安装依赖包:
# yum install gcc gcc-c++ openssl-devel pcre-devel zlib-devel
上传源码包到root下:
nginx-1.12.2.tar.gz
解压并进入nginx:
# tar zxf nginx-1.12.2.tar.gz
# cd nginx-1.12.2
编译并安装:
# ./configure && make && make install
启动nginx:
# /usr/local/nginx/sbin/nginx
查看80端口是否启动成功:
# netstat -lptnu | grep 80
启动成功查看网页是否显示nginx:
编辑nginx配置文件
vi /usr/local/nginx/conf/nginx.conf
修改45行:添加index.php
location / {
root html;
index index.php index.html index.htm;
}
修改65-71行:
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
安装php文件
# yum install php php-fpm php-mysql
添加php文件
# vim /usr/local/nginx/html/index.php
<?php
phpinfo()
?>
启动php
# systemctl start php-fpm
查看是否成功: