Articles & Snippets

How to Restart Web Server on cPanel

Restarting your web server can fix configuration changes, clear stuck processes, and refresh services. On cPanel servers, you usually manage this via SSH as the root user.

Access Your Server

Open an SSH connection to your server using a terminal or SSH client. Log in as the root user because restarting services requires root permissions.


ssh root@your-server-ip

Restart Apache Web Server

To restart the main Apache HTTP server, run:


/scripts/restartsrv_httpd

Command Breakdown

  • /scripts/restartsrv_httpd is a cPanel script that stops and starts the Apache HTTP service.
  • It reloads configuration changes without rebooting the server.

Restart Apache with PHP-FPM

If you use PHP-FPM for handling PHP requests, restart it as well:


/scripts/restartsrv_apache_php_fpm

Command Breakdown

  • /scripts/restartsrv_apache_php_fpm restarts PHP-FPM along with Apache.
  • This ensures PHP processes use updated configuration.

Verify Server Status


systemctl status httpd
systemctl status php-fpm

These commands show if Apache and PHP-FPM are running after restart. Check for errors in the logs if the services fail to start.

Best Practices

  • Always back up configuration files before making changes.
  • Restart services during low traffic periods to avoid downtime.
  • Monitor error logs in /usr/local/apache/logs/error_log for issues.
  • Use the cPanel WHM interface for a safer restart if you are not comfortable with SSH.

Summary

Use /scripts/restartsrv_httpd to restart Apache and /scripts/restartsrv_apache_php_fpm to restart Apache with PHP-FPM. Verify services are running and check logs if needed.


linux  cpanel  restart web server