how to configure Apachi Tomcat?
By default you only able to access default Tomcat page, to access admin and other sections like Server Status, Manager App and Host Manager. You need to configure user accounts for admins and managers. To do so, you need to edit ‘tomcat-users.xml‘ file located under/opt/apache-tomcat-8.0.9/conf directory.
Setup Tomcat User Accounts
For example, to assign the manager-gui role to a user named ‘tecmint‘ with a
password ‘t$cm1n1‘, add the following line of code to the
config file inside the section.
# vi /opt/apache-tomcat-8.0.9/conf/tomcat-users.xml
<role rolename="manager-gui"/>
<user username="tecmint" password="t$cm1n1" roles="manager-gui"/>
Similarly, you can also add ‘admin-gui‘ role
to a admin user named ‘admin‘ with a password ‘adm!n‘ as shown
below.
<role rolename="admin-gui"/>
<user username="admin" password="adm!n" roles="admin-gui"/>
Create User Accounts in Tomcat
After setting up the admin and
managers roles, restart the Tomcat and then try to access the admin section.
./shutdown.sh
./startup.sh
For example, click on 'Server Status' tab, it will prompt you to enter user credentials, enter username and password that you've added above in config file.
Tomcat Admin Login
Changing Tomcat Port
If you want to run Tomcat on
different port say 80 port. You will have to edit the ‘server.xml‘
file in ‘/opt/apache-tomcat-8.0.9/conf/‘. Before changing,
port, make sure to stop the Tomcat server using.
# /opt/apache-tomcat-8.0.9/bin/shutdown.sh
Now open the server.xml file using the Vi editor.
# vi /opt/apache-tomcat-8.0.9/conf/server.xml
Now search for “Connector port”
and change its value from 8080 to 80 or any other port you want as it
follows.
To save the file, Press the ‘ESC’ key, and write :w then :x.
Now restart the Apache Tomcat
server again, using below command.
# /opt/apache-tomcat-8.0.9/bin/startup.sh
That’s it, you server will be
running on the 80 port.
Of course, you have to run all
the above commands as a root, if you
don’t they won’t work because we are working in the ‘/opt‘ directory
which is a folder owned by the root user only, if you want you can run the
server as a normal user but you will have to use your HOME folder as a working area to download,
extract and run the Apache Tomcat server.
To get some information about
your running Tomcat server and your computer, run.
/opt/apache-tomcat-8.0.9/bin/version.sh
Sample Output
Using CATALINA_BASE: /opt/apache-tomcat-8.0.9
Using CATALINA_HOME: /opt/apache-tomcat-8.0.9
Using CATALINA_TMPDIR: /opt/apache-tomcat-8.0.9/temp
Using JRE_HOME: /usr
Using CLASSPATH: /opt/apache-tomcat-8.0.9/bin/bootstrap.jar:/opt/apache-tomcat-8.0.9/bin/tomcat-juli.jar
Server version: Apache Tomcat/8.0.9
Server built: Jun 19 2014 01:54:25
Server number: 8.0.9.0
OS Name: Linux
OS Version: 2.6.32-042stab084.26
Architecture: i386
JVM Version: 1.8.0_20-b26
JVM Vendor: Oracle Corporation
That’s it! Now you can start
deploying JAVA based applications under Apache Tomcat.
For more about on how to deploy applications and create virtual hosts.
No comments:
Post a Comment