Cloud server deployment WEB project

1. Preparation work

1. A cloud server
2. Install Xshell to access the remote server
3. Install Xftp to transfer files between local and remote servers
4. Install Navicat to connect to the remote database

2. Install JDK

1. Click on the download address to jump and transfer
Insert image description here
the downloaded compressed file to the server using Xftp

2. Unzip the compressed package

tar -zxvf 压缩包的名字

3. Create a folder for java

mkdir /usr/local/java

4. Move the extracted folder to a custom directory

mv 解压出来的文件夹的 /usr/local/java/

5. Configure environment variables

vim /etc/profile

Add environment variables at the bottom

export JAVA_HOME=/usr/local/java/***
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin

Insert image description here

Then activate the environment variables

source /etc/profile

Finally, java -version. If the version information can be displayed correctly, it means the environment configuration is successful.
Insert image description here

3. Install MySQL

1. Download the MySql installation package

rpm -ivh http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

2. Install Mysql 5.7

yum install -y mysql-server

If Complete! is displayed, the installation is successful.

3. Set up mysql to start at boot

 systemctl enable mysqld.service

4. Check whether automatic startup has been installed.

systemctl list-unit-files | grep mysqld

If the following content is displayed, it means that the automatic startup installation
mysqld.service enabled has been completed
5. Start the mysql service

systemctl start mysqld.service

6. View root temporary password

grep "A temporary password" /var/log/mysqld.log 

Insert image description here
The last part is the temporary password. Copy it and use it to change the password later.
Insert image description here
Enter the mysql service.

mysql -uroot -p

7. Change the temporary password
mysql has its own policy requirements for security. If we want to set it to our commonly used password like root or 123456, we need to modify the policy requirements.

set global validate_password_policy=LOW;

Then change the password

SET PASSWORD = PASSWORD('root');

8. Configure remote access

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;

IDENTIFIED BY 'root' here should be replaced with the password of your own mysql database
9. Refresh permissions

flush privileges;

4. Install Tomcat

1. Click to jump to
the download address 2. Unzip

tar -zxvf ***

3. Create a local directory

mkdir /usr/local/tomcat

4. Move the extracted folder

mv *** /usr/local/tomcat/

5. Configure the firewall

Check firewall service status

systemctl status firewalld

Check the status of firewall

firewall-cmd --state

Start, restart, shut down, firewalld.service service

# 开启
service firewalld start
# 重启
service firewalld restart
# 关闭
service firewalld stop

View firewall rules

firewall-cmd --list-all

Query, open and close ports

# 查询端口是否开放
firewall-cmd --query-port=8080/tcp
# 开放80端口
firewall-cmd --permanent --add-port=80/tcp
# 移除端口
firewall-cmd --permanent --remove-port=8080/tcp
#重启防火墙(修改配置后要重启防火墙)
firewall-cmd --reload
# 参数解释1、firwall-cmd:是Linux提供的操作firewall的一个工具;
#2、--permanent:表示设置为持久;
#3、--add-port:标识添加的端口;

Three ports 80, 8080, and 3306 are open here.

6. Configure cloud server security group

Insert image description here

7. Tomcat directly accesses the system without adding a project name

1. Change the default port to 80,
enter the conf directory under the tomcat directory, and open server.xml

vim server.xml

Insert image description here
Change the port number to 80, because the default port number of the browser is 80, so you don’t need to add the port number when accessing the project.
2. Add it under the Host node

<Context docBase="/usr/local/tomcat/***/webapps/项目名" path="" reloadable="false"/> 

Insert image description here
Then use Navicat to import the database into the mysql of the cloud server.
Finally, place the war package in the webapps directory of tomcat. Be careful to put it when the server is not started.
Then go to the bin directory of tomcat to start the project.

./startup.sh

Shut down the server

./shutdown.sh

Guess you like

Origin blog.csdn.net/qq_42042158/article/details/122015935