Archive for the ‘tomcat’ Category

  • Configure tomcat7 to start on port 80

Open /etc/tomcat7/server.xml and locate to the following lines

<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />

Change the port value to 80 as below.

<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
  • Start the tomcat7 as root user

After configuring tomcat7 to start on port 80, if you start the tomcat7 you will get errors in /etc/log/catalina.log file as below

SEVERE: Failed to initialize end point associated with ProtocolHandler ["http-bio-80"]
java.net.BindException: Permission denied <null>:80
at org.apache.tomcat.util.net.JIoEndpoint.bind(JIoEndpoint.java:406)
at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:610)
at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:429)
at org.apache.coyote.http11.AbstractHttp11JsseProtocol.init(AbstractHttp11JsseProtocol.java:119)

The reason for above error is only root users have the permission to start applications on port 80. So lets configure tomcat to start with rot privileges.
So open the file /etc/init.d/tomcat7 and locate to

# Define the tomcat username
TOMCAT_USER="${TOMCAT_USER:-tomcat}"

Then change the TOMCAT_USER to root as below.

# Define the tomcat username
TOMCAT_USER="root"

Please note that the location of the tomcat7 file is dependent of the OS.
Debian wheezy – /etc/default/tomcat7 instead of /etc/init.d/tomcat7
Ubuntu 13.04 – /etc/init.d/tomcat7
Ubuntu 14.04 – /etc/default/tomcat7

Those locations were reported by the viewers commented below

  • Restart the tomcat7
sudo service tomcat7 status

If everything is fine, you will get an output similar to

tomcat7 (pid  24215) is running…

  • Verify tomcat7 running on port 80

You can get the pid of the tomcat7 process from the output of above command which is 24215 in mycase. Using the netstat command you can view what are the ports our tomcat7 process is running on.


sudo netstat -tulpn | grep 24215

If tomcat7 is started on port 80, you will get and output like below.

tcp        0      0 :::80                       :::*                        LISTEN      24215/java