初始环境
[root@php7 ~]# cat /etc/redhat-releaseCentOS Linux release 7.4.1708 (Core) [root@php7 ~]# getenforceDisabled[root@php7 ~]# systemctl status firewalld.service● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) Active: inactive (dead) Docs: man:firewalld(1)[root@php7 ~]#
1.安装nginx
前面的博文已写编译安装nginx
2.安装php
下载地址:
http://cn2.php.net/distributions/php-7.1.1.tar.gz
提示:php7中已废弃了mysql_connect()系列的函数,可以删除此参数 --with-mysql=mysqlnd
# 解决依赖 yum install -y zlib-devel openssl-devel pcre-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libivonv-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel bzip2-devel readline-devel recode recode-devel libtidy libtidy-devel libmcrypt-devel mhash mcrypt./configure --prefix=/application/php-7.1.1 --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --enable-short-tags --enable-static --with-xsl --with-fpm-user=www --with-fpm-group=www --enable-ftp --enable-opcache=nomake #时间会有点长make install #所以我会把它包为rpm# 创建php软件链接ln -s /application/php-7.1.1/ /application/php# 配置php-fpm.confmkdir /application/php/etc/ -p\cp /server/tools/php-7.1.1/sapi/fpm/php-fpm.conf /application/php/etc/\cp /server/tools/php-7.1.1/sapi/fpm/php-fpm.conf /application/php/etc/\cp /application/php/etc/php-fpm.d/www.conf.default /application/php/etc/php-fpm.d/www.conf# 配置php.inimkdir /application/php/lib/ -p\cp /server/tools/php-7.1.1/php.ini-production /application/php/lib/php.inivim /application/nginx/conf/nginx.conf# 在server模块中加入 index.php location / { root html; index index.php index.html index.htm; }# 在server模块中添加 location ~* .*\.(php|php5)?$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; }# 检查nginx配置状态/application/nginx/sbin/nginx -t# 重启nginx /application/nginx/sbin/nginx -s reload# 启动php-ftp程序/application/php/sbin/php-fpm# 输入phpinfoecho -e ' ' > /application/nginx/html/index.php
3.结果图
此处没写连接mysql.读者可以到这里查看