sudo dnf install httpd -y<\/pre>\nTo start and enable the apache service, execute the commands below:<\/p>\n
sudo systemctl start httpd && sudo systemctl enable httpd<\/pre>\nCheck the status of the Apache service:<\/p>\n
sudo systemctl status httpd<\/pre>\nYou should receive the following output:<\/p>\n
[root@vps ~]# sudo systemctl status httpd\r\n\u25cf httpd.service - The Apache HTTP Server\r\n Loaded: loaded (\/usr\/lib\/systemd\/system\/httpd.service; enabled; vendor preset: disabled)\r\n Active: active (running) since Mon 2022-05-09 12:43:47 CDT; 7s ago\r\n Docs: man:httpd.service(8)\r\n Main PID: 7287 (httpd)\r\n Status: \"Started, listening on: port 80\"\r\n Tasks: 213 (limit: 23715)\r\n Memory: 36.5M\r\n CGroup: \/system.slice\/httpd.service\r\n \u251c\u25007287 \/usr\/sbin\/httpd -DFOREGROUND\r\n \u251c\u25007353 \/usr\/sbin\/httpd -DFOREGROUND\r\n \u251c\u25007354 \/usr\/sbin\/httpd -DFOREGROUND\r\n \u251c\u25007355 \/usr\/sbin\/httpd -DFOREGROUND\r\n \u2514\u25007356 \/usr\/sbin\/httpd -DFOREGROUND\r\n\r\nMay 09 12:43:46 host.test.vps systemd[1]: Starting The Apache HTTP Server...\r\n<\/pre>\n<\/span>Step 3. Install Java<\/span><\/h2>\nTo install the latest Java 17 version along with other dependencies execute the following commands:<\/p>\n
dnf install epel-release\r\n\r\ninstall java-17-openjdk-devel\r\n<\/pre>\nAfter successfull installation check the installed version.<\/p>\n
java -version<\/pre>\nYou should receive the following output:<\/p>\n
[root@vps ~]# java -version\r\nopenjdk version \"17.0.3\" 2022-04-19 LTS\r\nOpenJDK Runtime Environment 21.9 (build 17.0.3+6-LTS)\r\nOpenJDK 64-Bit Server VM 21.9 (build 17.0.3+6-LTS, mixed mode, sharing)\r\n<\/pre>\n<\/span>Step 4. Install Tomcat 10<\/span><\/h2>\nFirst, we need to create a directory for tomcat installation, a tomcat user, and a group.<\/p>\n
mkdir \/opt\/tomcat\r\n\r\ngroupadd tomcat\r\n\r\nuseradd -s \/bin\/nologin -g tomcat -d \/opt\/tomcat tomcat\r\n<\/pre>\nDownload Tomcat 10 and extract it in the \/opt\/tomcat<\/b> directory on your server.<\/p>\ncd \/opt\r\n\r\nwget https:\/\/downloads.apache.org\/tomcat\/tomcat-10\/v10.0.20\/bin\/apache-tomcat-10.0.20.tar.gz -O tomcat-10.0.20.tar.gz\r\n\r\ntar xzvf tomcat-10.0.20.tar.gz -C \/opt\/tomcat --strip-components=1\r\n<\/pre>\nOnce, downloaded and extracted, set the right permissions.<\/p>\n
chown tomcat:tomcat -R \/opt\/tomcat\/\r\n\r\nchmod +x \/opt\/tomcat\/bin\/*.sh\r\n<\/pre>\nNext, is to create a Systemd Service File for Tomcat.<\/p>\n
touch \/etc\/systemd\/system\/tomcat.service<\/pre>\nOpen the file, and paste the following lines of code.<\/p>\n
[Unit]\r\nDescription=Apache Tomcat\r\nAfter=network.target\r\n\r\n[Service]\r\nType=forking\r\n\r\nUser=tomcat\r\nGroup=tomcat\r\n\r\nEnvironment=\"JAVA_HOME=\/usr\/lib\/jvm\/jre\"\r\nEnvironment=\"JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:\/dev\/.\/urandom\"\r\n\r\nEnvironment=\"CATALINA_BASE=\/opt\/tomcat\"\r\nEnvironment=\"CATALINA_HOME=\/opt\/tomcat\"\r\nEnvironment=\"CATALINA_PID=\/opt\/tomcat\/temp\/tomcat.pid\"\r\nEnvironment=\"CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC\"\r\n\r\nExecStart=\/opt\/tomcat\/bin\/startup.sh\r\nExecStop=\/opt\/tomcat\/bin\/shutdown.sh\r\n\r\nExecReload=\/bin\/kill $MAINPID\r\nRemainAfterExit=yes\r\n\r\n[Install]\r\nWantedBy=multi-user.target\r\n<\/pre>\nSave, the file close it and restart the daemon.<\/p>\n
systemctl daemon-reload<\/pre>\nStart and enable the Tomcat service:<\/p>\n
systemctl start tomcat && systemctl enable tomcat<\/pre>\nOnce started check the status of the service:<\/p>\n
systemctl status tomcat<\/pre>\nYou should receive the following output:<\/p>\n
[root@vps ~]# systemctl status tomcat\r\n\u25cf tomcat.service - Apache Tomcat\r\n Loaded: loaded (\/etc\/systemd\/system\/tomcat.service; enabled; vendor preset: disabled)\r\n Active: active (exited) since Mon 2022-05-09 14:47:43 CDT; 3min 7s ago\r\n Tasks: 0 (limit: 23715)\r\n Memory: 0B\r\n CGroup: \/system.slice\/tomcat.service\r\n\r\nMay 09 14:47:43 host.test.vps systemd[1]: Starting Apache Tomcat...\r\n<\/pre>\n<\/span>Step 5. Create Apache as a reverse proxy for Tomcat<\/span><\/h2>\nNow, you can access Tomcat on port 8080 at http:\/\/YourServerIPAddress:8080<\/b>, but it will be insecurity and as we know, we can only install an SSL certificate on the domain.<\/p>\ntouch \/etc\/httpd\/conf.d\/tomcat.conf<\/pre>\nOpen the file with your favorite editor and paste the following lines of code:<\/p>\n
<VirtualHost *:80>\r\n ServerName yourdomain.com\r\n ProxyRequests off \r\n ProxyPass \/ http:\/\/127.0.0.1:8080\/ \r\n ProxyPassReverse \/ http:\/\/127.0.0.1:8080\/ \r\n<\/VirtualHost>\r\n<\/pre>\nSave the file, close it and check the Apache syntax.<\/p>\n
httpd -t<\/pre>\nYou should receive the following output:<\/p>\n
[root@vps httpd]# httpd -t\r\nSyntax OK\r\n<\/pre>\nIf the syntax is OK, restart the service<\/p>\n
sudo systemctl restart httpd<\/pre>\nNow, you can access your Tomcat via domain at http:\/\/yourdomain.com<\/b>, but we are not done here in this tutorial. The next step is about securing the Tomcat domain with an SSL certificate.<\/p>\n<\/span>Step 6. Install SSL certificate<\/span><\/h2>\nInstall first, the mod_ssl extension and python certbot.<\/p>\n
dnf install epel-release mod_ssl -y\r\n\r\ndnf install python3-certbot-apache -y\r\n<\/pre>\nOnce, this is installed you can generate an SSL certificate with the following command:<\/p>\n
certbot --apache --agree-tos --redirect --hsts --staple-ocsp --email admin@yourdomain.com -d yourdomain.com\r\n<\/pre>\nAfter successful installation you should receive the following output:<\/p>\n
Deploying certificate\r\nSuccessfully deployed certificate for yourdomain.com<\/b> to \/etc\/httpd\/conf.d\/tomcat-le-ssl.conf\r\nCongratulations! You have successfully enabled HTTPS on https:\/\/yourdomain.com<\/b>\r\n\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\nIf you like Certbot, please consider supporting our work by:\r\n * Donating to ISRG \/ Let's Encrypt: https:\/\/letsencrypt.org\/donate\r\n * Donating to EFF: https:\/\/eff.org\/donate-le\r\n\r\n<\/pre>\n Now you can access your Tomcat interface securely at https:\/\/yourdomain.com<\/b><\/p>\n
<\/p>\n
Congratulations! You successfully installed and secured Tomcat 10 with an SSL certificate on AlmaLinux. If you find it difficult to install and configure all these with the provided commands, you can always contact our technical support and they will do the rest for you. We are available 24\/7.<\/p>\n
P.S If you liked this post on how to install and secure Tomcat on AlmaLinux, please share it with your friends on social networks or simply leave a reply below. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":"
In this tutorial, we are going to install Tomcat 10 and secure it with an SSL certificate on AlmaLinux OS. … <\/p>\n
Read More<\/a><\/p>\n","protected":false},"author":4,"featured_media":41580,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[1910,1603,90],"yoast_head":"\nHow to Install and Secure Tomcat 10 on AlmaLinux - RoseHosting<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n \n \n \n \n \n\t \n\t \n\t \n