one , Business description :
I'm working on an e-commerce project recently , There are platform side, business side and user side , So much Vue How to deploy the project to the server ?
two , deploy
(1) First, the local test project can be started and run normally .
(2) Enter in project npm run build
A file is generated
(3) Install on server Nginx, And will admin-web Upload to server .
My upload location :
(4) modify Nginx file , find nginx.conf
three , If there are more than one vue What about the project ?
Add a few more location that will do
four , Finally, remember to save
:wq
five , Restart Nginx
systemctl restart nginx
six :Nginx.conf Content of
server { listen 80; server_name localhost; #charset koi8-r; #access_log
logs/host.access.log main; location / { root html/dist/; index index.html
index.htm; try_files $uri $uri/ @router; index index.html; }
# Corresponding to the above @router, The main reason is that the routing path resource is not a real path , So we can't find the specific file location @router { #
# So we need rewrite reach index.html in , Then it is handed over to the router to process the request resource rewrite ^.*$ /index.html last; }
location /admin { alias /usr/local/nginx/admin/dist; index index.html
index.htm; try_files $uri $uri/ @router; index index.html; }
# Corresponding to the above @router, The main reason is that the routing path resource is not a real path , So we can't find a specific one location @router { #
# So we need rewrite reach index.html in , Then it is handed over to the router to process the request resource try_files $uri $uri/ @router; index
index.html; } # Corresponding to the above @router, The main reason is that the routing path resource is not a real path , So it's impossible to find the details > File for location
@router { # # So we need rewrite reach index.html in , Then it is handed over to the router to process the request resource rewrite ^.*$ /index.html
last; }
Technology
Daily Recommendation