1. Background

After working for such a long time, I only have a vague impression of server, domain name and IP, and I always want to have a deeper understanding of it. Just this time, I wrote a node project locally. I want to use ali Cloud platform to host this project to the server of the platform, and finally I can access this project directly from the public IP.

2. Hardware introduction

Because the new company assigned Windows system, I used Windows system in this practice, which just enabled me to get familiar with Windows. The main GUI is as follows:

Windows + XShell + fileZilla + Navicat

3. The process

Here is the main flow.

3.1 Purchase AliYun ESC

Go to Ali cloud to buy cloud server ECS, WHAT I buy is the lowest configuration of more than 400 a year.

I choose the latest version of Linux system, other things like server login name, password and so on can be set after purchase.

3.2 Configuring security Groups

After the purchase, we can click the console in the upper right corner of Aliyun to configure our server (just kidding, aliyun’s page design is too messy). This section focuses on security group Settings.

A security group is a virtual firewall. You need to manually add a security group to expose ports 80,3000, and 3306, which are most commonly used HTTP ports.

3.3 Connecting to the Server Using XShell

Before installing the required software on the service, we need to connect to the server locally. Since it is a Windows environment, I use XShell here for Lunix operations.

3.4 installation node

Since we only have a black box to interact with the server locally, we don’t use the local setup (all-purpose Lunix).

A

cd /usr/local/ SRC/wget HTTP: / / https://nodejs.org/dist/v10.11.0/node-v10.11.0-linux-x64.tar.xzCopy the code

B

Tar -zxvf node-v10.11.0-linux-x64.tar.xz // Decompress mv node-v10.11.0-linux-x64 nodeCopy the code

C

Vim ~/.bash_profile // Open the file and enter I to edit PATH=$PATH:$HOME/bin// PATH=$PATH:$HOME/bin:/usr/local/ SRC /node/bin // after modification (blue is added, don't forget the conjunction)   Then press Esc in the upper left corner of the keyboard and enter :wq to compile the file you just modified  source ~/.bash_profile   
Copy the code

3.4 install nginx

A simple command will do

yum install nginx

3.5 Installing mysql and Connecting to mysql locally

Install mysql for Navicat to connect to mysql on server (I started with 3306 security group)

yum install mysql-server
mysql -u root -p
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@The '%' IDENTIFIED BY 'mypassword';
Copy the code

After completing mysql configuration on the server, we can connect to the server database locally using Navicat.

3.6 Uploading code Starts the service

All we need to do is upload the Node code to the server, go to the specified directory, start the service, and see our interface service in the browser.