在Ubuntu上打開Tomcat6的443端口和80端口

How to install and configure tomcat 6 in ubuntu server

 
 
 
 
 
 
 
1 Vote

 


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

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! page

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:
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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值