Operations 16 min read

CentOS 7 Server Deployment: VM Import, Network, JDK, MySQL, Spring Boot & Tomcat Setup

This step-by-step tutorial covers importing a CentOS 7 VM in VMware, configuring dynamic and static IP addresses, troubleshooting network issues, installing JDK 1.8 and MySQL 5.7, and setting up Spring Boot and Tomcat 8.5 services for auto-start on boot using systemd.

Linux Tech Enthusiast
Linux Tech Enthusiast
Linux Tech Enthusiast
CentOS 7 Server Deployment: VM Import, Network, JDK, MySQL, Spring Boot & Tomcat Setup

1. Import CentOS 7 Virtual Machine in VMware

Open VMware, click "Open a Virtual Machine", select the centos7.ova file, and choose a storage path. Click Import. If a compatibility warning appears, select "Do not show this message again" and click Retry. Click "Edit virtual machine settings" to adjust processor, memory, and disk, then power on. Press Ctrl+Alt to release mouse focus. Log in with username root and password 123456.

2. Configure IP Address

Set Network Adapter to Bridged Mode

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

Option A: Dynamic IP (DHCP)

Edit the network interface file: vi /etc/sysconfig/network-scripts/ifcfg-enp0s3 (the suffix matches your interface name). Change two lines:

BOOTPROTO="dhcp"
ONBOOT="yes"

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

Option B: Static IP

In the same file, set:

BOOTPROTO="static"
IPADDR="192.168.0.121"

(choose an unused address in your subnet)

NETMASK="255.255.255.0"
GATEWAY="192.168.0.1"

(VMware gateway IP) DNS1="114.114.114.114" Restart network service again.

3. Common Pitfalls and Solutions

Error: "Job for network.service failed"

Run systemctl status network.service and journalctl -xn for details.

Cannot ping external sites

Troubleshooting steps:

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

Remove extra interface configs: Delete surplus 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. Restart with service network restart.

Comment out or delete DEVICE line in ifcfg-ethXX.

Set NAME to match 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 net rules: rm -f /etc/udev/rules.d/70-persistent-net.rules.

Ensure VMware virtual network services are running (check VMware services in Windows).

Verify VMware network adapter is connected in the VMware UI (bottom-right icon).

Last resort: reboot the VM.

If Bridged Mode Still Fails

Switch to NAT mode temporarily.

Set IP to DHCP.

Check current DNS: cat /etc/resolv.conf.

After installing required packages, switch back to Bridged mode and configure static IP.

4. Install 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: local directory d:/tmp1, remote /usr. Rename uploaded file to java1.8.

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. This creates jdk1.8.0_281.

Configure environment variables: edit /etc/profile (as root) and append:

#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

Save and run source /etc/profile.

Verify: java -version should show 1.8.0_281.

5. Install 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 and enter the temporary password.

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

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

Allow remote root access:

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

Open port 3306 in firewall:

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 utf8: 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

6. Configure Spring Boot Auto-Start on Boot

Import database schema into MySQL.

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

Create systemd service file: vi /etc/systemd/system/java.service with content:

[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

Adjust paths to your JDK and JAR.

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.

7. Install 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
# add tomcat pid
CATALINA_PID="$CATALINA_BASE/tomcat.pid"
# add java opts
JAVA_OPTS="-server -XX:PermSize=256M -XX:MaxPermSize=1024m -Xms512M -Xmx1024M -XX:MaxNewSize=256m"

Create systemd service: vi /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

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

Reload daemon: 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 in server.xml, and create separate service files (e.g., tomcat1.service, tomcat2.service).

Reboot server to verify auto-start works.

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 BootVMwarenetwork configurationserver deploymentsystemdMySQL 5.7CentOS 7JDK 1.8Tomcat 8.5
Linux Tech Enthusiast
Written by

Linux Tech Enthusiast

Focused on sharing practical Linux technology content, covering Linux fundamentals, applications, tools, as well as databases, operating systems, network security, and other technical knowledge.

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.