- Java Development Kit Configuration
Start by uploading the required software packages to the /opt directory on your Linux server. Once transferred, extract the JDK binaries to a dedicated installation directory.
mkdir -p /usr/local/java_env
tar -xf jdk-8u-linux-x64.tar.gz -C /usr/local/java_env
Navigate to the extraction directory to verify the contents and then configure the environment variables globally.
cd /usr/local/java_env
ls -l
Open the system profile configuration file to add the Java environment variables:
vi /etc/profile
Append the following configuration to the file, adjusting the paths to match your specific extraction directory:
# Java Environment Settings
export JAVA_ROOT=/usr/local/java_env/jdk1.8.0_XXX
export JRE_HOME=${JAVA_ROOT}/jre
export CLASSPATH=.:${JAVA_ROOT}/lib:${JRE_HOME}/lib
export PATH=${JAVA_ROOT}/bin:$PATH
Save the file and reload the configuration to apply the changes immediately. Verify the installation using the version flag.
source /etc/profile
java -version
- Apache Tomcat Installation and Service Configuration
Return to the /opt directory to decompress the Tomcat archive into the environment folder.
cd /opt
tar -xf apache-tomcat-9.0.xx.tar.gz -C /usr/local/java_env
Verify the extraction and then navigate to the bin directory to test the startup script manually.
cd /usr/local/java_env/apache-tomcat-9.0.xx/bin/
./startup.sh
Configure the firewall to allow traffic on the default Tomcat port (8080).
firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --reload
firewall-cmd --zone=public --list-ports
To ensure Tomcat starts automatically on system boot, register it as a system service. Copy the main script to the init directory.
cp /usr/local/java_env/apache-tomcat-9.0.xx/bin/catalina.sh /etc/init.d/tomcat_service
mv /etc/init.d/tomcat_service /etc/init.d/tomcatd
chmod +x /etc/init.d/tomcatd
Edit the new service file to include the required environment paths:
vim /etc/init.d/tomcatd
Insert the following definitions at the beginning of the file:
# chkconfig: 2345 85 15
# description: Apache Tomcat Service
JAVA_HOME=/usr/local/java_env/jdk1.8.0_XXX
CATALINA_HOME=/usr/local/java_env/apache-tomcat-9.0.xx
Add the service to the chkconfig manager and enable it:
chkconfig --add tomcatd
systemctl restart tomcatd
- MySQL Database Installation and Setup
First, check for and remove any conflicting pre-installed database libraries like MariaDB.
rpm -qa | grep -i mariadb
rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
Create a directory for the MySQL packages and install the RPMs in the correct order of dependencies.
mkdir -p /usr/local/mysql_setup
cd /usr/local/mysql_setup
rpm -Uvh mysql-community-common-5.7.35-1.el7.x86_64.rpm
rpm -Uvh mysql-community-libs-5.7.35-1.el7.x86_64.rpm
rpm -Uvh mysql-community-client-5.7.35-1.el7.x86_64.rpm
rpm -Uvh mysql-community-server-5.7.35-1.el7.x86_64.rpm --force --nodeps
Start the MySQL daemon and configure it to launch at boot.
systemctl start mysqld
systemctl enable mysqld
Retrieve the temporary root password generated during installation.
grep "password" /var/log/mysqld.log
Log in to the database CLI and update the security settings.
mysql -uroot -p
# Enter the retrieved password
In side the MySQL shell, adjust the password validation policy to allow simpler passwords for development, update the root password, and grant remote access privileges.
SET GLOBAL validate_password_policy=LOW;
SET GLOBAL validate_password_length=4;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPass123!';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'NewPass123!' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Open the default MySQL port 3306 in the firewall.
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
- Project Deployment and Verification
With the environment ready, deploy the application. First, import the database schema to ensure the data layer matches the application requirements.
Stop the Tomcat service before deploying the new application package (WAR file).
service tomcatd stop
cd /usr/local/java_env/apache-tomcat-9.0.xx/webapps/
# Transfer your project WAR file here
Start the service again to load the application.
service tomcatd start
Verify that the application is accessible via the browser. Finally, perform a system reboot to confirm that all services (MySQL and Tomcat) start automatically without manual intervension.
reboot