Linux – how to run Tomcat without using port 8080

linuxtomcat

I need to host and run tomcat without using an arbitrary port. How do I do it.

Best Answer

You have not specified your Linux version, Tomcat version and whether or not you are using the "system" Tomcat [ the version that installs via the package manager ].

I will answer on the assumption that you are on a recent edition of Ubuntu and using a Tomcat 6 that has been installed via the package manager.

  1. Edit /etc/tomcat6/server.xml and change the port from 8080 to 80 in the line that starts with 'Connector port="8080" protocol="HTTP/1.1" ...'. If you are using HTTPS, you may also need to change the port for that from 8443 to 443 ( same file, the connector specification starts with 'Connector port="8443"...'. If you change this, also change the redirect port in the first connector to 443.
  2. Edit /etc/default/tomcat6 and change “#AUTHBIND=no” to “AUTHBIND=yes”. If you do not do this, the Tomcat will not be allowed by the OS to bind to ports 80 and 443 when it is started as the tomcat6 user. Ports with numbers below 1024 are considered "privileged" and can ordinarily only be bound to by processes running with root user privileges. Authbind allows processes running as non-root users to bind to privileged ports.
  3. Restart tomcat (“sudo /etc/init.d/tomcat6 restart”)

If your system differs significantly from my assumed system, comment and I may be able to adapt this answer.