Ali cloud installation configuration yarn, Nginx

1, and has the advantage of npm compared yarn

1 faster than npm. npm is a mounting package, yarn is installed in parallel.
2, npm there may be a case of the same package.json files are installed on different machines in different packages. Unexplained cause problems. But ah now npm also used the method of package-lock.json. Reduce confusion version.

Overall management of the yarn package version more stringent, less error-prone. npm can go wrong. If the production is, assisting people with yarn more suitable.

2, both locally and remotely installed yarn

Local install mac OS version of the Yarn
BREW install the Yarn

Install the Yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo APT the Add-Key -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo TEE / etc /apt/sources.list.d/yarn.list
// ubantu different versions, installation of command will be different, you can follow the prompts. I did not succeed with the above command, use the following command to install success
sudo apt-get update && sudo apt -get install yarn

If not fast enough, you can switch to Taobao source
$ config the SET the Yarn Registry https://register.npm.taobao.org

2, the overall package may further mounting npm npm.

1, the overall installation and pm2 vue-cli

Server.js Start by PM2
PM2 will automatically maintain the service process. We do not need to manually maintain the service
list $ pm2
view the service list
view more detailed information about
$ PM2 Show Server
// stop the service
$ PM2 STOP Server
// view real-time log
$ PM2 logs
// restart the service
$ pm2 restart

2, such as mac and solutions to connect remote Terminal Services after a lapse of a few minutes stuck
/ etc / ssh / ssh_config solve this problem by adding the following settings:

Retry connection is disconnected
ServerAliveCountMax 5
every 5 seconds automatically sends a request to keep the connection empty
ServerAliveInterval 5

3, installation and configuration Nginx

Ali stopped some default apache cloud service, because he occupies a 80-port, affect our service node.
$ sudo service apache2 stop

Or delete the Apache
$ Update-rc.d -f apache2 the Remove
APT-GET delete
$ sudo apt-get remove apache2
update-GET APT
$ sudo APT-GET Update

// install nginx
$ sudo APT-GET install nginx
// check the version number
$ nginx -v
// switch to the specified directory
cd /etc/nginx/conf.d
// create a configuration file
Touch demo.conf
// write configuration items
load balancing example: the following code to be introduced, upstream of which is a command, the load balancing Demo configuration name, to use ip_hash; followed by a plurality of network servers. ip_hash can guarantee that next time the user accessed the server also assigned to the specified intranet server. In this way the whole session the session will not be destroyed. You can set the upstream load balancing weights, the number of retries the request, the request fails to suspend time and so on.

upstream demo {
ip_hash;
server xx.xx.xx.xx:3007;
server 127.0.0.1:3006;
}

Here, we first do load balancing configuration:
The key is to configure the upstream server and the server server_name and location of proxy_pass. Which proxy_pass corresponding HTTP: // Demo ; and their own domain name prefix correspond. And the new website]

upstream demo {
    server 127.0.0.1:3010;
}
server {
    listen 80;
    server_name demo.upumind.com;
    location / {
        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_http_version 1.1;
                proxy_pass         http://demo;
    }
}

// esc: wq to save the configuration after the restart nginx
$ sudo Service nginx restart
// start the service with pm2 Demo
$ cd ~
$ pm2 Start service.js
enter the domain name in the browser, or ip: port to see whether the service started
// with ubantu from command with nginx start to see the situation
ps -ef | grep nginx

Guess you like

Origin www.cnblogs.com/wjw-blog/p/10965430.html