centos7.5安装php7.4

1 下载php7.4的源文件

wget https://www.php.net/distributions/php-7.4.0.tar.gz
tar -xzvf php-7.4.0.tar.gz
cd ./php-7.4.0

2 编译安装

./configure --prefix=/app/php74 --with-config-file-path=/app/php74/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-zlib --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local/curl --enable-mbregex --enable-mbstring --enable-intl --enable-ftp --with-openssl=/usr/local/openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --with-gettext --enable-fileinfo --enable-opcache --with-sodium
make
make install

3 修改配置文件

cp php.ini-production  /app/php74/etc
cp /app/php74/etc/php-fpm.conf.default  /app/php74/etc/php-fpm.conf
cp /app/php74/etc/php-fpm.d/www.conf.default   /app/php74/etc/php-fpm.d/www.conf

4 配置启动命令

touch /usr/lib/systemd/system/php74-fpm.service

php74-fpm.service 文件内容

[Unit]
Description=php74-fpm
After=syslog.target network.target

[Service]
Type=forking
PIDFile=/app/php74/var/run/php-fpm.pid
ExecStart=/app/php74/sbin/php-fpm
ExecStop=/bin/kill -s QUIT $MAINPID
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target
systemctl enable php74-fpm.service

5 启动php-fpm

systemctl start php74-fpm

常见错误:

1 缺少依赖扩展包,例如

configure: error: Package requirements (icu-uc >= 50.1 icu-io icu-i18n) were not met:

方法

yum search icu   //  搜索相关的包
yum install icu libicu libicu-devel  //  将相关的扩展全部安装

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注