Latest Technology News, Mobile, Laptop, Gadgets and Much More

How To Install PHP 7.4 on Ubuntu 16.04/ 18.04/ 19.04/ 19.10

0 4,103

In this tutorial, We’ll show you How To Install PHP 7.4 on Ubuntu 16.04/ 18.04/ 19.04/ 19.10. New PHP 7.4 comes with many new features and improvements and as a result of this many developers are using it for their projects. Installing the latest PHP version 7.4 on your Ubuntu system or your Ubuntu server on any VPS or any Cloud or any Dedicated hosting and configure it with Apache is an easy task, just follow the steps below and you should have it done in a few minutes.

The latest PHP 7.4 version is officially released on November 28th, 2019. It comes with a number of new features and a few incompatibilities that you should be aware of before upgrading from the previous version.

This installation is tested on the Vultr Cloud VPS Platform with a Compute Compute Engine VM Instance. This set up will work on all Linux servers.

Getting Started

Make sure your Ubuntu server is having the latest packages by running the following command.

sudo apt update
sudo apt upgrade

This will update the package index and update the installed packages to the latest version.

Step 1: Add PHP PPA Repository

We’ll add ppa:ondrej/php PPA repository which has the latest build packages of PHP.

sudo apt-get update
sudo apt -y install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update

Step 2: Install PHP 7.4 on Ubuntu 16.04/18.04/19.04/ 19.10

sudo apt -y install php7.4

After the installation has completed, you can confirm the installation using the following command.

php -v

Installing PHP Modules/ Extensions

Now, install some commonly used php-extensions with the following command.

sudo apt install php7.4-common php7.4-mysql php7.4-xml php7.4-xmlrpc php7.4-curl php7.4-gd php7.4-imagick php7.4-cli php7.4-dev php7.4-imap php7.4-mbstring php7.4-opcache php7.4-soap php7.4-zip php7.4-intl -y

Configure PHP 7.4

Now we configure PHP for Web Applications by changing some values in php.ini file.

For PHP 7.4 with Apache the php.ini the location will be in the following directory.

sudo nano /etc/php/7.4/apache2/php.ini

For PHP 7.4 FPM with Nginx the php.ini the location will be in the following directory.

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

Hit F6 for search inside the editor and update the following values for better performance.

upload_max_filesize = 32M 
post_max_size = 48M 
memory_limit = 256M 
max_execution_time = 600 
max_input_vars = 3000 
max_input_time = 1000

Once you have modified your PHP settings you need to restart your Apache for the changes to take effect.

Configure PHP 7.4 FPM Pools

PHP 7.4 FPM allows you to configure the user and group that the service will run under. You can modify these with these commands

sudo nano /etc/php/7.4/fpm/pool.d/www.conf

Change the following lines by replacing the www-data with your username.

user = username 
group = username 
listen.owner = username
listen.group = username

Hit CTRL+X and Y to save the configuration and check if the configuration is correct and restart PHP.

Restart PHP 7.4 FPM

Once you have updated your PHP FPM settings you need to restart it to apply the changes.

sudo php-fpm7.4 -t 
sudo service php7.4-fpm restart

Great, now you are having PHP 7.4 successfully Installed and configured.


We hope this post helped you to find out How To Install PHP 7.4 on Ubuntu 16.04/ 18.04/ 19.04/ 19.10

We love to hear your comments on this article. Please feel free to leave any comments here.

If you liked this article, then please share to Social Media Site. You can also find us on Facebook, Twitter, and Instagram.

Thanks for reading this.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More