运行环境
centos7.9
安装
下载Nginx
yum install nginx
Nginx的默认安装目录:
cd /etc/nginx
编辑Nginx配置文件
vi /etc/nginx/nginx.conf
```shell
启动ng
```shell
//启动ng
service nginx start
其他命令参数
systemctl daemon-reload #生效配置文件重载
systemctl enable nginx.service #设置开机启动
systemctl list-unit-files |grep nginx #查看nginx应用开机状态
systemctl start nginx.service #查看nginx应用启动状态
systemctl status nginx.service
基本配置
以代理到php为例
server {
listen 80;
server_name 127.0.0.1;
root /var/www/html;
index index.php index.html;
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
location ~ \.php$ {
root /var/www/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
评论区