Tomcat Installation Linux Server
Tomcat installation will be explained under this topic for answer the how install tomcat application server.To do this I will explain in a few steps below. We will install tomcat 9.0.41.
INFO: Java must be installed on your machine. Or you must install the java.
Step1:
Go to /opt directory and obtain the tomcat installation files.
cd /opt
wget https://ftp.itu.edu.tr/Mirror/Apache/tomcat/tomcat-9/v9.0.41/bin/apache-tomcat-9.0.41.tar.gz --no-check-certificate
Step 2:
Decompress the tar.gz files.
tar -zxvf apache-tomcat-9.0.41.tar.gz
Step 3:
Change opened folder name.
mv apache-tomcat-9.0.41 tomcat
Step 4:
Add user “tomcat” for tomcat applicaiton server.
useradd tomcat
Step 5:
Change ownership off tomcat folder “tomcat” from root.
chown -R tomcat:tomcat tomcat
Step6:
Create service file to start and stop tomcat application server. Also if you need restart the machine, with this service you have not to start tomcat with specific command. With this service this applicaiton will start automatically.
vim /etc/systemd/system/tomcat.service
[Unit]
Description=Apache Tomcat Web Application Server
After=network.target
[Service]
Type=forking
User=tomcat
Group=tomcat
Environment=CATALINA_BASE=/opt/tomcat
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_TMPDIR=/opt/tomcat/temp
Environment=JRE_HOME=/usr
Environment=CLASSPATH=/opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
RestartSec=10
Restart=always
[Install]
WantedBy=multi-user.target
chown tomcat:tomcat /etc/systemd/system/tomcat.service
systemctl daemon-reload
systemctl enable tomcat
systemctl start tomcat
Step8:
Check tomcat application server on your browser.
http://<Your Machine Ip Address>:8080
Enable SSL Connection With Selfsigned Certificate
Create Self-Signed certificate with openssl. İf you want enable this settings in your production environment you have to use your security certificate. I just showed how do you enable ssl connection on tomcat Web application server.
mkdir /opt/SSL
keytool -genkey -alias tomcat_cert -keyalg RSA -keystore /opt/SSL/tomcat_cert.keystore
After run this command you should answer the is coming promt with your prefer.
Then we will configure the tomcat applicaiton server.xml file. You should add below commands and remove redirect settings. Then restart tomcat server.
vim /opt/tomcat/conf/server.xml
<Connector port="8443" maxthreads="150" scheme="https" secure="true"
SSLEnabled="true" keystoreFile="/opt/SSL/tomcat_cert.keystore"
keystorePass="your password" ClientAuth="false" keyAlias="tomcat_cert"
sslProtocol="TLS"/>
systemctl restart tomcat
Check SSL connection on your browser.
https://<Your Machine IP Address>:8443
Enable Tomcat Admin Console
To enable tomcat admin console you should follow below steps. We will add some commands in tomcat-users.xml file.
vim /opt/tomcat/conf//tomcat-users.xml
<role rolename="manager-gui"/>
<user username="tomcat" password="tomcat" roles="manager-gui"/>
İf you want access remote machine you should edit context file.
vim /opt/tomcat/webapps/manager/META-INF/context.xml
After edit files you should restart the tomcat service.
systemctl restart tomcat
Let’s try to connect to the admin console.
As you can see we have been connected with success.
If I have enaough time, Iwill continue to write.
No responses yet