centos7编译安装php7.4.22

2021/11/1 7:14:32

本文主要是介绍centos7编译安装php7.4.22,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

------------恢复内容开始------------

yum -y install gcc libxml2-devel bzip2-devel libmcrypt-devel sqlite-devel oniguruma-devel bison
tar xjvf php-7.4.22.tar.bz2
./configure --prefix=/apps/php74 --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-zlib --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-mbstring --enable-xml --enable-sockets --enable-fpm --enable-maintainer-zts --disable-fileinfo
make && make install
echo 'PATH=/apps/php74/bin:$PATH' > /etc/profile.d/php74.sh
source /etc/profile.d/php74.sh

[root@17 ~]# php -v
PHP 7.4.22 (cli) (built: Oct 31 2021 20:41:00) ( ZTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies


cp php.ini-production /etc/php.ini                        源码目录中拷贝php配置文件
cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/      源码目录中拷贝service文件
cp /apps/php74/etc/php-fpm.conf.default /apps/php74/etc/php-fpm.conf        安装目录中拷贝fpm配置文件
cp /apps/php74/etc/php-fpm.d/www.conf.default /apps/php74/etc/php-fpm.d/www.conf    安装目录中拷贝fpm配置文件,需要修改启动用户为httpd相同用户,打开状态页和测试页面。

vim /apps/httpd24/conf/httpd.conf
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so        #取消代理模块注释

<IfModule dir_module>
DirectoryIndex index.php index.html                          #修改默认页面为index.php
</IfModule>

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
ProxyRequests Off

ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/data/html/$1      
ProxyPassMatch ^/(fpm-status|ping)$ fcgi://127.0.0.1:9000/$1

vim /data/html/info.php
<?php
phpinfo();
?>

chown apache.apache -R /data/html

访问测试
[root@17 ~]# curl http://10.0.0.17/ping
pong
[root@17 ~]# curl http://10.0.0.17/fpm-status
pool:                 www
process manager:      dynamic
start time:           31/Oct/2021:21:08:33 +0800
start since:          1823
accepted conn:        16
listen queue:         0
max listen queue:     0
listen queue len:     128
idle processes:       1
active processes:     1
total processes:      2
max active processes: 1
max children reached: 0
slow requests:        0

记录
1、httpd安装参考其他脚本
2、./configure生成编译参数是报错
configure: error: bison 3.0.0 is required to generate PHP parsers (excluded versions: none).
需要安装 bison 解析器生成器

------------恢复内容结束------------



这篇关于centos7编译安装php7.4.22的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程