This tutorial describes how to restart php-fpm on Ubuntu. This may be necessary, for example, if you have enabled opcode caching and performed a deployment.
The first step is to check the installed version of PHP:
php -v
The output should look something like this:
PHP 7.2.19-0ubuntu0.18.04.2 (cli) (built: Aug 12 2019 19:34:28) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.19-0ubuntu0.18.04.2, Copyright (c) 1999-2018, by Zend Technologies
Note: The command-line version of PHP (CLI) may differ from the "web server version" of PHP. To check the version used by the web server, create a simple PHP file with the following content:
<?php phpinfo() ?>
Use the following commands to restart php-fpm. Depending on the installed PHP version, select the appropriate command:
For PHP 7.2:
sudo service php7.2-fpm restart
For PHP 7.3:
sudo service php7.3-fpm restart
For PHP 7.4:
sudo service php7.4-fpm restart
For PHP 8.0:
sudo service php8.0-fpm restart
For PHP 8.1:
sudo service php8.1-fpm restart