php7.4.5 编译安装
- php
- 2020-05-04
- 3038
- 0
PHP 7.4.5 编译安装
编译安装
下载 php 源码文件
wget https://www.php.net/distributions/php-7.4.5.tar.gz
tar -zxvf php-7.4.5.tar.gz
cd php-7.4.5
编译并安装php
./configure --prefix=/usr/local/php74 --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mysqli --with-pdo-mysql --with-zlib --with-curl --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-openssl --enable-mbstring --enable-ftp --enable-zip
make
make install
修改 php.ini 文件
* cp php.ini-development /usr/local/php74/lib/php.ini
* vim /usr/local/php/lib/php.ini
* mysqli.default_socket = /var/lib/mysql/mysql.sock
* date.timezone = PRC
* 检测安装是否成功
* /usr/local/php74/bin/php -v
- 将php路径添加到系统变量之中
ln -s /usr/local/php74 /usr/local/php
ln -s /usr/local/php/bin/php /usr/sbin/php
ln -s /usr/local/php/bin/phpize /usr/sbin/phpize
- 设置php-fpm配置
cp /usr/local/php74/etc/php-fpm.conf.default /usr/local/php74/etc/php-fpm.conf
cp /usr/local/php74/etc/php-fpm.d/www.conf.default /usr/local/php74/etc/php-fpm.d/www.conf
- 设置 systemd 配置文件
cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/php-fpm74.service
ln -s /usr/lib/systemd/system/php-fpm74.service /usr/lib/systemd/system/php-fpm.service
systemctl daemon-reload
systemctl enable php-fpm
php7.4 遇到的问题
- 缺少 sqlite 包依赖
yum -y install sqlite-devel
- 缺少 oniguruma 包依赖
yum install https://rpms.remirepo.net/enterprise/7/remi/x86_64/oniguruma5php-6.9.6-1.el7.remi.x86_64.rpm
yum install https://rpms.remirepo.net/enterprise/7/remi/x86_64/oniguruma5php-devel-6.9.6-1.el7.remi.x86_64.rpm
- 启动 php-fpm 报错 Read-only file system
systemctl start php-fpm 启动时报错,通过 systemctl status php-fpm 查看,发现以下报错信息:
解决办法:需要修改 system 中 php-fpm.service 文件中的参数ERROR: failed to open error_log (/usr/local/php74/var/log/php-fpm.log): Read-only file system
- vim /usr/lib/systemd/system/php-fpm.service
- ProtectSystem=false