linux中如何把端口号改变,linux系统如何修改端口号
一、修改/etc/httpd/conf/httpd.conf文件中的监听端口号Listen 80把80修改成需要的号,如8000,即Listen 8000二、查看SELinux下http相关端口# semanage port -l|grep httphttp_cache_port_t tcp 3128, 8080, 8118, 10001-10010http_cache_port_t udp 31
一、修改/etc/httpd/conf/httpd.conf文件中的监听端口号
Listen 80
把80修改成需要的号,如8000,即
Listen 8000
二、查看SELinux下http相关端口
# semanage port -l|grep http
http_cache_port_t tcp 3128, 8080, 8118, 10001-10010
http_cache_port_t udp 3130
http_port_t tcp 80, 443, 488, 8008, 8009, 8443
pegasus_http_port_t tcp 5988
pegasus_https_port_t tcp 5989
发现8000不在其范围之内,所以需要另外添加,方法如下:
# semanage port -a -t http_port_t -p tcp 8000
再次查看,
# semanage port -l|grep http
http_cache_port_t tcp 3128, 8080, 8118, 10001-10010
http_cache_port_t udp 3130
http_port_t tcp 8000, 80, 443, 488, 8008, 8009, 8443
pegasus_http_port_t tcp 5988
pegasus_https_port_t tcp 5989
三、在防火墙中开放新添加的端口
修改/etc/sysconfig/iptables文件,在文件中添加如一行:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8008 -j ACCEPT
四、重启防火墙和Apache
# service iptables restart
# service httpd restart
五、正常情况下,应该可以通过新端口访问WEB服务了。
注:
1、第二、三、四步骤是在系统已经开启SELinux和防火墙的情况下设置的,如果已经关闭此两个服务,修改端口后直接重启Apache即可;
2、修改的端口号可以是执行#semanage port -l|grep http后,默认已经有的端口,如8443,这样可以省略额外添加SELinux端口操作;
3、第三步操作可以图形界面下完成。
参考资料
1、Permission denied: make_sock: could not bind to address
http://www.doczj.com/doc/95b2361ca8114431b90dd8c0.html/2009/07/permission-denied-makesock-could-not.html
不熟悉python、plone、zope,想用apache。80端口已经不在,就征用81端口凑合吧。修改httpd.conf后apachectl start,结果:
(13)Permission denied: make_sock: could not bind to address [::]:81
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:81
查一下SELinux下http相关端口 semanage port -l|grep http,结果:
http_cache_port_t tcp 3128, 8080, 8118, 10001-10010
http_cache_port_t udp 3130
http_port_t tcp 80, 443, 488, 8008, 8009, 8443
pegasus_http_port_t tcp 5988
pegasus_https_port_t tcp 5989
直接用man semanage最后例子中的一句
# Allow Apache to listen on port 81
semanage port -a -t http_port_t -p tcp 81
然后再apachectl start,OK。使用域名:81能够访问啦。
注:semanage
semanage is used to configure certain elements of SELinux policy without requiring modification to or recompilation from policy sources. This includes the mapping from Linux usernames to SELinux user identities (which controls the initial security context assigned to Linux users when they login and bounds their authorized role set) as well as
更多推荐
所有评论(0)