Skip to content
Step-by-Step: Deploy Apps to CentOS 7 Server with VMware, JDK, MySQL & Tomcat
Operations 15 min read

Step-by-Step: Deploy Apps to CentOS 7 Server with VMware, JDK, MySQL & Tomcat

A comprehensive hands-on tutorial covering CentOS 7 VM setup in VMware, network configuration (DHCP/static IP), troubleshooting common network errors, installing JDK 1.8 and MySQL 5.7, configuring Spring Boot auto-start via systemd, and deploying Tomcat 8.5 with custom memory settings.

IoT Full-Stack Technology
IoT Full-Stack Technology
IoT Full-Stack Technology

Importing CentOS 7 Virtual Machine in VMware

Open VMware, click "Open a Virtual Machine", select the centos7.ova file, choose a storage path, and click Import. Dismiss the warning by selecting "Do not show this message again" and clicking Retry. Edit virtual machine settings to adjust CPU, memory, and disk, then start the VM. Press Ctrl+Alt to release mouse focus. Log in with username root and password 123456.

Configuring IP Address

Set Network Adapter to Bridged Mode

In VMware, ensure the network connection is set to Bridged Mode .

Option 1: Dynamic IP (DHCP)

Edit the network interface file vi /etc/sysconfig/network-scripts/ifcfg-enp0s3 (replace enp0s3 with your interface name). Modify two lines:

BOOTPROTO="dhcp"
ONBOOT="yes"

Restart network service: systemctl restart network. Verify with ip addr and test connectivity ( ping baidu.com).

Option 2: Static IP

In the same file, set:

BOOTPROTO="static"
IPADDR="192.168.0.121"        # desired static IP (e.g., 192.168.1.4-253)
NETMASK="255.255.255.0"
GATEWAY="192.168.0.1"         # VMware gateway IP
DNS1="114.114.114.114"        # domestic DNS
ONBOOT="yes"

Restart network service again.

Troubleshooting Common Network Issues

If systemctl restart network fails with Job for network.service failed, or ping fails, try these steps in order:

Check IP conflict: From host, ping the assigned IP to see if it's already in use.

Remove duplicate interface configs: Delete extra ifcfg-e* files in /etc/sysconfig/network-scripts/: rm -f /etc/sysconfig/network-scripts/ifcfg-eXXX Fix HWADDR (MAC address): Run ip addr to find the correct MAC, then edit the corresponding ifcfg-ensXX file to set HWADDR correctly, or delete the line entirely. Restart with service network restart.

Comment out or delete DEVICE line in ifcfg-ethXX.

Ensure NAME matches filename in ifcfg-xxx.

Delete UUID line from the interface config.

Stop and disable NetworkManager:

systemctl stop NetworkManager.service
systemctl disable NetworkManager.service

Then restart network: service network restart.

Remove persistent udev rules: rm -f /etc/udev/rules.d/70-persistent-net.rules.

Verify VMware services running and that the network adapter shows "Connected" in VMware status bar.

Last resort: Reboot the VM.

If issues persist, switch to NAT mode, configure DHCP first, check DNS ( cat /etc/resolv.conf), then switch back to static IP and bridged mode after installing required packages.

Installing JDK 1.8 on CentOS 7

Check existing Java: java -version.

Download JDK 8u281 from Oracle:

https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html

.

Upload to CentOS via SFTP:

sftp> lcd d:/tmp1
sftp> cd /usr
sftp> put jdk-8u281-linux-x64.tar.gz
sftp> mv jdk-8u281-linux-x64.tar.gz java1.8

Extract: cd /usr && tar -zxvf java1.8 → creates jdk1.8.0_281.

Configure environment variables in /etc/profile (as root):

#java environment
export JAVA_HOME=/usr/jdk1.8.0_281
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin

Apply: source /etc/profile.

Verify: java -version should show 1.8.0_281.

Installing MySQL 5.7 on CentOS 7

