Install php-fpm

 Updated on: 5.Dec.2020

  • To install php-fpm

   sudo apt install software-properties-common
   sudo add-apt-repository ppa:ondrej/php
   sudo apt update
   sudo apt install php7.3-fpm

  • Assign permission for current user, without this, might get permission issue when php trying to access the directory.
   sudo chown -R $USER:$USER /var/www/your_domain
  • To test if the PHP page is working, you have to create a test page and then load it in the browser.
   sudo nano /var/www/myweb.com/html/info.php
 
File contents:
 
   <?php
      phpinfo();
   ?>
  • To view the status of fast CGI process manager (FPM):
    sudo systemctl status php7.3-fpm
  • In case you need Sqlite, you will have to install SQLite component,
    sudo apt-get install php7.3-sqlite
 
After that, enable any extension by editing the PHP configuration,
 
    sudo nano /etc/php/7.3/fpm/php.ini
 
Note: if you installed version other than 7.3, please change it to the correct path. 

In nano editor, press CTRL+w to search text. Type "pdo_sqlite". Then, uncomment (remove the ";" symbol) that line and save it.
 
     ....
    ;extension=pdo_pgsql
    extension=pdo_sqlite
    ;extension=pgsql
     ....
 
    sudo systemctl restart nginx
    sudo systemctl restart php7.3-fpm

  • To troubleshoot any error,
   # restart PHP service - in case any error, you will find it in syslog
   sudo systemctl restart php7.3-fpm 

   # look for the last few logs
   tail /var/log/syslog

For example, you found the following error appear in syslog:

   PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_sqlite'
   PHP Warning:  Module 'sqlite3' already loaded


This means that Sqlite extension has already been loaded as per the setting in the following directory:

   ls /etc/php/7.3/fpm/conf.d

To resolve this issue, you have to disable Sqlite extension in php.ini
  • To upgrade from x to v7.3
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt install php7.3
sudo apt purge --auto-remove php7.2-fpm

No comments:

Post a Comment