>yum -y install tomcat7
....
Compile and deploy your webapp / mobile app
Let's make it simple - for example, deploy helloworld.jsp
....
>service tomcat7 status
tomcat7 (pid <...>) is running...
....
Go to web browser / g.g. Google Chrome
http://<IP address or domain name>/helloworld.jsp
For example
http://hastasiempre-ismyfavourite.com
Oops! Google Chrome could not connect to <...>
Darn! I mean, WTF?
Browse some forums. Figure that default port for Tomcat7 to listen on is 8080.
http://<IP address or domain name>:8080/helloworld.jsp
Hell of a world!
Go to .../tomcat7/conf. Edit server.xml with your editor of choice to change ports 8080 and 8443 to 80 and 443 respectively.
http://<IP address or domain name>/helloworld.jsp
Oops! Google Chrome could not connect to <...>
Browse even more forums. Figure out that you need to run tomcat as root to be allowed to use port under 1024. Edit tomcat7.conf with your editor of choice to change TOMCAT_USER="tomcat" to TOMCAT_USER="root".
http://<IP address or domain name>/helloworld.jsp
Hell of a world!
Bingo!
My humble contribution in the form of sed script to switch from port 8080 to 80:
#!/bin/bash
tomcat=tomcat7
tomcat_conf=/usr/share/$tomcat/conf
cd $tomcat_conf
sed -e 's/="8080/="80/g' -e 's/="8443/="443/g' -i $tomcat_conf/server.xml
sed '/Connector port="80"/i\<!-- change user tomcat to root in tomcat7.conf, change ports 8080 and 8443 to 80 and 443 respectively -->/' -i $tomcat_conf/server.xml
sed -e '/TOMCAT_USER=/i\# Switch user from tomcat to root' -e 's/TOMCAT_USER="tomcat"/TOMCAT_USER="root"/' -e 's/="8080/="80/' -i $tomcat_conf/$tomcat.conf
No comments:
Post a Comment