1.下载对应当前系统版本的nginx包(package)
wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
2.建立nginx的yum仓库
rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm
3.安装nginx
yum install nginx
4.启动nginx服务并设置服务为自启动
systemctl start nginx
systemctl enable nginx
其他注意事项:
配置文件路径:/etc/nginx/
配置PHP(请先安装php):
server {
listen 80;
server_name greatgis.com www.greatgis.com;
access_log /www/access_greatgis.log main;
location / {
root /www/greatgis;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ /.ht {
deny all;
}
#添加如下配置
location ~ \.php$ {
root /www/greatgis;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#添加以上配置
}