Alibaba Cloud Java Web Environment Construction Guide (CentOS7)

1. Log in to the Alibaba Cloud server

After purchasing an ECS server, the system will create an ECS instance. Each ECS instance corresponds to a purchased cloud server. You can access the cloud server through the terminal tool that comes with your computer, or you can use the three-way connection terminal tool.

(1) Open the command line terminal tool on the computer.

 --Windows:Powershell。
 --MAC:Terminal。
Windows用户请检查系统中是否安装有SSH工具。检查方法:
a.在终端中输入命令:ssh -V。
  如果显示SSH版本则表示已安装,信息如下:
	PS C:\Users\HASEE> ssh -V
	OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
b.如果未安装,请下载安装OpenSSH工具。
c.在终端中输入连接命令:ssh root@[ipaddress]。其中ipaddress 替换为服务器的公网IP地址。例如:ssh [email protected]
d.输入yes,然后输入云服务器的登录密码。

(2) Other tools

例如:xshell等,访问原理和(1)一样都是设置访问ip和登录用户以及密码进行登录。

2. Install JDK

1. Execute the following command to view the JDK version in the yum source.

yum list java*

2. Execute the following command, use yum to install JDK1.8.

yum -y install java-1.8.0-openjdk*

3. Execute the following command to check whether the installation is successful.

java -version

If the content shown in the following figure is displayed, it means that the JDK is installed successfully.
Insert picture description here
Note : The location of Java installed in this way is under the /usr/share/Javadoc directory

3. Install mysql database

1. Execute the following commands to download and install the official Yum Repository of MySQL.

wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server

Insert picture description here
2. View the MySQL database service status.

systemctl status mysqld

3. Execute the following command to start the MySQL database.

systemctl start mysqld

4. Execute the following command to view the initial MySQL password.

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

Insert picture description here

5. Execute the following command to log in to the database.

mysql -uroot -p

6. Execute the following command to modify the MySQL default password.

set global validate_password_policy=0; #修改密码安全策略为低(只校验密码长度,至少8位)。
ALTER USER 'root'@'localhost' IDENTIFIED BY '12345678';

7. Execute the following commands to grant the root user remote management authority.

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

8. Enter exit to exit the database.

exit

9. Modify the mysql default access port (to prevent unnecessary MySQL attacks)
(1) View the port number (log in to mysql): show global variables like 'port';
(2) Modify the port, edit the /etc/my.cnf file, and add the following in the [mysqld] section instruction:

port=3309 (端口号可以是其他的)

(3) Restart the mysql service: service mysqld restart(At this time, check again and find that it has changed from 3306 to 3309).
10. The steps to solve the forgotten password of the root user:
(1) Modify the MySQL login settings, and add a sentence in the [mysqld] paragraph: skip-grant-tablessave and exit vi.

vi /etc/my.cnf

(2) Restart mysqld

/etc/init.d/mysqld restart(或者service mysqld restart) 

(3) Log in and modify the MySQL root password

mysql> USE mysql; 
mysql> UPDATE user SET Password = new_password WHERE User = 'root'; 
mysql> flush privileges; 

(4) Modify the MySQL login settings back, skip-grant-tablesdelete (or comment out) the one just added in the [mysqld] section , save and exit.

vi /etc/my.cnf

(5) Restart mysqld again

4. Install Tomcat

1. Execute the following command to download the Tomcat compressed package.
Address 1: wget https://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.5.59/bin/apache-tomcat-8.5.59.tar.gz
Address 2: wget https://archive .apache.org/dist/tomcat/tomcat-8/v8.5.59/bin/apache-tomcat-8.5.59.tar.gz For
other versions, please see: http://archive.apache.org/dist/tomcat/ , where Bin is a binary file, and src is the source code.
2. Execute the following command to decompress the Tomcat package just downloaded.

tar -zxvf apache-tomcat-8.5.59.tar.gz 

3. Execute the following command to move and modify the Tomcat name.

mv apache-tomcat-8.5.59 /usr/local/Tomcat8.5

4. Execute the following commands to authorize Tomcat (maybe sometimes not needed).

chmod +x /usr/local/Tomcat8.5/bin/*.sh

5. Execute the following command to modify the default port number of Tomcat to 80, and it is not necessary to modify it. (Tomcat default port number is 8080)

sed -i 's/Connector port="8080"/Connector port="80"/' /usr/local/Tomcat8.5/conf/server.xml

6. Start Tomcat.

/usr/local/Tomcat8.5/bin/./startup.sh

7. Visit Tomcat. Open the browser and enter the ECS public network IP in the address bar, for example: 139.0.0.1
If a cat interface is displayed, it means that the Tomcat installation and configuration are successful.
Note: You need to open the port that the security group allows you to open, such as Tomcat's default port 8080

At this point, the Java Web development environment is set up.

Guess you like

Origin blog.csdn.net/rao991207823/article/details/114197289