Deploy the Egg project to the Alibaba Cloud server

Table of contents

1. Connect to Alibaba Cloud server and upload files

2. Install Nodejs on the Alibaba Cloud server

3. Download project dependencies

4. Install the egg-scripts module

5. Start the project

6. Alibaba Cloud server opens port 7001


1. Connect to Alibaba Cloud server and upload files

It is recommended to use the FileZilla Client tool to connect to the cloud server, and you can directly drag and drop files to upload.

Connect to the Alibaba Cloud server, click the site manager in the upper left corner, fill in the ip address, user name and password, and click Connect.

After the connection is successful, you will see two areas, the left is the local site, and the right is the remote site, which is the cloud server directory.

 Next, you can find a directory on the remote site and create a new folder to store the Egg project.

Delete the dependent node_modules of the Egg project, and then upload it to the Alibaba Cloud server. Here you can directly find the folder of the Egg project on the left, and drag it to the right area. I put the Egg project in the /home/egg directory.

2. Install Nodejs on the Alibaba Cloud server

Open cmd locally, and connect to the cloud server through the command  ssh root@ip address   .

Use the command node -v to view the node version number. If node is not installed, you need to install node first. Installing node is to download dependencies and run the project.

A higher version of Node is needed here, but the Node installed by command apt-get install nodejs  defaults to version 8.6.0, and there will be problems when installing dependencies. We can install the specified version of Node through the following command

第一步:安装n模块:
npm install -g n

第二步:升级node.js到最新稳定版
n stable

n后面也可以+版本号比如:
n v16.18.0

The Node version I chose here is 16.18.0

After the installation is complete, if you use the command node -v   to check whether the version is still the original version, you can close cmd and reconnect.

3. Download project dependencies

First enter the directory where the project is located:

cd 目录
cd /home/egg/myBlog

 Then download dependencies:

npm install

4. Install the egg-scripts module

The framework has a built-in egg-cluster to start the Master process. The Master is stable enough and no longer needs to use process daemon modules such as pm2. At the same time, the framework also provides egg-scripts to support the running and stopping of the online environment.

npm i egg-scripts --save

5. Start the project

npm start

If egg started on http://127.0.0.1:7001 appears, it means the startup is successful.

If you want to stop the project later, you can use the npm stop command.

6. Alibaba Cloud server opens port 7001

Security Group --> Management Rules --> Manually Add

 

 After opening, we enter in the browser address bar:  ip address: 7001 

Deployment succeeded!

Reference blog:


Ape Chuang Solicitation | Cloud Server Deployment - Deploy the project to the cloud server_Leaf yes's Blog-CSDN Blog

Deploy the egg project to the Alibaba Cloud server

Error: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.27' not found (requ - Short Book

Guess you like

Origin blog.csdn.net/lq313131/article/details/130471563