Nginx_Windos本地部署

1. 安装跟配置

安装:

下载地址:nginx: download

 

 下载完成后,在指定位置解压缩,不要直接双击nginx.exe。

 

 

配置:

server {
listen 10700; #输入端口号
server_name localhost;

location / {
            root   D:/nginx-1.16.1/html; #输入包的地址
            
        # 用于配合 browserHistory使用
            try_files $uri $uri/ /index.html;
            
            index  index.html index.htm;
        }
}

 


2. 启动nginx :

启动nginx服务,启动命令为:start nginx,启动时会一闪而过是正常的

修改配置执行下面命名:修改完成后保存,使用以下命令检查一下配置文件是否正确,后面是nginx.conf文件的路径,successful就说明正确了

d:
cd D:\nginx-1.16.1
nginx -t -c /nginx-1.16.1/conf/nginx.conf

 

3. 出现下面标识启动成功:
nginx: the configuration file D:/nginx-1.16.1/conf/nginx.conf syntax is ok
nginx: configuration file D:/nginx-1.16.1/conf/nginx.conf test is successful

 

4. 刷新配置:nginx -s reload

 

5. 出现错误:nginx: [error] invalid PID number "" in "D:\nginx-1.16.1/logs/nginx.pid"
原因:D:\nginx-1.16.1\logs文件夹下面缺少文件nginx.pid
解决:添加文件并且文件内部添加数字:395180


6. 出现错误:原因:那是系统在你修改配置文件的时候,将你的nginx关闭了
nginx: [error] OpenEvent("Global\ngx_reload_2144") failed (2: The system cannot find the file specified)
解决:start nginx

 

 

 

7. 关闭nginx服务使用以下命令,同样也是一闪而过是正常的,看一下是否进程已消失即可

快速停止:nginx -s stop

完整有序的关闭:nginx -s quit

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章