search
HomeBackend DevelopmentPHP8Quickly install php8.2 suite (centos stream 9)

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

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

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

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

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

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

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/

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

/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 the installation is correct

systemctl start nginx
systemctl start php82-php-fpm

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

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

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;

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客户端无法连接!

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

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!

Statement
This article is reproduced at:learnku. If there is any infringement, please contact admin@php.cn delete
How to deploy PHP 8 securelyHow to deploy PHP 8 securelyMar 03, 2025 pm 04:54 PM

This guide details securing PHP 8 deployments. It covers code-level practices (input validation, output encoding, dependency management), deployment processes (version control, staging), and server-side security (updates, firewalls, HTTPS). The mai

How to perform security testing in PHP 8How to perform security testing in PHP 8Mar 03, 2025 pm 04:58 PM

This article provides a comprehensive guide to security testing for PHP 8 applications. It details various testing methods, including static & dynamic analysis, code review, and vulnerability scanning, highlighting tools like Psalm, OWASP ZAP, a

PHP 8 Installation Guide: Step-by-Step for Windows, macOS, and LinuxPHP 8 Installation Guide: Step-by-Step for Windows, macOS, and LinuxMar 10, 2025 am 11:14 AM

This guide details PHP 8 installation on Windows, macOS, and Linux. It covers OS-specific steps, including using package managers (Homebrew, apt), manual installation from source, and configuring PHP with Apache or Nginx. Troubleshooting tips are a

How to use Web Application Firewall in PHP 8How to use Web Application Firewall in PHP 8Mar 03, 2025 pm 05:02 PM

This article details how to enhance PHP 8 application security using a Web Application Firewall (WAF). It covers WAF integration (e.g., Cloudflare, AWS WAF), best practices (regular updates, robust logging), mitigating common vulnerabilities (SQL in

How to implement multi-factor authentication in PHP 8How to implement multi-factor authentication in PHP 8Mar 03, 2025 pm 04:55 PM

This article details implementing multi-factor authentication (MFA) in PHP 8 using TOTP. It covers key aspects: secret key generation & storage, TOTP code generation & verification, secure coding practices (input validation, rate limiting, H

How to filter input in PHP 8How to filter input in PHP 8Mar 03, 2025 pm 05:01 PM

This article explores secure input filtering in PHP 8, emphasizing prevention of vulnerabilities like SQL injection and XSS. It details validation, sanitization, and parameterized queries as core techniques, advocating a multi-layered approach incor

How to set appropriate file permissions in PHP 8How to set appropriate file permissions in PHP 8Mar 03, 2025 pm 04:57 PM

This article emphasizes secure file permission practices in PHP 8. It advocates setting permissions externally, using the principle of least privilege, and avoiding dynamic chmod() use within PHP code to mitigate security risks. Proper octal notati

How to prevent information leakage in PHP 8How to prevent information leakage in PHP 8Mar 03, 2025 pm 05:00 PM

This article details preventing information leakage in PHP 8. It emphasizes secure coding, input validation, robust error handling, and utilizing PHP's built-in security features to mitigate vulnerabilities like SQL injection and XSS. Best practice

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool