Domain name: Newnet server and domain name purchase (omitted)

Install various environments

1. In any cli tool, enter SSH root@public IP address of the server

2. Enter yes and the password for starting the server. Passwords are not displayed for security reasons

3, install git yum install git

4. Install the advanced version of Node. When it is ready, node and NPM will be available$ curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash - $ yum install nodejs5, generally in the data folder down data, through touch index. HTML can create a file, using the built-in vi/ VIm tool can be edited, cat command only view do not edit 6, install httpServernpm i http-server -g7,http-server8. Install pM2 to keep the Node process running in the backgroundnpm i pm2 -g pm2 start http-serverKeep the server runningpm2 list/lsView what services are running through pM2Pm2 delete Indicates the ID of the service to be disabledStop the service

Deploy the service through nginx

1. Install nginxyum install nginx -yThe nginx configuration file is in the /etc/nginx /conf.d/*.conf file

Basic configuration: go to /etc/nginx/conf.d and create a new one. Conf Write the server configuration to the /etc/nginx/conf

server { listen 8000; / root/port/var/WWW/yourfolder/build /; {try_files $uri $uri/ /index.html; } location /api/ { proxy_pass http://serverip:4444; }Copy the code

$nginx -c /etc/nginx/nginx.conf $nginx -s reload

2, resolve the domain name, access the previous IP address through the domain name:

Git clone NPM I install NPM run build NPM run build NPM run build

$ sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
$ sudo /sbin/mkswap /var/swap.1
$ sudo /sbin/swapon /var/swap.1
Copy the code

Location/API {proxy_pass: location/API {proxy_pass: location/API {proxy_pass: location/API; }} add a location to conf.d:

location / {
  try_files $uri $uri/ /index.html;
}
Copy the code

The final effect is as follows:

Nginx 403 forbidden Open nginx.conf and set the user name to the host name, usually root

$ vim nginx.conf
      user root
Copy the code