How to Restart PHP on CentOS

After upgrading or changing PHP on a CentOS server, you must restart your Web server daemon before the changes take effect. Most CentOS servers use Apache's HTTP daemon, but some use other daemons such as NGINX or Tomcat. Each of these services includes a restart script that is usually on the system executable path, and to make the process easy, they all use the same syntax.

male hands typing on a laptop pc keyboard
Close-up of hands typing on a laptop keyboard
credit: tanialerro/iStock/Getty Images

Restart The Web Server Daemon

You can restart services in a virtual terminal if you have physical access to the server or through Secure Shell if you're logging in remotely. Open a terminal window and enter the following command:

service your-web-server-daemon restart

Substitute the name of your Web server daemon for “your-web-server-daemon” in the command. For example, if you're using Apache, enter the following command:

service httpd restart

If you're remotely logging in to your server, use SSH to restart the service by entering the following command:

ssh your-domain-name service your-web-server-daemon restart

Substitute your domain name, including the top-level domain suffix, for “your-domain-name” and your server daemon for “your-web-server-daemon.” For example, enter a command such as the following:

ssh service httpd restart

When your Web server restarts, it reloads your PHP module and applies any changes you've made.