Complete steps for deploying Alibaba Cloud CentOS7 in maven project

Recently, a local maven project was deployed on CenOS7 in accordance with the requirements of the team assessment. I checked many blogs and integrated a lot of information, and finally successfully deployed. Thinking that the project will definitely be deployed on a remote linux server in the future, I wrote a blog to record its detailed steps, and by the way, I also review common linux commands.

1. Configure security group and open ports

Open 3306 MySQL database port and 8080 Tomcat port, set up SSH remote connection, open port 80, and then open FTP service port 21 due to file upload in my project,
cloud server ECS console -> instance -> management -> this instance Security Group -> Configure Rules

2. Download JDK, MySQL and Tomcat

1. Download and install JDK

Check if the machine comes with java: rpm -qa|grep java
, uninstall if there is: == rpm -e --nodeps java *
Check the jdk version in yum : yum search jdk
find the required jdk version to download and install: yum install -y + jdk version name
View java version information: java -version

2. Install MySQL 8.X version and configure remote access

2.1 Download and install MySQL8.X

Because the local project database uses the MySQL8.0.19 version, if the remote server uses the MySQL5.X version, an error will occur when the sql script file is executed and the data cannot be migrated.
1. Configure the installation source of MySQL 8.0:
sudo rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
2. Install MySQL 8.0:
sudo yum --enablerepo= mysql80-community install mysql-community-server
3. Start the command: sudo service mysqld start
Check the running status: service mysqld status
4. Check the temporary password:
grep "A temporary password" /var/log/mysqld.log
5. Use the temporary password Log in to MySQL: mysql -uroot -p
6. Modify password command: ALTER USER'root '@'localhost' IDENTIFIED BY'root ';
Note: MySQL requires a password of at least 8 digits by default, including uppercase and lowercase letters, numbers, and symbols.

2.2 Configure remote access

1. After logging in to MySQL, use the mysql table: use mysql;
2. View some field information:
select host, user, authentication_string, plugin from user;
3. Set root account access permissions:
CREATE USER'root'@'%' IDENTIFIED BY ' root';
4. Check again:
select host, user, authentication_string, plugin from user;
5. Save the configuration: GRANT ALL ON .
TO'root '@'%'; 6. Modify the encryption method of mysql8:
ALTER USER'[User First name]'@'%' IDENTIFIED WITH mysql_native_password BY'[password]';
Insert picture description here

3. Install Tomcat server

1. yum -y install tomcat
2. After the installation is complete, use the cd command to enter the webapps folder under the installation directory
3. Install the default browser management interface:
yum install tomcat-webapps tomcat-admin-webapps
4. Related tomcat commands:
systemctl stop tomcat.service stop command
systemctl restart tomcat.service restart command
systemctl enable tomcat boot start command
systemctl start tomcat.service start command
systemctl status tomcat view running status After
installation, view port 8080:
Insert picture description here

3. Set the firewall to enable remote access permissions

View the status of open ports:
query the open ports netstat -anp
query whether the specified port is open firewall-cmd --query-port=port/tcp
Common firewall commands:
view firewall statussystemctl status firewalld
Turn on the firewall systemctl start firewalld
Turn off firewall systemctl stop firewalld
Turn on the firewall service firewalld start
Open ports:
add the specified ports that need to be opened:
firewall-cmd --add-port=port/tcp --permanent
reload the added port:
firewall-cmd --reload
query whether the specified port is successfully opened:
firewall- cmd- -query-port=port/tcp
remove the specified port:
firewall-cmd --permanent --remove-port=port/tcp
can connect to the database and server remotely after success:
Insert picture description here
Insert picture description here

4. MySQL data copy and project deployment

1. MySQL data copy

Directly use graphical software such as SQLyog to remotely connect to the MySQL database, regenerate the sql script file of the local database, and finally execute it on the remote database.

2. Project deployment remote server

Mark the local maven project into a war package in IDEA , then use remote file transfer tools such as Filezilla to connect to the remote server and paste the war package in the webapps folder under the tomcat directory .
Finally, enter the project path for access login:
Insert picture description here

Guess you like

Origin blog.csdn.net/m0_46550452/article/details/106503466