CentOS 7.2 yum安装Nginx
- 2018-10-16
- 172 人已阅读
1.添加Nginx到YUM源
添加CentOS 7 Nginx yum资源库,打开终端,使用以下命令:
sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
2.安装Nginx
sudo yum install -y nginx
3.启动Nginx
sudo systemctl start nginx.service
4、CentOS 7 开机启动Nginx
sudo systemctl enable nginx.service
5、配置Nginx使其支持php
vi /etc/nginx/conf.d/default.conf
1、修改默认的 location 块,使其支持 .php 文件:
location / {
root /usr/share/nginx/html;
try_files $uri $uri/ /index.php?$query_string;
index index.php index.html index.htm;
}
2、下一步配置来保证对于 .php 文件的请求将被传送到后端的 PHP-FPM 模块, 取消默认的 PHP 配置块的注释,并修改为下面的内容:
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
Nginx配置信息
网站文件存放默认目录:/usr/share/nginx/html
网站默认站点配置:/etc/nginx/conf.d/default.conf
自定义Nginx站点配置文件存放目录:/etc/nginx/conf.d/
上一篇:Delphi7中DateTimePicker控件,显示格式
下一篇:没有了