Home Backend Development PHP8 Quickly install php8.2 suite (centos stream 9)

Quickly install php8.2 suite (centos stream 9)

Apr 11, 2023 pm 03:22 PM
php8.2

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!

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

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 ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8 Installation Guide: Step-by-Step for Windows, macOS, and Linux PHP 8 Installation Guide: Step-by-Step for Windows, macOS, and Linux Mar 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 Do I Stay Up-to-Date with the Latest PHP 8 Best Practices and Trends? How Do I Stay Up-to-Date with the Latest PHP 8 Best Practices and Trends? Mar 10, 2025 pm 06:04 PM

This article details how to stay updated on PHP 8 best practices. It emphasizes consistent engagement with resources like blogs, online communities, conferences, and the official documentation. Key PHP 8 features like union types, named arguments,

PHP 8: Date and Time Manipulation - Mastering the DateTime Class PHP 8: Date and Time Manipulation - Mastering the DateTime Class Mar 10, 2025 am 11:29 AM

This article details PHP 8's DateTime class for date/time manipulation. It covers core functionalities, improved error handling, union types, and attributes. Best practices for efficient calculations, time zone handling, and internationalization a

How Can I Leverage PHPStan for Static Analysis in PHP 8? How Can I Leverage PHPStan for Static Analysis in PHP 8? Mar 10, 2025 pm 06:00 PM

This article explains how to use PHPStan for static analysis in PHP 8 projects. It details installation, command-line usage, and phpstan.neon configuration for customizing analysis levels, excluding paths, and managing rules. The benefits include

PHP 8 Security: Protect Your Website from Common Vulnerabilities PHP 8 Security: Protect Your Website from Common Vulnerabilities Mar 10, 2025 am 11:26 AM

This article examines common PHP 8 security vulnerabilities, including SQL injection, XSS, CSRF, session hijacking, file inclusion, and RCE. It emphasizes best practices like input validation, output encoding, secure session management, and regular

PHP 8: Working with Arrays - Tips and Tricks for Efficient Data Handling PHP 8: Working with Arrays - Tips and Tricks for Efficient Data Handling Mar 10, 2025 am 11:28 AM

This article explores efficient array handling in PHP 8. It examines techniques for optimizing array operations, including using appropriate functions (e.g., array_map), data structures (e.g., SplFixedArray), and avoiding pitfalls like unnecessary c

How Do I Implement Event Sourcing in PHP 8? How Do I Implement Event Sourcing in PHP 8? Mar 10, 2025 pm 04:12 PM

This article details implementing event sourcing in PHP 8. It covers defining domain events, designing an event store, implementing event handlers, and reconstructing aggregate states. Best practices, common pitfalls, and helpful libraries (Prooph,

How Do I Write Effective Unit Tests for PHP 8 Code? How Do I Write Effective Unit Tests for PHP 8 Code? Mar 10, 2025 pm 06:00 PM

This article details best practices for writing effective PHPUnit unit tests in PHP 8. It emphasizes principles like independence, atomicity, and speed, advocating for leveraging PHP 8 features and avoiding common pitfalls such as over-mocking and

See all articles