Ubuntu16.04/18.04 install PHP7.4

The following describes how to install PHP 7.4 is very simple. It applies to Ubuntu 18.04/19.04/16.04. The installed version is PHP 7.4.0 RC1. You only need to add the PHP ppa repository and run the relevant commands to complete the installation. 1. Add the PHP ppa repository We will add the ppa:ondrej/php PPA repository, which has the latest PHP buildpacks, and the reference teaches you two ways to add the Apt repository in Ubuntu/Debian systems: sudo apt-get update sudo apt -y install software-properties-common sudo add-apt-repository ppa:ondrej/php sudo apt-get update Second, the command to install PHP 7.4 on Ubuntu 18.04/19.04/16.04 Install PHP 7.4 on Ubuntu with the following command: sudo apt -y install php7.4 After testing, it can be successfully installed on Ubuntu 18.04/19.04/16.04 versions. To check the installed version, run the php -v command:

#################################################################################

Method 2

#################################################################################

Ubuntu 16.04 and 18.04 default to the installation of packages that do not support php7.4. For some specific software, PHP7.4 software support is required. For this reason, installing PHP7.4 under Ubuntu is a very important process. The following describes the installation of PHP7. 4 methods, the actual measurement works well!

1:Install the add-apt-repository command

Install with the following command

sudo apt-get install software-properties-common

2:Add sources with the add-apt-repository command

sudo add-apt-repository ppa:ondrej/php

# Install
sudo apt-get install php7.4 php7.4-fpm php7.4-mysql php7.4-gd php7.4-mbstring php7.4-bcmath php7.4-sqlite3 php7.4-cli php7.4-soap
# start up
sudo service php7.4-fpm start
# restart
sudo service php7.4-fpm restart
# stop
sudo service php7.4-fpm stop
# Use the netstat command to view the listening status
sudo netstat -nlp | grep 9000

The default monitoring method of php74-fpm is the sock method, for which we need to modify the configuration file

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

# Comment listen = /run/php/php7.4-fpm.sock
# Add to
listen=127.0.0.1:9000
# Restart and use the netstat command to check the listening status
sudo service php7.4-fpm restart
sudo netstat -nlp | grep 9000

Such a configuration needs to be added to Nginx (there is Nginx option, but none can be ignored)

 location ~ .php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
       }

5:Test

# check version
php -v

Configure PHP 7.4 FPM Pools (optional)

PHP 7.4 FPM allows you to configure the user and group that runs the service. You can modify them with

vi /etc/php/7.4/fpm/pool.d/www.conf

Suspend the following lines by replacing www-data with your username

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

Leave a Reply

Your email address will not be published.

en_USEnglish