一、项目打包后,build中的index.html打开是空白页
解决办法:
在package.json中加入"homepage": “./”。
二、nginx正常配置,但没办法访问,可能是防火墙的问题
解决办法:
- 对端口进行防火墙配置
firewall-cmd --zone=public --add-port=端口号/tcp --permanent
- 重启防火墙服务
systemctl restart firewalld.service
三、Nginx报错:nginx: [error] invalid PID number “” in “/run/nginx.pid”
服务器重启之后,检查 nginx -t 发现配置是正常的,但是执行nginx -s reload 就会报错。
解决办法:
nginx -c /etc/nginx/nginx.conf
后面是ngin.conf的路径可以从nginx -t中查看
四、一个端口加入多个location出现404
解决办法:
root只能由一个,其他location内用alias
比如:
server {
listen 80;
server_name localhost;
location / {
root /home/react/music;
index index.html;
};
location /snake {
alias /home/react/snake;
index index.html;
}
location /plane {
alias /home/react/plane;
index index.html;
}
}