Content provider: Jinniu District Wudi Software Development Studio

First test go live:

  1. On the dev branch of the project
$ npm run build
Copy the code
  1. Install http-sever globally in the dev branch of the project
$ npm i http-server -g
Copy the code
  1. Start the HTTP sever
$http-server-c10 $http-server-c10 $http-server-c10Copy the code

If it doesn’t work, go to the project, find the index.js file in the config directory, and set host to 0.0.0.0

  1. NPM Run Build after modification (the third part can be modified directly when building the project)
  2. Dist directory
  3. Start the http-server-c10 server

Procedure for official launch:

One: Remotely create online branches

The first:

  1. Create a branch to go live remotely (you can also create a branch locally and push it to a remote repository)
  2. If the branch is created online remotely, create an identical branch locally, establish the association and push the online code to the remote online branch

The second:

  1. An easy way to do this is to create a live branch locally and push the project live code to a remote repository based on the dev branch
2. Purchase a server (if the server has been purchased and configured, skip this step)
  1. Optional purchase (Tencent Cloud, Ali Cloud, etc..)
  2. Configure the security group after the purchase is successful. (Choose More > Security Groups > Configure Security Groups.)

Set the inbound rule to 0.0.0.0 (that is, all IP addresses can access this server by default (Ali cloud server is not configured by default, Tencent cloud is configured by default).If it is ali Cloud server, it is more -> Configure security groups -> Configure Rules -> Quick Creation rules -> Configure the following content, the priority must not conflict with other configurations.3. Set password – – Restart the server Tencent cloud set password:Aliyun set password:4. In the first login mode, use a browser to log in to the cli of the serverEnter ls to view this will ask you to enter your password, which is the password you set in step 3.Note: there will be no display when you enter the password. If you enter the password correctly, you will login successfully. If you enter the password incorrectly, you will be returned. After a successful login, the following command line is displayedCD/View the root directory 5. The second method for logging in to the server (common) is to use the COMMAND line interface (CLI) in a random directory

$SSH server username @Public IP address of the serverCopy the code
  1. Enter the password to access the user directory of the server

7. Install nodejs and git in the user directory

$curl - sL https://rpm.nodesource.com/setup_10.x | sudo bash - / / install higher node $yum install nodejs $yum install gitCopy the code

If NPM does not work, the openSSL version is low and needs to be upgraded

$ yum update openssl -y
Copy the code
  1. Tests whether the server is accessible
$ cd/ Go to server root directory $cd$mkdir WWW create folder (create a WWW directory to store online items) $mkdirtestCreate online project storage folder (name yourself) $cd test$NPM install -g http-server $NPM install pm2 -g $NPM install -g CNPM $$// $http-server-c10 start server $// $pm2 start http-server $pm2 stop id $pm2 delete id $PS $http-server-c10 -p 8081 $pm2 start http-server -- -p 8081Copy the code

Http-server./ -p Port name Specifies the port

  1. Deployment project
$ cdData/WWW/Go to the WWW directory $gitclone-b Remote repository online branch name (remote repository SSH or HTTPS address) folder name (clone remote repository to online branch) $Enter the project folder CNPM I install the project depends on $NPM run build $cdDist/Go to dist directory $pm2 start http-server Start the serverCopy the code

CentOS nginx deployment

$ yum install nginx -y
Copy the code

Conf is the default nginx configuration file, and there is a directory called conf.d where we can put our own configuration.

If an error is reported:

$ nginx: [error] open() "/run/nginx.pid" failed (2: No such file or directory)
Copy the code

Let’s start with:

$nginx: the configuration file /etc/nginx/nginx.conf syntax is ok $nginx: configuration file /etc/nginx/nginx.conftest$nginx -c /etc/nginx/nginx.conf $nginx -s reloadCopy the code

If you go to your public IP address, you should see welcome to Nginx

Go to /etc/nginx/conf.d and create an arbitrary.conf file to write the server configuration

If the Hash Router is not used, the page will be unreachable after the refresh

Just add it to the server configuration

Vue – the router documentation: router.vuejs.org/zh/guide/es…

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

NPM run build cannot be fixed

$ sudo /bin/dd if1 bs=1M count=1024 $sudo /sbin/mkswap /var/swap.1 $sudo /sbin/swapon /var/swap.1 // Continue NPM run buildCopy the code