#CENTOS8 网络配置
net默认dhcp自动分配ip – 建议使用,避免占用局域网ip
onboot=yes
#php7.4安装
#下载目录
cd /usr/local
#下载php7.4源码
wget https://www.php.net/distributions/php-7.4.2.tar.bz2
#解压 进入
tar --bzip -xvf /usr/local/php-7.4.2.tar.bz2
cd php-7.4.2
#安装编译工具gcc gcc++ 和php依赖库
yum -y install gcc gcc-c++
yum -y install libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel libicu-devel freetype-devel openldap-devel openldap openldap-devel
#用户和用户组
groupadd www
useradd -g www www
#开始编译
./configure --prefix=/usr/local/php
–enable-fpm
–with-fpm-user=www
–with-fpm-group=www
–enable-mysqlnd
–with-mysqli=mysqlnd
–with-pdo-mysql=mysqlnd
–enable-mysqlnd-compression-support
–with-iconv-dir
–with-freetype-dir
–with-jpeg-dir
–with-png-dir
–with-zlib
–with-libxml-dir
–enable-xml
–disable-rpath
–enable-bcmath
–enable-shmop
–enable-sysvsem
–enable-inline-optimization
–with-curl
–enable-mbregex
–enable-mbstring
–enable-intl
–with-mcrypt
–with-libmbfl
–enable-ftp
–with-gd
–enable-gd-jis-conv
–enable-gd-native-ttf
–with-openssl
–with-mhash
–enable-pcntl
–enable-sockets
–with-xmlrpc
–enable-zip
–enable-soap
–with-gettext
–disable-fileinfo
–enable-opcache
–with-pear
–enable-maintainer-zts
–with-ldap=shared
–without-gdbm
#错误1 – 缺sqlite3
yum install sqlite-devel
#错误2 – 没有/user/lib文件
cp -frp /usr/lib64/libldap* /usr/lib/
#错误3 – oniguruma 包未找到
这个错误信息是由于mbstring的正则功能需要oniguruma的支持,编译PHP的时候使用了“–enable-mbstring”参数,系统中却没有oniguruma库。
yum install oniguruma
再次编译 还是失败
源码安装oniguruma
git clone https://github.com/kkos/oniguruma
./configure --prefix=/usr --libdir=/lib64
make
make install
#再次编译 安装–ok
#安装完成配置php
##查看版本
/usr/local/php/bin/php -v
##添加环境变量
cd /etc/profile.d
vim php.sh
export PHP_HOME=/usr/local/php
export PATH=.:
P
H
P
H
O
M
E
/
b
i
n
:
PHP_HOME/bin:
PHPHOME/bin:PATH
:wq
source /etc/profile
#验证
php -m
#php-fpm配置
cd /usr/local/php-7.4.2
#php.ini
cp php.ini-production /etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
#设置使用快捷启动
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
#启动php
service php-fpm start
#安装SWOOLE —建议安装swoole4.5.2
下载地址
https://github.com/swoole/swoole-src/releases
http://pecl.php.net/package/swoole
http://git.oschina.net/swoole/swoole
#解压进入
。。。。
cd swoole
phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
#查看php.ini 位置
php --ini
#编辑php.ini
extension=swoole.so
#启动php-fpm
service php-fpm retart
#php -m 查看
参看文档:
https://www.cnblogs.com/alliancehacker/p/12255445.html
https://www.cnblogs.com/liubaoqing/p/12176017.html
https://www.cnblogs.com/huliangqing/p/12611487.html