How to Restart PHP on CentOS

By David Wayne

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.

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 restartSubstitute 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 restartIf 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 restartSubstitute 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 example-domain.com service httpd restartWhen your Web server restarts, it reloads your PHP module and applies any changes you've made.