Deploy the Vue+Node.js project to the full version of the linux server

1. Connect to the ECS server

1. The terminal connects to the remote server

  1. Enter the connection command ssh [username]@[ipaddress] in the terminal and press the Enter key on the keyboard. You need to replace username and ipaddress with the login name and public address of the ECS server,
ssh root@139.xxx.xxx.230
  1. Enter yes to agree to continue the connection. After doing this, you will be prompted to enter your login password.

  2. Enter the login password. The password is the login password of the created ECS server. Note that nothing will be displayed when entering the password.

2. xshell connects to the remote server

Configure ip, port, account, password
insert image description here
insert image description here

2. Install the pagoda panel

1. xshell for remote connection or terminal connection

2. Enter the Centos installation command:

yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh

Installation error, you can view the version issues as follows:
After December 31, 2021, users of CentOS Linux 8 will not be able to obtain any software maintenance and support including bug fixes and feature updates.
The official suggestion of Pagoda:
1. If you are using Centos 8 system, switch to Centos 8 Stream to ensure that you can get any software maintenance and support including fixes and function updates. You can also choose to
switch to Rocky/Alma/Anolis/Oracle linux 8
2. It is recommended to use Centos7 to install the pagoda panel for new installation machines. If you want to continue using Centos8, you can use Rocky/Alma/Oracle linux 8. If you want to
use Debian or Ubuntu, it is recommended to choose Debian-11/Ubuntu-20
to install the pagoda panel. The impact of the panel, it may not be possible to install the panel or the environmental software in the panel, etc.
Centos 8 to Centos 8 Stream tutorial

3. Centos 8 upgrade to Centos 8 Stream tutorial

detailed steps

4. Enter the pagoda panel

1. Terminal or xshell terminal input :

/etc/init.d/bt default

2. The result appears:
insert image description here
3. Then enter the URL, enter the panel, and enter the above account and password
insert image description here

3. Install ngnix and pm2

Install ngnix and pm2, enter the command to install, or find it directly in the store.

1. Upload vue and node.js projects

Upload the vue project
This is my directory, the default location
of the vue project is directly packaged

npm run build

Just upload the dist directory of your local vue project. If you
insert image description here
upload the node.js project
node.js project, don’t pass in the node_modules directory, it’s too big, and don’t pass in some useless ones.
Pass in other directories.
After uploading, switch to your node.js project directory in the terminal to download npm your project dependencies, that's it

npm install

2. nginx configuration vue project

The nginx configuration instructions
are for reference only to
the server block in the http block in the nginx configuration

location / {
    
    
          root /www/server/php/dist;
          index index.html index.htm index.php;
}

3. Port firewall settings (front-end, back-end and front pagoda ports cannot be accessed)

At this time, you can check whether you can access the front-end page in an external browser.
Reason for failure:
The file path is wrong. The
port is not open
. If the port is open, but still fails, you need to set
the firewall. The first step of the port release
is to configure the firewall on port 80 :

firewall-cmd --zone=public --add-port=80/tcp --permanent
1

The second step is to restart the firewall service:

systemctl restart firewalld.service
or
sudo firewall-cmd --reload

Step 3. Check all the ports allowed by the firewall, whether your port is included.
Enter this command in the terminal

sudo firewall-cmd --list-all

insert image description here

4. PM2 configuration node.js project

Introduction:
pm2 is a process manager for Node applications with load balancing function.

Use:
In the PM2 manager, add the project, and add the Node.js project directory. Select an open port
insert image description here
and click start. You can
check the log to see if it is running normally.
insert image description here
5. Test whether the deployment is successful
. If there is no problem with the port, you can use postman to test the back-end port, which directly accesses the back-end interface.
Below is a backend test port I wrote. Success means that the Node backend deployment is successful
insert image description here

4. Nginx front-end server forwards back-end requests

Server configuration in nginx http block

Match the request starting with /api . The requests sent from the front end to the back end here all start with /api. It was also used for local development before to configure cross-domain requests.

# 这里的一个斜杠也不能少,之前我就是少了个斜杠,找了半天错
  location ^~ /api/ {
    
        
            proxy_pass http://localhost:3000/;
 }

This is the complete end, you can try the project you deployed on the browser
If you have any questions, welcome to private message me

Guess you like

Origin blog.csdn.net/qq_45859670/article/details/122868279