PHP - Nginx
一、下载源码、依赖和编译工具
[root@localhost opt]# wget https://www.php.net/distributions/php-7.2.34.tar.gz
[root@localhost opt]# yum -y install gcc gcc-c++ make php-mcrypt libmcrypt libmcrypt-devel freetype gd libmcrypt libpng libpng-devel libjpeg libxml2 libxml2-devel zlib curl curl-devel re2c net-snmp-devel libjpeg-devel freetype-devel gmp-devel
二、解压、安装
[root@localhost opt]# tar -xvf php-7.2.34.tar.gz && cd php-7.2.34
检测是否缺少依赖包
[root@localhost php-7.2.34]# ./configure --prefix=/usr/local/php \
--with-mysql-sock=/usr/local/mysql.sock \
--with-mysqli \
--with-pdo-mysql \
--with-iconv-dir \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-curl \
--with-gd \
--with-gmp \
--with-zlib \
--with-xmlrpc \
--with-openssl \
--without-pear \
--with-snmp \
--with-gettext \
--with-libxml-dir=/usr \
--with-fpm-user=www \
--with-fpm-group=www \
--enable-xml \
--enable-fpm \
--enable-ftp \
--enable-bcmath \
--enable-soap \
--enable-shmop \
--enable-sysvsem \
--enable-sockets \
--enable-inline-optimization \
--enable-maintainer-zts \
--enable-mbregex \
--enable-mbstring \
--enable-pcntl \
--enable-zip \
--enable-fileinfo \
--enable-rpath \
--enable-libxml \
--enable-opcache \
--enable-mysqlnd
安装
[root@localhost php-7.2.34]# make && make install
三、配置php配置文件
[root@localhost etc]# cd /usr/local/php/etc/
[root@localhost etc]# cp /opt/php-7.2.34/php.ini-development ./php.ini.
[root@localhost etc]# cp php-fpm.conf.default php-fpm.conf
[root@localhost etc]# cd php-fpm.d/
[root@localhost php-fpm.d]# cp www.conf.default www.conf
对www.conf进行编辑
[root@localhost php-fpm.d]# vim www.conf
设置启动项
[root@localhost php-7.2.34]# cp /opt/php-7.2.34/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@localhost php-7.2.34]# chmod +x /etc/init.d/php-fpm
[root@localhost php-7.2.34]# chkconfig --add php-fpm
[root@localhost php-7.2.34]# systemctl daemon-reload
用systemctl进行管理
四、对nginx.conf配置文件进行修改
[root@localhost php-7.2.34]# vim /etc/nginx.conf
五、编写index.php测试页
[root@localhost php-fpm.d]# cd /usr/local/nginx/html/
[root@localhost html]# cat >>index.php<<-EOF
> <?php
> phpinfo();
> ?>
> EOF
启动nginx和php-fpm
[root@localhost html]# systemctl start nginx
[root@localhost html]# systemctl start php-fpm
在浏览器输入IP地址,看看能否获取到php版本信息