CentOS 8 / RHEL 8 install PHP 7.4

CentOS 8/RHEL 8 uses yum tool to install php7.2 by default. For some software, php7.4 version is required. The following describes the environment for installing php7.4 on CentOS 8/RHEL 8.

1. Add epel and remi warehouse

Add a repository with php7.4 resource package and its extension package
yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
yum -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm


2. Install php

Run the following command to install dnf, then you can install php
dnf -y install dnf-utils

Uninstall the previous version

yum erase php*

Reset and enable php7.4

dnf module reset php
dnf module enable php:remi-7.4
Install php7.4
dnf module install php:remi-7.4


After installing php, you can check the version with the following command:

php -v

3. Install php7.4 extension plug-in (optional)

Install the php7.4 extension plug-in, you can execute the following similar commands
yum install php-extension_name
Now briefly introduce, install wordpress related php7.4 extension plug-ins
yum install -y php-dom php-simplexml php-ssh2 php-xml php-xmlreader php-curl php-date php-exif php-filter php-ftp php-gd php-hash php-iconv php-json php-libxml php -pecl-imagick php-mbstring php-mysqlnd php-openssl php-pcre php-posix php-sockets php-spl php-tokenizer php-zlib

4. Configure php7.4 (optional)

We can deploy web services by configuring the php.ini file. Edit this file in the following directory:
vi /etc/php.ini
Modify the following values ​​to achieve the best performance
upload_max_filesize = 32M
post_max_size = 48M
memory_limit = 256M
max_execution_time = 600
max_input_vars = 3000
max_input_time = 1000

5. Configure PHP 7.4 FPM Pools (optional)

PHP 7.4 FPM allows you to configure the users and groups that run the service. You can modify them with the following command
vi /etc/php-fpm.d/www.conf
Suspend the following lines by replacing www-data with your username
user = username
group = username
listen.owner = username
listen.group = username

6. Start the PHP service

Edit the configuration file and modify it to port monitoring service, the default port is 9000
vi /etc/php-fpm.d/www.conf

start up:

# start up
systemctl start php-fpm.service
# stop
systemctl stop php-fpm.service
# Restart
systemctl restart php-fpm.service

View status:

# View status
netstat -nlp | grep 9000

Congratulations you have completed the installation of php7.4

0

Leave a Reply

Your email address will not be published.