CentOS8 install PHP7.3+Swoole4.4+MySql8.0+Redis5.0+Nginx
本文由 简悦 SimpRead 转码, 原文地址 http://doc.seagm.io/web/#/p/9271ba8a1ac976a05fd53c76b0855adc
yum update
先安装一下 git 和 nginx
yum install git nginx -y
安装 php: step 1
yum install epel-release
安装信息
===============================================================================================================================================
Package Architecture Version Repository Size
===============================================================================================================================================
Installing:
epel-release noarch 8-8.el8 extras 23 k
===============================================================================================================================================
安装 php: step 2
yum install http://rpms.remirepo.net/enterprise/remi-release-8.rpm
安装 php: step 3
yum install -y php73-php-fpm php73-php-cli php73-php-bcmath php73-php-gd php73-php-json php73-php-mbstring php73-php-mcrypt php73-php-mysqlnd php73-php-opcache php73-php-pdo php73-php-pecl-crypto php73-php-pecl-mcrypt php73-php-pecl-geoip php73-php-recode php73-php-snmp php73-php-soap
yum install -y php73-php-xml
查看安装的 PHP 版本
php73 -v
关于 php-fpm 的启停:
不是本次安装使用的重点,本次主要是使用 swoole 作服务器,不需要使用 php-fpm
systemctl restart php73-php-fpm #重启
systemctl start php73-php-fpm #启动
systemctl stop php73-php-fpm #关闭
systemctl status php73-php-fpm #检查状态
安装 pecl,然后通过 pecl 来安装 swoole
wget http://pear.php.net/go-pear.phar
php73 go-pear.phar
yum install php73-php-pear
由于环境变量的原因,直接输入 pecl 命令找不到,这里直接输入完整路径
sudo /opt/remi/php73/root/usr/bin/pecl install swoole
下载太慢,等了很久最终下载失败,手动到网站上下载然后上传到服务器
https://pecl.php.net/package/swoole
本地上传服务器
wenqidongdeMBP:Downloads wenqidong$ scp -r swoole-4.4.17.tgz root@47.104.79.117:/tmp
root@47.104.79.117's password:
swoole-4.4.17.tgz 100% 1425KB 2.8MB/s 00:00
wenqidongdeMBP:Downloads wenqidong$
在服务器上指定安装文件安装,提示需要安装 php73-php-devel,于是安装
yum install php73-php-devel
但是遇到问题:
Problem: cannot install the best candidate for the job
- nothing provides libedit-devel(x86-64) needed by php-devel-7.3.10-1.el8.remi.x86_64
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
解决方式:
dnf config-manager --set-enabled PowerTools
然后再安装 php73-php-devel,安装完后,再安装 swoole
sudo /opt/remi/php73/root/usr/bin/pecl install ./swoole-4.4.17.tgz
安装完后,提示将 swoole.so 配置到 php.ini 中
Build process completed successfully
Installing '/opt/remi/php73/root/usr/lib64/php/modules/swoole.so'
Installing '/opt/remi/php73/root/usr/include/php/ext/swoole/config.h'
install ok: channel://pecl.php.net/swoole-4.4.17
configuration option "php_ini" is not set to php.ini location
You should add "extension=swoole.so" to php.ini
注意:不能放到最前面,至少需要放到加载 mysql 之后。
通过 php73 --ini
可以查看 php 使用到的配置文件
[root@iZm5eccrtb2rzofq0fcwcaZ tmp]# php73 --ini
Configuration File (php.ini) Path: /etc/opt/remi/php73
Loaded Configuration File: /etc/opt/remi/php73/php.ini
Scan for additional .ini files in: /etc/opt/remi/php73/php.d
Additional .ini files parsed: /etc/opt/remi/php73/php.d/10-opcache.ini,
/etc/opt/remi/php73/php.d/20-bcmath.ini,
/etc/opt/remi/php73/php.d/20-bz2.ini,
/etc/opt/remi/php73/php.d/20-calendar.ini,
/etc/opt/remi/php73/php.d/20-ctype.ini,
/etc/opt/remi/php73/php.d/20-curl.ini,
/etc/opt/remi/php73/php.d/20-dom.ini,
/etc/opt/remi/php73/php.d/20-exif.ini,
/etc/opt/remi/php73/php.d/20-fileinfo.ini,
/etc/opt/remi/php73/php.d/20-ftp.ini,
/etc/opt/remi/php73/php.d/20-gd.ini,
/etc/opt/remi/php73/php.d/20-gettext.ini,
/etc/opt/remi/php73/php.d/20-iconv.ini,
/etc/opt/remi/php73/php.d/20-json.ini,
/etc/opt/remi/php73/php.d/20-mbstring.ini,
/etc/opt/remi/php73/php.d/20-mysqlnd.ini,
/etc/opt/remi/php73/php.d/20-pdo.ini,
/etc/opt/remi/php73/php.d/20-phar.ini,
/etc/opt/remi/php73/php.d/20-posix.ini,
/etc/opt/remi/php73/php.d/20-recode.ini,
/etc/opt/remi/php73/php.d/20-shmop.ini,
/etc/opt/remi/php73/php.d/20-simplexml.ini,
/etc/opt/remi/php73/php.d/20-snmp.ini,
/etc/opt/remi/php73/php.d/20-soap.ini,
/etc/opt/remi/php73/php.d/20-sockets.ini,
/etc/opt/remi/php73/php.d/20-sqlite3.ini,
/etc/opt/remi/php73/php.d/20-sysvmsg.ini,
/etc/opt/remi/php73/php.d/20-sysvsem.ini,
/etc/opt/remi/php73/php.d/20-sysvshm.ini,
/etc/opt/remi/php73/php.d/20-tokenizer.ini,
/etc/opt/remi/php73/php.d/20-xml.ini,
/etc/opt/remi/php73/php.d/20-xmlwriter.ini,
/etc/opt/remi/php73/php.d/20-xsl.ini,
/etc/opt/remi/php73/php.d/30-mcrypt.ini,
/etc/opt/remi/php73/php.d/30-mysqli.ini,
/etc/opt/remi/php73/php.d/30-pdo_mysql.ini,
/etc/opt/remi/php73/php.d/30-pdo_sqlite.ini,
/etc/opt/remi/php73/php.d/30-wddx.ini,
/etc/opt/remi/php73/php.d/30-xmlreader.ini,
/etc/opt/remi/php73/php.d/40-crypto.ini,
/etc/opt/remi/php73/php.d/40-geoip.ini
注意配置文件名前的编号,php 是按这个顺序加载的。
进到配置文件目录,复制一个配置文件,编号为 50-swoole.ini
[root@iZm5eccrtb2rzofq0fcwcaZ tmp]# cd /etc/opt/remi/php73/php.d/
[root@iZm5eccrtb2rzofq0fcwcaZ php.d]# cp 40-geoip.ini 50-swoole.ini
[root@iZm5eccrtb2rzofq0fcwcaZ php.d]# vi 50-swoole.ini
50-swoole.ini 的内容
extension=swoole.so
现在可以通过 php73 -m
查看到 swoole 扩展已安装完成.
安装 MySQL: 参照 MySQL 官网文档
mysql8 通过 ssh 连接
User
Password: Root@123
Redis 配置
127.0.0.1:6379
连接密码:redis
远程连接方式:ssh
在 centos8 上安装 composer,参照阿里云文档
https://yq.aliyun.com/articles/753676?type=2