目录
一、 安装PHP-FPM
1. 安装依赖软件包
[root@Web ~]# yum -y install gcc gcc-c++ libxml2 libxml2-devel autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel yum -y install sqlite-devel yum -y install oniguruma yum -y install https://rpms.remirepo.net/enterprise/7/remi/x86_64/oniguruma5php-6.9.8-1.el7.remi.x86_64.rpm yum -y install https://rpms.remirepo.net/enterprise/7/remi/x86_64/oniguruma5php-6.9.8-1.el7.remi.x86_64.rpm
2. 下载安装包
(1)下载
https://www.php.net/distributions/php-7.4.20.tar.bz2
(2)解压php压缩包
[root@Web~]# tar jxvf php-7.2.4.tar.bz2
3. 进入目录
[root@Web~]# cd php-7.2.4/
4. 配置
[root@localhost~]#./configure --prefix=/usr/local/php-fpm --enable-fpm --with-zlib --with-pdo-mysql --enable-mbstring --with-gd --with-png-dir=/usr/lib64 --with-jpeg-dir=/usr/lib64 --with-freetype-dir=/usr/lib64 --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock 或 [root@localhost~]#./configure --prefix=/usr/local/php-fpm --enable-fpm --with-zlib --with-pdo-mysql --enable-mbstring --with-gd --with-png-dir=/usr/lib64 --with-jpeg-dir=/usr/lib64 --with-freetype-dir=/usr/lib64 --with-mysqli=/usr/local/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock
5. 编译&安装
Make & &make install
注:make &make install会报错:
libtool: link: `ext/opcache/ZendAccelerator.lo' is not a valid libtool object
原因是make和make install同时运行;
执行make clean即可解决,重新执行make &&make install即可
6. 增加用户和组:
useradd -s /sbin/nologin web
7. 配置php-pfm
[root@Webphp-7.2.4]# cd /usr/local/php-fpm/etc/ [root@Webetc]# cp php-fpm.conf.default php-fpm.conf [root@Webetc]# vim php-fpm.conf
去掉注释:pid = run/php-fpm.pid [root@Webetc]# cd php-fpm.d/ [root@Webphp-fpm.d]# cp www.conf.default www.conf
注释:#[www],改为[web]
修改:user = web group = web
listen = 127.0.0.1:9000
8. Php.ini
[root@Webetc]# cp php.ini-development /usr/local/php-fpm/etc/php.ini
9. 启动
/usr/local/php-fpm/sbin/php-fpm
10. 测试
[root@localhost ~]# cd /usr/local/nginx/html [root@localhost ~]# rm -rf index.html [root@localhost ~]# vim index.php
添加
<?php phpinfo(); ?>
注:Php注释使用分号“;”,而不是#
11、访问站点
http://192.168.20.253
文章评论