1. 安装
- 下载地址http://nginx.org/en/download.html
- 一般选择 稳定版
stable版本
2.编辑 nginx\conf\nginx.conf
server {
listen 8080;//服务端口
server_name localhost;//域名
location / {
root C:\Users\Administrator\Desktop\study\ydc-vue\dist;//引用文件地址
index index.html index.htm; // 首页文件
}
location /apis {
proxy_pass http://www.***.com/; // 代理(注:代理网址最后的‘/’是否需要)
}
}
3.命令 (在nginx 文件夹根目录运行)
- 启动
start nginx(注:启动失败 ,查看日志 nginx\logs\error.log进行判断) - 停止
nginx -s stop - 重启
nginx -s reload - 查看版本
nginx -v