How to Install PHP 7.3-FPM on Ubuntu 19.10

Here is how you can install PHP 7.3-FPM on Ubuntu. In particular on Vultr’s instance i.e. Ubuntu 19.10.

Prerequisites

  • Have an Ubuntu 19.10 x64 instance.
  • Logged in as a root with sudo privileges.
  • You will also need to have Nginx installed by following these instructions.

Step 1: Add Ondrej PHP PPA repository

PHP 7.3 can be installed using Ondřej Surý PPA, so install the software-properties-common package with the following command:

sudo apt-get install software-properties-common

Now add the ondrej PPA and update your sources using the following commands:

sudo add-apt-repository -y ppa:ondrej/php
sudo apt-get update

Step 2: Install PHP 7.3-FPM & PHP Extensions

Install PHP 7.3-FPM on Ubuntu & most commonly used PHP extensions using the following command:

sudo apt install php7.3-fpm php7.3-common php7.3-zip php7.3-curl php7.3-xml php7.3-xmlrpc php7.3-json php7.3-mysql php7.3-pdo php7.3-gd php7.3-imagick php7.3-ldap php7.3-imap php7.3-mbstring php7.3-intl php7.3-cli php7.3-recode php7.3-tidy php7.3-bcmath php7.3-opcache

Step 3: Check the PHP installation

You can use php -v command to check the PHP version installed on your server and output will be

PHP 7.3.11-1+ubuntu19.10.1+deb.sury.org+6 (cli) (built: Oct 28 2019 21:34:37) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.11-1+ubuntu19.10.1+deb.sury.org+6, Copyright (c) 1999-2018, by Zend Technologies

You can also confirm installed version of any PHP extension using apt policy command i.e. apt policy php7.3-cli and output will be

php7.3-cli:
  Installed: 7.3.11-1+ubuntu19.10.1+deb.sury.org+6
  Candidate: 7.3.11-1+ubuntu19.10.1+deb.sury.org+6
  Version table:
 *** 7.3.11-1+ubuntu19.10.1+deb.sury.org+6 500
        500 http://ppa.launchpad.net/ondrej/php/ubuntu eoan/main amd64 Packages
        100 /var/lib/dpkg/status
     7.3.11-0ubuntu0.19.10.1 500
        500 http://archive.ubuntu.com/ubuntu eoan-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu eoan-security/main amd64 Packages
     7.3.8-1 500
        500 http://archive.ubuntu.com/ubuntu eoan/main amd64 Packages

Now, PHP 7.3-FPM has been installed on your Ubuntu server. The default Nginx PHP-FPM configuration file is at /etc/php/7.3/fpm/php.ini and if we want to modify the default PHP configuration, open file for Nginx using the following command:

sudo nano /etc/php/7.3/fpm/php.ini

Step 4: Configure PHP 7.3-FPM for Nginx

Make the changes on the following below lines in the file and save. The value below is great settings to apply in your environments.

max_execution_time = 180
max_input_time = 360
max_input_vars = 5000
memory_limit = 256M
cgi.fix_pathinfo = 0
file_uploads = On
upload_max_filesize = 100M
allow_url_fopen = On
date.timezone = Asia/Karachi

After making the change above, save the file and close out.

Step 5: Restart Nginx And PHP-FPM

After installing PHP and related modules, all you have to do is restart Nginx to reload PHP configurations.

To restart Nginx and PHP-FPM, run the commands below

sudo systemctl restart nginx.service
sudo systemctl restart php7.3-fpm

Now you are having PHP-FPM 7.3 Installed and configured.

Conclusion

Now you have learned how to install PHP 7.3-FPM on your Ubuntu server.

Leave your comment