快速安装php8.2套件(centos stream 9)

广告:宝塔服务器面板,一键全能部署及管理,送你10850元礼包,点我领取~~~

快速安装php8.2套件(centos stream 9)

本篇文章给大家带来了关于php8.2的相关知识,其中主要介绍了教大家在centos stream 9中怎么快速安装php8.2套件?到底有多快呢?下面一起来看一下,希望对大家有帮助。

快如闪电的安装php8.2套件(centos stream 9)

本文只考虑centos stream 9

本文编写时间:2023-04-11,文章较新,是我自己仔细测试过的。

centos stream 9 是 centos 的社区版,目前我看到的是阿里云和百度云有 centos stream 9 的直接镜像选择,如果是用 centos stream 8的话,阿里云和百度云和腾讯云都有 centos stream 8 的镜像,但是 8 太老了,应该使用 centos stream 9 。

另外,从外网看,Rocky Linux, AlmaLinux 这两个都是centos的克隆版本,使用已经都比较广泛,也都可以用。

如果使用操作系统镜像的话,我这样操作

docker pull dokken/centos-stream-9:latestdocker  run -tid --name centos_stream_9   --privileged=true  dokken/centos-stream-9:latest /usr/sbin/initdocker exec -it centos_stream_9 /bin/bash
登录后复制

remi是一个php安装仓库。是rpm包。到底有多快?今天的实测,全部软件的安装时间总共约 3 分钟(不含操作系统)。

本文各软件版本

CentOS Stream release 9php 8.2.4nginx 1.22.1mysql 8.0.32redis 6.2.7git 2.39.1
登录后复制

首先,安装阿里的 centos 仓库。(centos stream 9)

cd /etc/yum.repos.dcp centos.repo centos.repo.bakcp 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 makecachednf repolist
登录后复制

安装 epel 仓库。(centos stream 9)

dnf install 'dnf-command(config-manager)'dnf --enable config-manager crbdnf install -y epel-release epel-next-releasednf makecachednf repolist
登录后复制

此时,/etc/yum.repos.d 目录下,多了epel的仓库,且源是外国的。

安装阿里的 remi 的仓库(centos stream 9)

dnf install -y https://mirrors.aliyun.com/remi/enterprise/remi-release-9.rpmsed -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 makecachednf repolistdnf -y install yum-utils
登录后复制

安装 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
登录后复制

执行上面这个命令,大约1分钟左右。快如闪电!

安装阿里的 composer 镜像源(centos stream 9)

rm /usr/bin/phpln -s /usr/bin/php82 /usr/bin/phpcurl -o /usr/local/bin/composer https://mirrors.aliyun.com/composer/composer.pharchmod +x /usr/local/bin/composercomposer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
登录后复制

安装 nginx 并整合 php-fpm 服务(centos stream 9)

# 下面这个echo是一句命令,得一起复制echo $'[nginx-stable]name=nginx stable repobaseurl=http://nginx.org/packages/centos/$releasever/$basearch/gpgcheck=1enabled=1gpgkey=https://nginx.org/keys/nginx_signing.keymodule_hotfixes=true ' > /etc/yum.repos.d/nginx.repo# 上面是一条echo命令。dnf makecachednf install -y nginxsystemctl enable nginxsystemctl enable php82-php-fpmsed -i 's/user\ =\ apache/user\ =\ nginx/g' /etc/opt/remi/php82/php-fpm.d/www.confsed -i 's/group\ =\ apache/group\ =\ nginx/g' /etc/opt/remi/php82/php-fpm.d/www.confsed -i 's/listen\ =\ \/var\/opt\/remi\/php82\/run\/php-fpm\/www.sock/listen=9000/g' /etc/opt/remi/php82/php-fpm.d/www.confrm -f /etc/nginx/conf.d/default.confvi /etc/nginx/conf.d/default.conf
登录后复制

/etc/nginx/conf.d/default.conf 文件内容如下

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;    }}
登录后复制

添加一个 php 文件如下:

vi /usr/share/nginx/html/1.php<?phpphpinfo();
登录后复制

启动 php-fpm 和 nginx 并验证安装正确

CentOS Stream release 9php 8.2.4nginx 1.22.1mysql 8.0.32redis 6.2.7git 2.39.10
登录后复制

安装mysql 8(centos stream 9)

CentOS Stream release 9php 8.2.4nginx 1.22.1mysql 8.0.32redis 6.2.7git 2.39.11
登录后复制

下面,整套设置新用户流程,先改初始,再加新用户并授权,再删除老用户。

CentOS Stream release 9php 8.2.4nginx 1.22.1mysql 8.0.32redis 6.2.7git 2.39.12
登录后复制

退出shell,重新进入。

现在就可以直接进入shell

CentOS Stream release 9php 8.2.4nginx 1.22.1mysql 8.0.32redis 6.2.7git 2.39.13
登录后复制

安装 redis 6 以及其他常用库(centos stream 9)

CentOS Stream release 9php 8.2.4nginx 1.22.1mysql 8.0.32redis 6.2.7git 2.39.14
登录后复制

总结(centos stream 9)

用了国内镜像会速度极快,下载包的速度:3MB/秒,惊人的快

另外感谢阿里云镜像库,非常快速和方便。【推荐学习:《PHP视频教程》】

以上就是快速安装php8.2套件(centos stream 9)的详细内容,更多请关注9543建站博客其它相关文章!

9543建站博客
一个专注于网站开发、微信开发的技术类纯净博客。
作者头像
admin创始人

肥猫,知名SEO博客站长,14年SEO经验。

上一篇:深入理解PHP7内核之zval
下一篇:数据库的备份还原管理:PHP编程中的技巧

发表评论

关闭广告
关闭广告