( Only to commemorate the first learning blog in my life ) A
while ago, I took a small JavaWeb project and released it to the cloud server as needed. At the same time, in order to be more familiar with the entire process of JavaWeb development, I bought an Alibaba Cloud server to practice. Practice hands. In the previous exercises, I used my own computer as the server. Other people who are not under the same local area network can not access the local project. I thought it would be difficult to publish the project to the Linux server. In fact, after contacting it, I found it very simple. Install the same (JDK, Mysql, Tomcat) environment on the Alibaba Cloud server as the local machine (it’s nothing more than Linux, which has less visual graphical interface than Windows system), and then package the project on the server. Then I will go through the whole process Show it again, starting with purchasing Alibaba Cloud servers...
1. Purchase Alibaba Cloud Server
Enter Ali cloud the official website , register Login
-
Search "Alibaba Cloud Server ECS" and click to buy
-
Choose custom purchase , choose server configuration according to your own needs;
It is best to choose a region close to your customers to reduce network latency and increase access speed.
Shared instance refers to an entry-level server, suitable for basic configuration such as website building and testing
- Select system mirror
It is recommended to choose the CentOS (Linux) system image, because Linux abandons the graphical interface and uses the command line to operate, and the performance can be more fully utilized. [Note: Non-Aliyun Linux]
Under the premise of determining the environmental requirements, you can also directly select more complete mirrors from the mirror market. These mirrors are pre-installed with the basic environment required for operation, saving time and effort.
There is a system image (Tomcat9, jdk1.8, MySQL5.6) pre-installed with the environment required for running a complete JavaWeb project. The system version is recommended to choose CentOS7 series, 7.3 and above.
Click " Use ", click " Next " to configure the network and security group
- Perform network and security group configuration
Choose the bandwidth according to your needs. I choose the default minimum
security group rule. After the purchase is successful, you need to open the corresponding port in the console, and then set it later.
Click Next to proceed to system configuration.
- Perform system configuration
Set a login password, don’t forget it, if you forget it, you can retrieve it or reinstall the system, the steps are the same, you need to connect later
Instance name and description are set according to personal preference
- The group setting is not filled by default, confirm the order and the purchase is successful!
Click on the console on the homepage of Alibaba Cloud official website,
click on the cloud server ECS and
click on the instance on the left , you can see the Alibaba Cloud server instance you just purchased
Two, configure the security group
Click "Manage" on the right side of "Instance",
click "Security Group for this instance " on the left, and then click "Configure Rules" on the right
- Inbound security group configuration
Then click in the inbound direction to quickly create a security group, and see if the check I ticked must be marked, otherwise the port will not be connected.
After adding, you need to add two more! Two! Two security groups
- Outbound security group configuration
Three, connect to Alibaba Cloud server
- Download Xshell (connect to remote server host via network)
Open Xshell -> New connection
Fill in the login user name (default root) and password you set when you purchased the server
. Prompt for successful connection.
Enter java -version to see the built-in jdk version.
MySQL.
Enter rpm -qa | grep mysql to see if the database is installed.
Enter mysql -u Root -p enter the password and log in to the database (Linux system is very cute, it hides the password, don't change the keyboard)
Use the local database visualization tool Navicate to connect to the MySQL database of Alibaba Cloud Server
Create a new connection -> Alibaba Cloud Database MySQL Edition
General settings (host connection port, username and password)
SSH channel settings (Alibaba Cloud server ip, port and username, password)
Click OK, double-click the connection name on the left to open the connection, you can manually create a database and table for the cloud server , And operating data from the cloud server database
2. Verify Tomcat
Enter the public network ip+:8080 of the Alibaba Cloud server you purchased in the address bar of the local browser, and you will see the following Tom Cat page, indicating that your Alibaba Cloud server public network ip is publicly accessible and tomcat is running normally
3. Download Xftp (can Transfer files between Linux and Windows) deploy JavaWeb project to Alibaba Cloud server
In the eclipse compiler, export the JavaWeb project as a war package (WAR file format)
Right-click on the project——>Export, select WAR file,
select the export address of the war package, and uncheck the specific Tomcat operating environment.
Open the Xftp tool downloaded earlier, the new connection
is successful, the left side is the computer file of the machine, the right Linux system files on the side (drag and drop to transfer files)
In the Linux system interface on the right, browse to the /usr/local/src/apache-tomcat-9.0.1/webapps directory, and directly drag the WAR package exported from the local JavaWeb project to the webapps directory on the right (here No need to unzip, tomcat will automatically unzip for us)
After the above, the entire project deployment process has been completed
Fourth, run the project
Enter ip+:8080+ project name (the designated jsp page) in the address bar of the local browser to access the JavaWeb project.
We can deploy JavaWeb, Html web pages, App, etc. on the server.
Congratulations! So far, you have successfully deployed the web project to the Alibaba Cloud server!
5. About how to remove the ":8080" in the address
- Enter /usr/local/src/apache-tomcat-9.0.1/conf in the cnof directory of tomcat in the Xftp tool, right-click sever.xml and open it with notepad
2. Modify a port information
3. Restart tomcat
Restart command under Linux : Systemctl restart tomcat.service
or go to the bin directory of tomcat, use the tomcat command to restart tomcat
- Without port 8080 , visit again