Fast installation of php7.4 Suite (CentOS 7)

Time:2021-6-10

Fast installation of php7.4 Suite (CentOS 7)

Only CentOS 7 is considered in this paper

This paper was written on November 16, 2020

Remi is a PHP installation repository. It’s the RPM package.

How fast is it? It mainly depends on the installation of MySQL 8. The total installation time of all software is about 3 to 5 minutes (excluding the operating system).



Each software version in this paper

centos 7
php 7.4.12
nginx 1.18
mysql 8.0.22
redis 6.0.9
git 2.24.3


First, install Alibaba’s CentOS warehouse( centos 7)

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
yum makecache
yum repolist



Install Alibaba’s EPEL warehouse( centos 7)

curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

yum makecache
yum repolist



The warehouse for installing Ali’s Remi (CentOS 7)

yum install -y https://mirrors.aliyun.com/remi/enterprise/remi-release-7.rpm

sed -i  's/https*:\/\/rpms.remirepo.net/https:\/\/mirrors.aliyun.com\/remi/g'  /etc/yum.repos.d/remi*
sed -i 's/#baseurl/baseurl/g' /etc/yum.repos.d/remi*
sed -i 's|^mirrorlist|#mirrorlist|' /etc/yum.repos.d/remi*

yum makecache
yum repolist

yum -y install yum-utils



Install PHP (CentOS 7)

yum-config-manager --enable remi-php74

yum install -y php74 php74-php-devel  php74-php-fpm  php74-php-mbstring php74-php-memcache php74-php-memcached php74-php-redis  php74-php-mysqlnd  php74-php-pdo  php74-php-bcmath php74-php-xml php74-php-gd php74-php-gmp php74-php-igbinary php74-php-imagick   php74-php-mcrypt  php74-php-pdo_mysql php74-php-posix php74-php-simplexml  php74-php-opcache php74-php-xsl php74-php-xmlwriter php74-php-xmlreader php74-php-swoole php74-php-zip php74-php-phalcon  php74-php-yaml php74-php-yar php74-php-yaf php74-php-uuid

Experience the speed as fast as lightning!



Install Alibaba’s composer image source (CentOS 7)

ln -s /usr/bin/php74 /usr/bin/php

curl -o /usr/local/bin/composer https://mirrors.aliyun.com/composer/composer.phar

chmod +x /usr/local/bin/composer

composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/



Install nginx and integrate PHP FPM service (CentOS 7)

#The following echo is a command that needs to be copied together

/Etc / nginx / conf.d/default.conf file content is as follows

server {
    listen       80;
    server_name  localhost;
    charset utf-8 ;
    access_log  /var/log/nginx/host.access.log  main;
    root   /usr/share/nginx/html;
    index index.php  index.html index.htm;
    error_page 404  500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $realpath_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

Add a PHP file as follows:

vi /usr/share/nginx/html/1.php

<?php
phpinfo();

Start PHP FPM and nginx and verify that they are installed correctly

systemctl start nginx



Install MySQL 8 (CentOS 7)

rpm -Uvh  https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm

Next, the whole set of new user process, first change the initial, then add new users and authorization, and then delete old users.

set global validate_password.policy=LOW;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'aaaa1234';
flush privileges;
create user 'root'@'%' identified by 'root1234';
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root1234';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
drop user [email protected];
flush privileges;

Exit the shell and re-enter.

Now you can go directly to the shell

mysql -uroot -proot1234



Install git (CentOS 7) in aliimage source IUS

The reason for installing this is that the big version of GIT with CentOS 7 is 1, which is really too old.

In addition, Ali’s wool must be collected here~

yum install -y https://mirrors.aliyun.com/ius/ius-release-el7.rpm
sed -i  's/https:\/\/repo.ius.io/https:\/\/mirrors.aliyun.com\/ius/g'  /etc/yum.repos.d/ius*
yum makecache
yum install -y git224



Install redis 6 and other common libraries (CentOS 7)

yum --enablerepo=remi install -y redis
yum install -y  wget vim zip unzip p7zip rsync crontabs supervisor net-tools python3
systemctl enable redis
systemctl start redis

Summary (CentOS 7)

With the domestic image will be extremely fast, download package speed: 3MB / s, amazing fast

MySQL installation is sometimes very fast and sometimes slow. Only MySQL is a bit slow in this article.

This work adoptsCC agreementReprint must indicate the author and the link of this article