Install wget: yum -y install wget.

Download and install MySQL repo RPM:

sudo wget http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql57-community-release-el7-10.noarch.rpm
sudo rpm -ivh mysql57-community-release-el7-10.noarch.rpm

Install server: sudo yum -y install mysql-community-server (takes a few minutes).

Start and enable: sudo systemctl start mysqld && sudo systemctl enable mysqld.

Find temporary root password: cat /var/log/mysqld.log (e.g., waf_eHWkr42K).

Log in: sudo mysql -uroot -p, enter temporary password.

Change password (must meet policy: 8+ chars, upper/lower/digit/special):

ALTER USER 'root'@'localhost' IDENTIFIED BY '1qaz!QAZ';

Enable remote root access:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '1qaz!QAZ' WITH GRANT OPTION;
exit

Open firewall port 3306:

sudo systemctl start firewalld.service
sudo firewall-cmd --add-port=3306/tcp --permanent
sudo firewall-cmd --reload
# optional: stop firewall if not needed
sudo systemctl stop firewalld.service

Set default charset to UTF-8: edit /etc/my.cnf, add under [mysqld]:

character_set_server=utf8
init_connect='SET NAMES utf8'

Restart MySQL: sudo systemctl restart mysqld. Verify with show variables like '%chara%';.

Test remote connection with Navicat or similar tool.

Key file locations: data /var/lib/mysql, config /etc/my.cnf, logs /var/log/mysqld.log.

Spring Boot Auto-start on Boot (systemd)

Import database schema into MySQL.

Upload built JAR to /usr/local/project/springboot.jar. Test run: java -jar springboot.jar.

Create service file /etc/systemd/system/java.service:

[Unit]
Description=java
After=syslog.target

[Service]
Type=simple
ExecStart=/usr/jdk1.8.0_281/bin/java -jar /usr/local/project/springboot.jar

[Install]
WantedBy=multi-user.target

Add execute permission: chmod +x /etc/systemd/system/java.service.

Reload daemon: systemctl daemon-reload.

Start and enable: systemctl start java && systemctl enable java.

Verify: ps -ef | grep java | grep -v grep and systemctl status java.service -l.

Installing Tomcat 8.5 on CentOS 7

Download Tomcat 8.5.63: https://tomcat.apache.org/download-80.cgi.

Upload to /usr/ and extract: tar -zxvf apache-tomcat-8.5.63.tar.gz.

Create PID file: touch /usr/apache-tomcat-8.5.63/tomcat.pid.

Create setenv.sh in bin/ with JVM options:

export CATALINA_HOME=/usr/apache-tomcat-8.5.63
export CATALINA_BASE=/usr/apache-tomcat-8.5.63
CATALINA_PID="$CATALINA_BASE/tomcat.pid"
JAVA_OPTS="-server -XX:PermSize=256M -XX:MaxPermSize=1024m -Xms512M -Xmx1024M -XX:MaxNewSize=256m"

Create service file /etc/systemd/system/tomcat.service:

[Unit]
Description=Tomcat
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
Environment="JAVA_HOME=/usr/jdk1.8.0_281"
PIDFile=/usr/apache-tomcat-8.5.63/tomcat.pid
ExecStart=/usr/apache-tomcat-8.5.63/bin/startup.sh
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

Permission and reload:

chmod +x /etc/systemd/system/tomcat.service && systemctl daemon-reload

.

Start and enable: systemctl start tomcat && systemctl enable tomcat.

Check status: systemctl status tomcat.service. Stop: systemctl stop tomcat. List processes: ps -ef | grep tomcat | grep -v grep.

For multiple instances, copy to different directories, change ports, and create separate service files (e.g., tomcat1.service, tomcat2.service).

Reboot server to verify auto-start.

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.

Spring BoottroubleshootingVMwarenetwork configurationsystemdMySQL 5.7Linux deploymentCentOS 7JDK 1.8Tomcat 8.5
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.