After running NPM run build, a dist folder is generated. Inde.html will not work if you open it locally.

steps

1. Download Nginx

Unzip Nginx

3. Configure Nginx

4, Start the Nginx server, throw the DIST file into the server, and run the access

The nginx configuration file is nginx.conf in the conf directory. The nginx.conf file is configured as follows

Then throw the packed dist folder into the HTML folder under Nginx, restart the nginx service, and type http://localhost:8096/ in the address bar

Later found, normal browsing is ok, but refresh the page, or in the browser to enter the routing address will appear 404 is attached to the solution at server {…… } insert the following code

location / {

root html\dist; # index index.html index.htm; try_files $uri $uri/ @router;Copy the code

}

location @router {

rewrite ^.*$ /index.html last;  
Copy the code

} Vue Nginx deployment

Nginx command:

Nginx -s stop kills the service directly

Start Nginx starts the service

Nginx -s quit gracefully stops nginx and waits for connection requests to complete before killing worker processes

Conf nginx -s reopen reopen log file, Nginx -v checking the version nginx -t checking the nginx configuration file nginx -h Checking the help information nginx -v detailed version information, including the compilation parameter nginx -c filename specifies the configuration fileCopy the code