We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – How To Install PHP 7.4 on Ubuntu 20.04/18.04/16.04

Learn how to – How To Install PHP 7.4 on Ubuntu 20.04/18.04/16.04.

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/19.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/19.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.

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 (cli) (built: Aug 17 2022 13:29:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.3, 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 add ppa:ondrej/php PPA repository which has the latest build packages of PHP.

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

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 (cli) (built: Feb 14 2023 18:31:54) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies

Use the next command to install additional packages:

sudo apt-get install php7.4-xxx

Example:

sudo apt install -y php7.4-{bcmath,bz2,intl,gd,mbstring,mysql,zip,common}

PHP configurations related to Apache is stored in /etc/php/7.4/apache2/php.ini

Using PHP 7.4 with Nginx on Ubuntu 20.04/18.04/16.04

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.

sudo apt-get install nginx php7.4-fpm

Nginx and fpm services should be running.

$ 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; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2019-09-16 17:09:41 UTC; 27s ago
     Docs: man:php-fpm7.4(8)
 Main PID: 25321 (php-fpm7.4)
   Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
    Tasks: 3 (limit: 2362)
   CGroup: /system.slice/php7.4-fpm.service
           ├─25321 php-fpm: master process (/etc/php/7.4/fpm/php-fpm.conf)
           ├─25339 php-fpm: pool www
           └─25340 php-fpm: pool www

Sep 16 17:09:41 ubuntu18 systemd[1]: Starting The PHP 7.4 FastCGI Process Manager...
Sep 16 17:09:41 ubuntu18 systemd[1]: Started The PHP 7.4 FastCGI Process Manager.

● nginx.service - A high performance web server and a reverse proxy server
    Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
    Active: active (running) since Mon 2019-09-16 17:09:42 UTC; 6min ago
      Docs: man:nginx(8)
  Main PID: 25441 (nginx)
     Tasks: 2 (limit: 2362)
    CGroup: /system.slice/nginx.service
            ├─25441 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
            └─25442 nginx: worker process
 Sep 16 17:09:42 ubuntu18 systemd[1]: Starting A high performance web server and a reverse proxy server…
 Sep 16 17:09:42 ubuntu18 systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument
 Sep 16 17:09:42 ubuntu18 systemd[1]: Started A high performance web server and a reverse proxy server.

PHP FPM configuration file is /etc/php/7.4/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

Cart

Your Cart is Empty

Back To Shop