How to install and configure tomcat 6 in ubuntu server
Tomcat is a well known and widely used java servlet container. These
days I am planning a project, which needs a tomcat 6 in ubuntu server. I
found that to make tomcat work in ubuntu is very easy, but you need
have a little trick to change your server listening port from 8080 to
80. Here I give you the way that I make it work.
1. Install tomcat 6 in ubuntu
normally, you just need to type the following command to install it
2. Start tomcat
Usually, HTTP server works with the port 80, but the default port for tomcat is 8080, that is why we need specify 8080 after your ip address. To change the default port from 8080 to 80, type the following command in the terminal:
Find the line contains the following content:
Change it to
Now restart your tomcat server, you will find the following error if you browse your tomcat log in /var/log/tomcat6/catalina_<your date>.log:
This is because you dont have the permission to use the port number lower than 1024 in ubuntu. To make it happen, open the /etc/default/tomcat6 file:
Find the text:
uncomment the last line and change it to
Save it, and restart your tomcat
Now you can access your server with the address:
1. Install tomcat 6 in ubuntu
normally, you just need to type the following command to install it
sudo apt-get install tomcat6 tomcat6-admin tomcat6-common tomcat6-user tomcat6-docs tomcat6-examples
2. Start tomcat
sudo /etc/init.d/tomcat6 start
Now, you can use your browser to navigate this address:http://<your ip>:8080
And you will see the tomcat It works! pageUsually, HTTP server works with the port 80, but the default port for tomcat is 8080, that is why we need specify 8080 after your ip address. To change the default port from 8080 to 80, type the following command in the terminal:
sudo vim /etc/tomcat6/server.xml
Find the line contains the following content:
<Connector port="8080" protocol=...
Change it to
<Connector port="80" protocol=...
Now restart your tomcat server, you will find the following error if you browse your tomcat log in /var/log/tomcat6/catalina_<your date>.log:
SEVERE: Error starting endpoint java.net.BindException: Permission denied <null>:80
This is because you dont have the permission to use the port number lower than 1024 in ubuntu. To make it happen, open the /etc/default/tomcat6 file:
sudo vim /etc/default/tomcat6
Find the text:
# If you run Tomcat on port numbers that are all higher than 1023, then you # do not need authbind. It is used for binding Tomcat to lower port numbers. # NOTE: authbind works only with IPv4. Do not enable it when using IPv6. # (yes/no, default: no) #AUTHBIND=no
uncomment the last line and change it to
AUTHBIND=yes
Save it, and restart your tomcat
sudo /etc/init.d/tomcat6 start
Now you can access your server with the address:
http://<your ip>