How to Restart PHP on CentOS

Techwalla may earn compensation through affiliate links in this story. Learn more about our affiliate and product review process here.
Close-up of hands typing on a laptop keyboard
Image Credit: tanialerro/iStock/Getty Images

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.

Advertisement

Restart The Web Server Daemon

Video of the Day

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:

Advertisement

Video of the Day

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:

Advertisement

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

Advertisement

Advertisement

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 example-domain.com service httpd restart

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

Advertisement

Advertisement

references