1.nginx的安装包下载
http://nginx.org/en/download.html
2.下载安安装包后解压,解压下如下
![](https://img.haomeiwen.com/i59232/2aa7cb5ca12bb5f3.png)
2.启动nginx服务
start nginx
3.如何查看nginx服务是否启动成功
![](https://img.haomeiwen.com/i59232/0c882a1ce50f2583.png)
如果找不到上图中的2个进程,很显然服务未启动成功,常见的错误是端口被占用了
4.找到conf文件下的nginx.conf,修改配置文件后,配置文件默认端口是80,去修改被占用的端口,重新加载配置文件
![](https://img.haomeiwen.com/i59232/da30929fc2274f30.png)
重新使用 start nginx 启动下
如果nginx服务已经启动了,修改了配置文件,需要重新加载下配置
nginx -s reload
5.如何关闭nginx服务
进入任务管理,点击详细信息,找到nginx.exe,有2个,直接单击右键结束进程
![](https://img.haomeiwen.com/i59232/0c65d87cbd6d0a0e.png)
upstream weige.cn{
server 127.0.0.1:8081 weight=9;
server 127.0.0.1:8082 weight=1;
}
server {
listen 8001;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html/dist;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
location /dev-api/ {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#需要代理访问的后端服务器地址
proxy_pass http://weige.cn/;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# 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 /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
网友评论