Introduction:
PHP is widely used as a scripting language well known for creating dynamic and interactive web pages. It is mostly used to develop websites. Developer make use of it in developing their different projects. Today, we are going to cover the installation of PHP 7.4 as it is available to public on Ubuntu 18.04/19.04/19.10. Just follow the below steps
What’s new in php 7.4
- Functionality to be deprecated in php 7.4
- Warning on typing invalid containers
- Speed up your work
- Arrow functions
- Improved functionalities
- Smoother working and much more.
Step 1: Adding PHP PPA Repository
First of all, add ppa:ondrej/php PPA repository which has the latest build packages of PHP. Type the following commands to add repo. Press Enter on prompt to add repository.
sudo apt-get update
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
Step 2: Installing PHP 7.4 on Ubuntu 18.04/19.04/19.10
Simply fire the below command in your Ubuntu Terminal to Install php 7.4 and Press Y when to Continue the process.
root@ubuntu:/home/sabi# apt install php7.4
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
apache2 apache2-bin apache2-data apache2-utils
libapache2-mod-php7.4 libapr1 libaprutil1
libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0
libpcre2-8-0 php-common php7.4-cli php7.4-common
php7.4-json php7.4-opcache php7.4-readline
Suggested packages:
apache2-doc apache2-suexec-pristine
| apache2-suexec-custom php-pear
The following NEW packages will be installed:
apache2 apache2-bin apache2-data apache2-utils
libapache2-mod-php7.4 libapr1 libaprutil1
libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0
php-common php7.4 php7.4-cli php7.4-common php7.4-json
php7.4-opcache php7.4-readline
The following packages will be upgraded:
libpcre2-8-0
1 upgraded, 17 newly installed, 0 to remove and 3 not upgraded.
Need to get 5,993 kB of archives.
After this operation, 25.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Verify the Installation
root@ubuntu:/home/sabi# php -v
PHP 7.4.1 (cli) (built: Dec 18 2019 14:44:55) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.1, Copyright (c), by Zend Technologies
For additional packages installation follow the syntax
apt-get install php7.4-xxx
As you all know we require a web server in order to run PHP, so in this case we are going to consider Nginx on Ubuntu.
Installing Nginx
Before going to Install Nginx, don’t forget to disable the Apache server.
sudo systemctl disable --now apache2
After it Install fpm extensions and nginx packages & press Y to continue
sudo apt-get install nginx php7.4-fpm
Check the status of services by running
systemctl status php7.4-fpm nginx
root@ubuntu:/home/sabi# systemctl status php7.4-fpm nginx
● php7.4-fpm.service - The PHP 7.4 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php7.4-fpm.service;
Active: active (running) since Tue 2019-12-24 22:47:49 P
Docs: man:php-fpm7.4(8)
Main PID: 14611 (php-fpm7.4)
Status: "Processes active: 0, idle: 2, Requests: 0, slow
Tasks: 3 (limit: 2286)
Memory: 7.1M
CGroup: /system.slice/php7.4-fpm.service
├─14611 php-fpm: master process (/etc/php/7.4/fp
├─14620 php-fpm: pool www
└─14621 php-fpm: pool www
Dec 24 22:47:49 ubuntu systemd[1]: Starting The PHP 7.4 Fas
lines 1-14
You can find the PHP fpm Configuration file under /etc/php/7.4/fpm/pool.d/www.conf
Congratulations! You have successfully installed php 7.4 on Ubuntu. If have any queries regarding this tutorial, leave a comment.