How to restart php on LAMP marketplace image?

Posted October 8, 2021 217 views
PHPUbuntu 20.04


I tried to restart php with service, systemctl or init.d/ but I unable to restart php and it says “Unit php8.0-fpm.service could not be found.”

php -v
PHP 8.0.11 (cli) (built: Sep 23 2021 21:26:24) ( NTS )
Copyright © The PHP Group
Zend Engine v4.0.11, Copyright © Zend Technologies
with Zend OPcache v8.0.11, Copyright ©, by Zend Technologies

How can I restart php?


These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

First, let’s find the service name:

systemctl list-units|grep php

If a service named php comes back, restart it

If nothing comes back, that means we need to find out the web server you’re running:

systemctl list-units|grep 'nginx\|apache' # leave the \ in there

If it comes back apache, restart apache.
If it comes back NGINX, let me know here, and I can help further.

Hello, @mraheel83Starfish

You can first check if the php-fpm service is running using the ps command:

  • ps axu | grep -i php

The output will help you to see which is the php-fpm process and from there you can restart the php-fpm service using the systemctl command:

  • systemctl restart php8.0-fpm.service

Note that your version might be different and you’ll need to substitute 8.0 with the actual php-fpm version that your server runs.