linux httpd 怎样查看80端口开启没?

linux httpd 怎样查看80端口开启没?,第1张

通过代码查询。

linux打开80端口

天客户那边有台服务器同一个局域网中都无法访问,排除lamp环境问题,发现时服务器中的防火墙没有开启80端口。

代码如下  

vi /etc/sysconfig/iptables

-A INPUT -m state _state NEW -m tcp -p tcp _dport 80 -j ACCEPT(允许80端口通过防火墙) 

-A INPUT -m state _state NEW -m tcp -p tcp _dport 3306 -j ACCEPT(允许3306端口通过防火墙)

按照这种方法测试,发现重启防火墙的时候,回报这两行错误。

[root@localhost ~]# /etc/init.d/iptables restart 

iptables:清除防火墙规则:                                 [确定]

iptables:将链设置为政策 ACCEPT:filter                    [确定]

iptables:正在卸载模块:                                   [确定]

iptables:应用防火墙规则:Bad argument `_-state'

Error occurred at line: 11

Try `iptables-restore -h' or 'iptables-restore --help' for more information.

[失败]

代码如下  

[root@centos httpd]# /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT

[root@centos httpd]# /etc/rc.d/init.d/iptables save

[root@centos httpd]# /etc/init.d/iptables restart

这样就搞定了。

Linux系统查看80端口是否被占用:[root@host ~]# netstat -anp | grep port lsof -i:80

#如果显示有运行程序就会占用了

查看80端口被那个进程占用:

[root@host ~]# netstat -pan | grep :80 tcp0 0

127.0.0.1:80 0.0.0.0:* LISTEN

23903/nginx tcp0 0 0.0.0.0:8081

0.0.0.0:* LISTEN 23509/httpd

然后终止占用80端口该进程的方式:

[root@host ~]# kill pid


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/8384027.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-15
下一篇 2023-04-15

发表评论

登录后才能评论

评论列表(0条)

保存