linux 下tomcat修改端口
2013-12-20 10:27
459 查看
Ubuntu Server 12.04 安装tomcat6和mysql
$ sudo apt-get install sysv-rc-conf tomcat6 mysql-server
$ sudo ufw allow 80/tcp
$ sudo sysv-rc-conf tomcat6 on
修改tomcat端口,我们似乎都知道在这里把8080改成80:
$ sudo vi /etc/tomcat6/server.xml
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
URIEncoding="UTF-8"
redirectPort="8443" />
网上很多文章写到这里就完事了,但其实改完后tomcat根本不工作,TCP监听端口里没有80,而恢复到8080就好用。原来,从ubuntu10.04起,默认是关闭1024以下端口的,还需要修改以下文件:
$ sudo vi /etc/default/tomcat6
# 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
改成AUTHBIND=yes
$ sudo service tomcat6 restart
$ ss -ln
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 50 127.0.0.1:3306 *:*
LISTEN 0 100 *:80 *:*
LISTEN 0 128 :::22 :::*
LISTEN 0 128 *:22 *:*
LISTEN 0 1 127.0.0.1:8005 *:*
$
现在好了。
参考 http://alanjiang.iteye.com/blog/737563
对于Centos6,是另一种情况,系统不允许tomcat用户使用1024以下的端口。所以除了修改 /etc/tomcat6/server.xml,还有这个文件:
# vi /etc/tomcat6/tomcat6.conf
# What user should run tomcat
TOMCAT_USER="tomcat"
# Connector port is 8080 for this tomcat6 instance
CONNECTOR_PORT="8080"
将上面两行改为
TOMCAT_USER="root"
CONNECTOR_PORT="80"
就可以了。但是这样做的安全性怎么样还不清楚,我觉得比较理想的是 Tomcat与Apache HTTPD的集成,感兴趣就搜一下吧。
参考
http://xuejiayue.iteye.com/blog/88370 http://www.cnblogs.com/gnorts/archive/2010/11/24/1886771.html
本文出自 “An old newbie” 博客,请务必保留此出处/article/7269488.html
$ sudo apt-get install sysv-rc-conf tomcat6 mysql-server
$ sudo ufw allow 80/tcp
$ sudo sysv-rc-conf tomcat6 on
修改tomcat端口,我们似乎都知道在这里把8080改成80:
$ sudo vi /etc/tomcat6/server.xml
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
URIEncoding="UTF-8"
redirectPort="8443" />
网上很多文章写到这里就完事了,但其实改完后tomcat根本不工作,TCP监听端口里没有80,而恢复到8080就好用。原来,从ubuntu10.04起,默认是关闭1024以下端口的,还需要修改以下文件:
$ sudo vi /etc/default/tomcat6
# 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
改成AUTHBIND=yes
$ sudo service tomcat6 restart
$ ss -ln
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 50 127.0.0.1:3306 *:*
LISTEN 0 100 *:80 *:*
LISTEN 0 128 :::22 :::*
LISTEN 0 128 *:22 *:*
LISTEN 0 1 127.0.0.1:8005 *:*
$
现在好了。
参考 http://alanjiang.iteye.com/blog/737563
对于Centos6,是另一种情况,系统不允许tomcat用户使用1024以下的端口。所以除了修改 /etc/tomcat6/server.xml,还有这个文件:
# vi /etc/tomcat6/tomcat6.conf
# What user should run tomcat
TOMCAT_USER="tomcat"
# Connector port is 8080 for this tomcat6 instance
CONNECTOR_PORT="8080"
将上面两行改为
TOMCAT_USER="root"
CONNECTOR_PORT="80"
就可以了。但是这样做的安全性怎么样还不清楚,我觉得比较理想的是 Tomcat与Apache HTTPD的集成,感兴趣就搜一下吧。
参考
http://xuejiayue.iteye.com/blog/88370 http://www.cnblogs.com/gnorts/archive/2010/11/24/1886771.html
本文出自 “An old newbie” 博客,请务必保留此出处/article/7269488.html
相关文章推荐
- Tomcat的server.xml工作流程
- tomcat 默认项目设置
- tomcat启动后台异常Error starting static Resources分析
- Tomcat安装问题
- VisualVM远程监控配置+Tomcat apr 安装+Tomcat 启动脚本
- Tomcat 7 部署 Solr 4.6.0
- 远程debug项目
- 部署项目到远程服务器
- 为tomcat页面设置访问权限(BASIC认证)
- 阿里云,CentOS下yum安装mysql,jdk,tomcat
- Win7下安装配置tomcat,java运行环境
- tomcat配置内存
- apache+tomcat集群03 mod_JK
- java项目部署到tomcat的常见问题
- 如何区分JDK,Tomcat,eclipse的32位与64版本
- tomcat 报错:严重: BAD packet signature 18245(转)
- 纯净版eclipse添加web支持,配置tomcat
- 关于tomcat默认页面的设置!!!
- tomcat配置的另一种简单方式!!
- nginx+tomcat