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即可