nginx使用

1、nginx压缩包解压

2、启动:

  方法1:打开目录中的nginx.exe即可启动nginx服务。

  方法2:cmd中  cd D: ginx  进入目录,然后 start nginx。

3、配置站点:

  配置文件:conf/nginx.conf

  添加站点:在server {}同级别添加新的server {},格式如下:

server {
        listen       10005;
        server_name  localhost;
        # 目录配置
        location / {
            root   D:/beginner/5.GW-monitor/web;
            index  index.html index.htm;
# try_files $uri $uri/ /index.html; # 显示目录文件 autoindex on; } # 添加反向代理 location /gfyun-omls-web/ { index proxy_set_header Host $host; index proxy_set_header X-Real-IP $remote_addr; index proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://192.168.1.100:8080/gfyun-omls-web/; # proxy_cookie_path /gfyun-omls-web /gfy/api; } }

4、重启服务:

  cmd中在nginx目录 nginx -s reload 【修改配置文件后需要重启】

5、退出nginx服务:  

  nginx -s stop  stop表示立即停止nginx,不保存相关信息
  nginx -s quit  quit表示正常退出nginx,并保存相关信息

  

  
原文地址:https://www.cnblogs.com/lstrive/p/10855916.html