php7.4.5 编译安装

PHP 7.4.5 编译安装

编译安装

  1. 下载 php 源码文件

    1. wget https://www.php.net/distributions/php-7.4.5.tar.gz
    2. tar -zxvf php-7.4.5.tar.gz
    3. cd php-7.4.5
  2. 编译并安装php

    1. ./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
    2. make
    3. make install
  3. 修改 php.ini 文件

    1. * cp php.ini-development /usr/local/php74/lib/php.ini
    2. * vim /usr/local/php/lib/php.ini
    3. * mysqli.default_socket = /var/lib/mysql/mysql.sock
    4. * date.timezone = PRC
    5. * 检测安装是否成功
    6. * /usr/local/php74/bin/php -v
  4. 将php路径添加到系统变量之中
    1. ln -s /usr/local/php74 /usr/local/php
    2. ln -s /usr/local/php/bin/php /usr/sbin/php
    3. ln -s /usr/local/php/bin/phpize /usr/sbin/phpize
  5. 设置php-fpm配置
    1. cp /usr/local/php74/etc/php-fpm.conf.default /usr/local/php74/etc/php-fpm.conf
    2. cp /usr/local/php74/etc/php-fpm.d/www.conf.default /usr/local/php74/etc/php-fpm.d/www.conf
  6. 设置 systemd 配置文件
    1. cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/php-fpm74.service
    2. ln -s /usr/lib/systemd/system/php-fpm74.service /usr/lib/systemd/system/php-fpm.service
    3. systemctl daemon-reload
    4. systemctl enable php-fpm

php7.4 遇到的问题

  1. 缺少 sqlite 包依赖
    1. yum -y install sqlite-devel
  2. 缺少 oniguruma 包依赖
    1. yum install https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/o/oniguruma-5.9.5-3.el7.x86_64.rpm
    2. yum install https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/o/oniguruma-devel-5.9.5-3.el7.x86_64.rpm
  3. 启动 php-fpm 报错 Read-only file system
    systemctl start php-fpm 启动时报错,通过 systemctl status php-fpm 查看,发现以下报错信息:
    1. ERROR: failed to open error_log (/usr/local/php74/var/log/php-fpm.log): Read-only file system
    解决办法:需要修改 system 中 php-fpm.service 文件中的参数
    • vim /usr/lib/systemd/system/php-fpm.service
    • ProtectSystem=false


评论 0

发表评论

Top