系统相关
首页 > 系统相关> > centos7编译安装php7.4.22

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 解析器生成器

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

标签:22,etc,--,apps,php7.4,php74,centos7,fpm,php
来源: https://www.cnblogs.com/windman0/p/15489291.html