Uploading a static File
Sudo chmod 777 pages /var/ WWW /pages sudo chmod 777 pages /var/ WWW /pages sudo chmod 777 pages Execute NPM run build as a static file, switch to the root directory of the project, and execute sudo SCP -r./dist/* [email protected]: / var/WWW/pages of all files uploaded to the server in the dist/var/WWW/pages directory.
kim@VM-0-12-ubuntu:/var/www/pages$ ll total 16 drwxrwxrwx 3 root root 4096 Feb 3 08:52 ./ drwxr-xr-x 5 root root 4096 Feb 3 08:47 .. / -rw-r--r-- 1 kim kim 512 Feb 3 08:52 index.html drwxr-xr-x 6 kim kim 4096 Feb 3 08:52 static/ kim@VM-0-12-ubuntu:/var/www/pages$Copy the code
Configure nginx
Sudo vi /etc/nginx/sites-available/default to replace the original node example project. The current nginx configuration is
location /catalog{
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Nginx-Proxy true;
proxy_set_header Connection "";
proxy_set_header Cookie $http_cookie;
proxy_pass http://127.0.0.1:3000;
}
location / {
root /var/www/;
index index.html;
}
Copy the code
Refresh the browser
subsequent
We have implemented a static page deployment and a Node project deployment, although it is a simple initial implementation, but it is suitable for beginners to practice. More optimizations and improvements will continue to be explored.
- History VUE project deployment for routing pattern
- Domain connection
- HTTPS access
reference
Pm2 tutorial How To Set Up a Node.js Application for Production on Ubuntu 16.04