Iam a new Linux user. How do I restart php service after editing php.ini file on Linux operating systems?
PHP is associated with either your web-server or external FastCGI process manager. In most cases you just need to restart web-server such as Apache / Nginx / Lighttpd depending on your system and software. This page explains how to restart PHP Service using Linux or Unix the command-line options.
Tutorial details | |
---|---|
Difficulty level | Easy |
Root privileges | Yes |
Requirements | Linux or Unix terminal |
Category | Processes Management |
OS compatibility | BSD • Linux • Unix |
Est. reading time | 3 minutes |
Restart PHP by restarting your web-server
Type the following command as per your web-server and operating systems.
Restart Apache for php service
If you are using Apache web server type the following command to restart the php:# /etc/init.d/apache2 restart
OR# apache2ctl restart
See how to restart Apache Web Server on Ubuntu Linux for more information.
Restart Nginx for php service
If you are using Nginx web-server type the following command to restart nginx:# /etc/init.d/nginx restart
OR# service nginx restart
OR# nginx -s reload
Restart Lighttpd for php service
If you are using Lighttpd web-server type the following command to restart lightpd:# /etc/init.d/lighttpd restart
OR# service lighttpd restart
Restart PHP-FAM Fastcgi for PHP service
If you are running php via PHP-FAM fastcgi manager, use any one of the following as per your version of Linux/Unix:# /etc/init.d/php-fpm restart
For php version 5 fpm:# /etc/init.d/php5-fpm restart
Are you using php version 7 fpm? Try:# /etc/init.d/php7.0-fpm restart
Other options on Linux using the service or systemctl command on systemd based Linux distros:# service php-fpm restart
# service php5-fpm restart
# service php7.0-fpm restart
# restart php-fpm # older ubuntu
# service php-fpm restart
OR# systemctl restart php-fpm
# systemctl restart php7.0-fpm
# Are you using PHP 8? Try
# systemctl restart php8.0-fpm
Here is how it looks on RHEL 8.x with PHP 8.x:$ sudo systemctl restart php-fpm
Getting status of PHP service
Again use any one of the following command:# /etc/init.d/php-fpm status
# service php-fpm status
# systemctl status php-fpm
Outputs from Rocky Linux/RHEL/CentOS with PHP v8.x:
● php-fpm.service - The PHP FastCGI Process Manager Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor pres et: disabled) Drop-In: /run/systemd/system/php-fpm.service.d └─zzz-lxc-service.conf Active: active (running) since Thu 2022-02-03 09:55:05 UTC; 1 week s 5 days ago Main PID: 525 (php-fpm) Status: "Processes active: 0, idle: 12, Requests: 16286, slow: 0, Traffic: 0r eq/sec" Tasks: 13 (limit: 102327) Memory: 168.5M CGroup: /system.slice/php-fpm.service ├─ 525 php-fpm: master process (/etc/php-fpm.conf) ├─ 544 php-fpm: pool www ├─ 545 php-fpm: pool www ├─ 546 php-fpm: pool www ├─ 547 php-fpm: pool www ├─ 548 php-fpm: pool www ├─ 592 php-fpm: pool www ├─ 725 php-fpm: pool www ├─1683 php-fpm: pool www ├─2228 php-fpm: pool www
A note about Alpine Linux
Use the following syntax# /etc/init.d/php-fpm7 restart
# /etc/init.d/php-fpm8 restart
See “how to enable and start services on Alpine Linux” for more info.
Summing up
I would suggest that you read the service command or systemctl command documentation on your Linux or Unix system using the man command:
man service man systemctl