Home > Backend Development > PHP8 > body text

Quickly install php8.2 suite (centos stream 9)

藏色散人
Release: 2023-04-11 15:24:43
forward
2966 people have browsed it

This article brings you relevant knowledge about php8.2. It mainly introduces and teaches you how to quickly install the php8.2 package in centos stream 9? How fast is it? Let’s take a look at it together, I hope it will be helpful to everyone.

Lightning fast installation of php8.2 package (centos stream 9)

  • This article only considers centos stream 9

This article was written on: 2023-04-11. The article is relatively new and I have carefully tested it myself.

centos stream 9 is the community version of centos. Currently, what I see is that Alibaba Cloud and Baidu Cloud have direct mirroring options for centos stream 9. If centos stream 8 is used, Alibaba Cloud, Baidu Cloud and Tencent There are images of centos stream 8 in the cloud, but 8 is too old, so centos stream 9 should be used.

In addition, from the outside, Rocky Linux and AlmaLinux are both clones of centos. They are widely used and can be used.

If you use an operating system image, I will do this

docker pull dokken/centos-stream-9:latest
docker  run -tid --name centos_stream_9   --privileged=true  dokken/centos-stream-9:latest /usr/sbin/init
docker exec -it centos_stream_9 /bin/bash
Copy after login

remi is a PHP installation repository. It is an rpm package.
How fast? Today's actual measurement showed that the total installation time for all software is about 3 minutes (excluding the operating system).

Each software version in this article

CentOS Stream release 9
php 8.2.4
nginx 1.22.1
mysql 8.0.32
redis 6.2.7
git 2.39.1
Copy after login

First, install Alibaba’s centos warehouse. (centos stream 9)

cd /etc/yum.repos.d
cp centos.repo centos.repo.bak
cp centos-addons.repo centos-addons.repo.bak

现在修改 centos.repo
把小节[baseos]和小节 [appstream]和小节[crb]下面的
metalink= 。。。 
都改成
# metalink= 。。。

然后,把小节[baseos]下面的  
# metalink 下面加一行
baseurl=https://mirrors.aliyun.com/centos-stream/9-stream/BaseOS/x86_64/os/

然后,把小节[appstream]下面的 
# metalink 下面加一行
baseurl=https://mirrors.aliyun.com/centos-stream/9-stream/AppStream/x86_64/os/

然后,把小节[crb]下面的 
# metalink 下面加一行
baseurl=https://mirrors.aliyun.com/centos-stream/9-stream/CRB/x86_64/os/


dnf makecache
dnf repolist
Copy after login

Install the epel repository. (centos stream 9)

dnf install 'dnf-command(config-manager)'
dnf --enable config-manager crb
dnf install -y epel-release epel-next-release

dnf makecache
dnf repolist
Copy after login

At this time, there is an epel warehouse in the /etc/yum.repos.d directory, and the source is foreign.

Install Alibaba's remi warehouse (centos stream 9)

dnf install -y https://mirrors.aliyun.com/remi/enterprise/remi-release-9.rpm

sed -i  's/http*:\/\/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*

dnf makecache
dnf repolist

dnf -y install yum-utils
Copy after login

Install php 8.2 (centos stream 9)

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

Execute the above command for about 1 minute. Fast as lightning!

Install Alibaba’s composer image source (centos stream 9)

rm /usr/bin/php
ln -s /usr/bin/php82 /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/
Copy after login

Install nginx and integrate php-fpm service (centos stream 9)

# 下面这个echo是一句命令,得一起复制

echo $'[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true ' > /etc/yum.repos.d/nginx.repo

# 上面是一条echo命令。

dnf makecache
dnf install -y nginx
systemctl enable nginx
systemctl enable php82-php-fpm
sed -i 's/user\ =\ apache/user\ =\ nginx/g' /etc/opt/remi/php82/php-fpm.d/www.conf
sed -i 's/group\ =\ apache/group\ =\ nginx/g' /etc/opt/remi/php82/php-fpm.d/www.conf

sed -i 's/listen\ =\ \/var\/opt\/remi\/php82\/run\/php-fpm\/www.sock/listen=9000/g' /etc/opt/remi/php82/php-fpm.d/www.conf

rm -f /etc/nginx/conf.d/default.conf
vi /etc/nginx/conf.d/default.conf
Copy after login

/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;
    }
}
Copy after login

Add a php file as follows:

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

<?php
phpinfo();
Copy after login

Start php-fpm and nginx And verify that the installation is correct

systemctl start nginx
systemctl start php82-php-fpm

curl localhost/1.php
# 如果能看到很多的大量输出,说明php和nginx正确安装了。
Copy after login

Install mysql 8 (centos stream 9)

dnf install -y https://repo.mysql.com/mysql80-community-release-el9-1.noarch.rpm

# 下面这句安装mysql服务,时间大概1到3分钟左右。

dnf -y --enablerepo=mysql80-community install mysql-community-server

systemctl enable mysqld
systemctl start mysqld

# 查看初始密码:
grep &#39;temporary password&#39; /var/log/mysqld.log

# 用查看到的密码进入mysql 的 shell
mysql -uroot -p
Copy after login

Below, the entire process of setting up a new user, first change the initialization, add a new user and authorize it , and then delete the old user.

ALTER USER &#39;root&#39;@&#39;localhost&#39; IDENTIFIED WITH mysql_native_password BY &#39;tb4Wn3BthR.&#39;;
flush privileges;
set global validate_password.policy=LOW;
create user &#39;root&#39;@&#39;%&#39; identified by &#39;root1234&#39;;
ALTER USER &#39;root&#39;@&#39;%&#39; IDENTIFIED WITH mysql_native_password BY &#39;root1234&#39;;
GRANT ALL PRIVILEGES ON *.* TO &#39;root&#39;@&#39;%&#39;;
drop user root@localhost;
flush privileges;
Copy after login

Exit the shell and re-enter.

Now you can directly enter the shell

mysql -uroot -proot1234

# 这句话查看用户的加密方式。
select user, host, plugin from mysql.user\G;

# plugin: caching_sha2_password 表示老的MySQL客户端无法连接!
Copy after login

Install redis 6 and other commonly used libraries (centos stream 9)

dnf --enablerepo=remi install -y redis
dnf install -y git wget vim zip unzip p7zip rsync crontabs supervisor net-tools python3
systemctl enable redis
systemctl start redis
Copy after login

Summary (centos stream 9)

Using domestic mirroring will be extremely fast, the speed of downloading the package: 3MB/second, amazingly fast

In addition, thanks to the Alibaba Cloud Mirror Library, it is very fast and convenient . [Recommended learning: "PHP Video Tutorial"]

The above is the detailed content of Quickly install php8.2 suite (centos stream 9). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:learnku.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!