Centos 6.8安装 Nginx+PHP

1,下载最新版Nginx

进入Nginx官网看一下最新版是哪个版本 http://nginx.org/en/download.html
我看到的最新版是:nginx-1.11.12
开始下载:
wget -c https://nginx.org/download/nginx-1.11.12.tar.gz

gcc 安装:yum install gcc-c++

PCRE pcre-devel 安装:yum install -y pcre pcre-devel

zlib 安装: yum install -y zlib zlib-devel

OpenSSL 安装:yum install -y openssl openssl-devel

2,解压文件

tar -zxvf nginx-1.11.12.tar.gz 

3.开始编译

./configure --prefix=$(pwd)
(如果要以后准备做https,配置:./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre)

make

4.开始安装

make install

5.开启nginx服务

nginx/sbin/nginx

6.测试是否安装成功

访问外网Ip,会有nginx的欢迎页面

7.安装PHP,Mysql,phpmyadmin

yum install mysql
yum install mydql-server
yum install phpmyadmin

安装php7
wget http://cn2.php.net/distributions/php-7.1.3.tar.gz
./configure --prefix='/usr/local/php7.1.3/' --enable-fpm
make
make install

8.配置Nginx支持PHP

vim .../etc/nginx/conf/nginx.conf.default.conf 修改:

location / {

root /usr/share/nginx/html;

index index.html index.htm index.php;#默认页面添加 index.php

}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

location ~ .php$ {

root html;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;

include fastcgi_params;

}

9.配置php-fpm

cd $(find / -name php-fpm* -type d)
vim www.conf.default
user = nginx

10.设置自启动

vim /etc/rc.local
添加 /usr/local/php7.1.3/sbin/php-frm

猜你喜欢

转载自blog.csdn.net/getcomputerstyle/article/details/68059797