How to Restart PHP in Linux / Unix

If you are a relatively new Linux user and you manage a server with PHP, it is important that you know that after editing the php.ini file , you must restart the PHP service.

PHp is associated with your web server or with your external FastCGI process manager. In most cases, after editing the php.ini file , you only need to restart your server, which is probably Apache, Nginx or Lighttpd, depending on what you have installed on your operating system. In this way you can apply the new saved configuration .

We will see how to restart PHP, for which, you must restart your web server. Depending on your web server, you must execute one of the following commands:

Restart Apache to restart PHP

If you use Apache, type the following command:

# /etc/init.d/apache2 restart

Or also:

# apache2ctl restart

Or also, with the service command:

# service apache2 restart

If you use CentOS, the server will have the name of httpd instead of Apache2:

# service httpd restart

Restart Nginx to restart PHP

If you use the Nginx web server, type the following command to restart it:

# /etc/init.d/nginx restart

You can also use the service command:

# service nginx restart

Or also this command:

# nginx -s reload

Restart Lighttpd to restart PHP

If you use the Lighttpd web server, type the following command to restart it:

# /etc/init.d/lighttpd restart

Or also:

# service lighttpd restart

Restart PHP-FAM FastCGI to restart PHP

If you use PHP from the PHP-FAM fastcgi manager , use one of the following commands. Depending on your version of Linux, it may be one or the other:

# /etc/init.d/php-fpm restart

For PHP5 you can also run:

# /etc/init.d/php5-fpm restart

Or also:

# service php-fpm restart

Or also:

# service php5-fpm restart

And finally you can also try:

# restart php-fpm

Leave a Reply

Your email address will not be published. Required fields are marked *