配置NGINX
Nginx环境配置与前端VUE部署
- 安装nginx:命令sudo yum update && sudo yum install nginx
- 部署:拷贝前端到目录/home/publish/idasweb/下
- 修改nginx配置:进入到/etc/nginx目录下,修改nginx.conf中user www-data为user root,不修改将导致nginx无权限访问部署的前端目录,并同时关闭访问日志,将access_log注释掉。同时进入到/etc/nginx/sites-enabled目录中,修改default的配置(文档中的其他内容都需要注释掉) server {
listen 80; #侦听的端口
listen [::]:80;#侦听的端口
server_name idasweb;#网站名称
root /home/publish/idasweb; #前端vue的部署目录
location / {
try_files $uri $uri/ @router;
index index.html index.htm;
}
location @router{
rewrite ^.*$ /index.html last;
}
} 完成后使用命令systemctl restart nginx重启nginx即可