Install Tomcat on CentOS 7
Apache Tomcat is an open source implementation of the Java Servlet and Java Server Pages. To install Apache Tomcat on CentOS 7, run
1 |
yum install tomcat |
To enable tomcat start on boot
1 |
systemctl enable tomcat |
You can manage tomcat with
1 2 3 4 |
systemctl stop tomcat systemctl start tomcat systemctl status tomcat systemctl restart tomcat |
To see the ports used by tomcat
1 2 3 4 5 |
[root@tomcat ~]# netstat -lntp| grep java tcp6 0 0 127.0.0.1:8005 :::* LISTEN 31423/java tcp6 0 0 :::8009 :::* LISTEN 31423/java tcp6 0 0 :::8080 :::* LISTEN 31423/java [root@tomcat ~]# |
webapps are stored in the directory
1 |
/var/lib/tomcat/webapps |
Create the default page with
1 2 |
mkdir /var/lib/tomcat/webapps/ROOT echo "Hello Cat" > /var/lib/tomcat/webapps/ROOT/index.html |
Tomcat web server can be accessed using
1 |
http://your-server-ip:8080 |
To open 8080 port on the firewall, use commands
1 2 |
firewall-cmd --permanent --zone=public --add-port=8080/tcp firewall-cmd --reload |
Tomcat configurations are available in the directory.
1 |
/etc/tomcat/ |
Install tomcat Manager
To install the Tomcat manager GUI application, run
1 |
yum install tomcat-admin-webapps.noarch -y |
To create user, edit file
1 |
vi /etc/tomcat/tomcat-users.xml |
Inside “
1 2 |
<role rolename="manager-gui"/> <user username="USER_NAME_HERE" password="PW_HERE" roles="manager-gui"/> |
USER_NAME_HERE and PW_HERE – replace with the username and password you need.
Restart tomcat to activate Tomcat Manager GUI.
1 |
systemctl restart tomcat |
To access GUI, go to
1 |
http://your-server-ip-here:8080/manager/ |