Step-by-Step Guide to Deploy a Java Web App on Alibaba Cloud Linux

This tutorial walks you through purchasing an Alibaba Cloud server, configuring the Linux environment, installing JDK, Tomcat, and MySQL, setting up environment variables, deploying a WAR file, and adjusting MySQL character settings, all with clear screenshots and command examples.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Step-by-Step Guide to Deploy a Java Web App on Alibaba Cloud Linux

Prepare the environment by purchasing an Alibaba Cloud server and connecting via Xshell with the root account.

Install JDK

1. Check if a JDK is already installed; if OpenJDK appears, uninstall it.

2. Verify JDK information.

3. Remove OpenJDK using the appropriate commands.

4. Create a directory for the JDK installation.

5. Extract the downloaded JDK archive and install it.

6. Add Java environment variables to the profile file.

7. Apply the changes immediately.

8. Verify the installation succeeded.

Install Tomcat

1. Upload tomcat.tar.gz to /var/local (or any preferred path) and extract it.

2. Move the extracted Tomcat directory to a desired location and rename it.

3. Start Tomcat.

4. If the default address is inaccessible, disable the firewall.

5. Configure Tomcat to start on boot, e.g., by adding Tomcat and JAVA_HOME to /etc/rc.local (note that rc.local runs before /etc/profile, so set JAVA_HOME in startup.sh if needed).

Configure MySQL

1. Install MySQL.

2. Perform initial MySQL configuration.

3. Start the MySQL service.

4. Further configure MySQL settings as required.

5. Test the MySQL installation.

Deploy the Web Application

Upload the compiled .war file from Windows to Tomcat's webapps directory using Xshell's rz command.

Modify conf/server.xml to enable deployment of the WAR file, editing the <Host> element accordingly.

Save changes with :wq in vi.

Prepare the Database

1. Export the MySQL database and upload the .sql file to /usr/bin (use rz to transfer).

2. Log into MySQL and create a database named student matching the Windows environment.

3. Select the newly created database.

4. Adjust character set settings: stop MySQL, edit /etc/mysql/my.cnf to set character_set_server=utf8 and init_connect='SET NAMES utf8', remove any duplicate default-character-set=utf8 lines, then restart MySQL.

After these steps, the server environment is fully configured and ready for the Java web application.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaBackend DevelopmentmysqlTomcatAlibaba CloudServer Setup
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.