Saturday, December 28, 2024
Google search engine
HomeGuest BlogsHow To Install PHP 7.4 on Ubuntu 20.04/18.04/16.04

How To Install PHP 7.4 on Ubuntu 20.04/18.04/16.04

.tdi_3.td-a-rec{text-align:center}.tdi_3 .td-element-style{z-index:-1}.tdi_3.td-a-rec-img{text-align:left}.tdi_3.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_3.td-a-rec-img{text-align:center}}

How to Install PHP 7.4 on Ubuntu?. Welcome to today’s guide on how to install PHP 7.4 on Ubuntu 20.04/18.04/16.04 Linux. The PHP release 7.4.0 has been made available for the general public and for use in Production environments.

PHP is a popular server scripting language known for creating dynamic and interactive Web pages. PHP is widely-used programming language in the Web. Use the steps below to install PHP 7.4 on Ubuntu 20.04/18.04/16.04.

Install PHP 7.4 on Ubuntu 20.04/18.04/16.04

Let’s consider the two installations for PHP 7.4 on Ubuntu 20.04 / Ubuntu 18.04 and Ubuntu 16.04.

.tdi_2.td-a-rec{text-align:center}.tdi_2 .td-element-style{z-index:-1}.tdi_2.td-a-rec-img{text-align:left}.tdi_2.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_2.td-a-rec-img{text-align:center}}

Install PHP 7.4 on Ubuntu 20.04

NOTE: Ubuntu 20.04 ships with PHP 7.4 in its upstream repositories. Just install it and the extensions you with the apt package manager.

sudo apt update
sudo apt install php php-cli php-fpm php-json php-common php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath

Confirm PHP version:

$ php --version
PHP 7.4.3-4ubuntu2.19 (cli) (built: Jun 27 2023 15:49:59) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.3-4ubuntu2.19, Copyright (c), by Zend Technologies

Listing all loaded PHP modules:

$ php -m

Install PHP 7.4 on Ubuntu 18.04 / Ubuntu 16.04

For the other editions of Ubuntu, use the process below:

Step 1: Add PHP PPA Repository

We’ll PPA repository which has the latest build packages of PHP. But first install dependent packages.

sudo apt update
sudo apt -y install software-properties-common

Add the repos:

sudo add-apt-repository ppa:sergey-dryabzhinsky/php74
sudo add-apt-repository ppa:sergey-dryabzhinsky/php7-modules
sudo add-apt-repository ppa:sergey-dryabzhinsky/backports
sudo add-apt-repository ppa:sergey-dryabzhinsky/packages

Step 2: Install PHP 7.4 on Ubuntu 18.04/16.04

Install PHP 7.4 on Ubuntu using the command:

sudo apt -y install php7.4

Check version installed:

$ php -v
PHP 7.4.33-SergeyD/6.1 (cli) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

Use the next command to install additional packages:

sudo apt install php7.4-xxx

Example:

sudo apt install php74p-mod-{mysql,bcmath,bz2,gd,intl,mbstring,zip,json}

PHP configurations related to Apache is stored in /etc/php74/cli/php.ini

Confirm PHP version:

$ php --version
PHP 7.4.33-SergeyD/6.1 (cli) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

Using PHP 7.4 with Apache

Install Apache PHP module.

sudo apt install libapache2-mod-php74

Using PHP 7.4 with Nginx

The installation of php on Ubuntu configures Apache. For users interested in running Nginx and PHP, you need to stop and disable Apache service.

sudo systemctl disable --now apache2

Then install fpm extension and nginx packages.

### Ubuntu 20.04 ###
sudo apt install nginx php7.4-fpm

### Ubuntu 18.04/16.04 ###
sudo apt install nginx php74p-fpm

PHP FPM configuration file is /etc/php74/fpm/pool.d/www.conf. Enjoy using PHP 7.4 on Ubuntu 20.04/ Ubuntu 18.04 / Ubuntu 16.04 Linux system.

Conclusion

In conclusion, this source supplied a complete information on how to installation PHP 7.4 on Ubuntu 20.04, 18.04, and 16.04. PHP 7.4 is a widely-used programming language for growing dynamic and interactive web pages. For Ubuntu 20.04, PHP 7.4 is easily reachable in the upstream repositories, making it convenient to set up the use of the apt package deal manager. However, for Ubuntu 18.04 and 16.04, extra steps are required.

The article outlined the process of adding the PHP PPA repository and installing PHP 7.4 using the appropriate commands. It also mentioned how to configure PHP with Nginx for those interested in using Nginx instead of Apache. By following the instructions provided, users can enjoy the benefits of PHP 7.4 on their Ubuntu systems. Whether you are a novice or an skilled developer, having PHP conveniently reachable on your Ubuntu machine empowers you to construct strong and dynamic net functions efficiently.

For other systems:

How To Install PHP 7.4 on Fedora

How To Install PHP 7.4 on CentOS 8 / RHEL 8

How To Install PHP 7.4 on CentOS 7

How To Install PHP 7.4 on Debian

.tdi_4.td-a-rec{text-align:center}.tdi_4 .td-element-style{z-index:-1}.tdi_4.td-a-rec-img{text-align:left}.tdi_4.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_4.td-a-rec-img{text-align:center}}

RELATED ARTICLES

Most Popular

Recent Comments