报错的问题
// # nginx: [alert] could not open error log file: CreateFile() “logs/error.log“ failed (5: Access is den
### **异常原因**
由于nginx的权限不够无法去创建文件如logs下的error.log文件
解决方法
给予nginx足够的权限
点击鼠标右键打开文件属性
点击安全,点击编辑
勾选上赋予的权限,然后点击应用,确定
再次进入CMD窗口输入nginx重新运行,不再报错
还有路径不要有中文名字
配置代码
# 部署前台项目
server {
listen 8085; # 端口号
server_name localhost; # 本地主机名
# 处理所有与后面不匹配的请求
location / {
root D:\work\workspace\wh221017\server\project\gshop-client; # 项目资源的根目录
index index.html index.htm; # 首页页面
try_files $uri $uri/ /index.html; # 所有404的请求返回index页面, 解决刷新404问题
}
# 处理所有/api开头的请求
# 转发到后台接口地址, 不要去掉/api
location /api {
proxy_pass http://gmall-h5-api.atguigu.cn;
}
}
# 部署后台项目
server {
listen 8086;
server_name localhost;
location / {
root D:\work\workspace\wh221017\server\project\gshop-admin;
index index.html index.htm;
}
# 所有/prod-api开头的请求都转发到后台接口地址, 去掉/prod-api
location /prod-api {
proxy_pass http://gmall-h5-api.atguigu.cn;
rewrite ^/prod-api/(.*) /$1 break; # 路径重写
}
}