I tried to change the default port on my Tomcat, with 开发者_如何学Cthe server.xml
file, changing 8080
to 80
. But when I try to visit my application, it is not available. What am I doing wrong? Are there some security issues with Amazon EC2?
There are several ways to make Tomcat listen on port 80, but not all of them are available on all flavors of Linux.
For details and pointers, see the section Running Tomcat on port 80 in my series of articles on Tomcat on EC2.
Switch to root user via sudo su -
command. In /usr/share/tomcat7/conf/tomcat7.conf
change TOMCAT_USER="tomcat"
to TOMCAT_USER="root"
. In /usr/share/tomcat7/conf/server.xml
change 8080
to 80
(and also 8443
to 443
if you’re a perfectionist).
Are you running Tomcat as root? Only root can open port 80. Check if can you access the port locally - eg. try wget http://localhost/
. Obviously check also if your security group allows access to port 80, but I expect it does if 8080 was available.
To enable this on AWS for tomcat 7.0.33 I modified server.xml as suggested above.
Then update /etc/tomcat/tomcat.conf.
sudo vi /etc/tomcat/tomcat.conf
change
TOMCAT_USER="tomcat" to "root"
bounce the server with
sudo service tomcat restart
you can use load balancer or set up port forwarding on the linux built in firwall
see this blog
http://charlie.cu.cc/2012/04/how-run-tomcat-port-80-amazon-web-service-aws/
I had the same issue. if you configure the server.xml and open port 80 in ec2 what you have to do is first shutdown the server. be root (sudo su -) and then start the server again and it should work for you.
精彩评论