linux打開80端口及80端口占用解決辦法


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
這樣就搞定了,查看效果
代碼如下 復制代碼
[root@centos httpd]# /etc/init.d/iptables status

 

 

Linux下啟動apache報錯:80端口已占用解決辦法

apache啟動報錯(98)Address already in use: make_sock: could not bind to address [::]:80
# /etc/init.d/httpd start
Starting httpd: (98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
[FAILED]
代碼如下 復制代碼
1.netstat -lnp|grep 80
tcp 0 0 192.168.180.68:61027 0.0.0.0:* LISTEN 6289/oproxyd
tcp 0 0 :::80 :::* LISTEN 846/httpd
tcp 0 0 ::ffff:192.168.180.68:7001 :::* LISTEN 32015/java
找到pid 846
#ps 846
查看
#kill -9 846
殺掉
#./apachectl start
啟動成功
*****************************************************************************
處理辦法:
代碼如下 復制代碼
# ps -aux | grep http
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ
root 12079 0.0 0.0 61164 720 pts/1 S+ 16:06 0:00 grep http
# ps -aux | grep apache
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ
apache 10820 0.0 0.0 2044 600 ? Ss Jan01 0:04 bash
root 12081 0.0 0.0 61160 716 pts/1 S+ 16:06 0:00 grep apache
# kill -9 10820
# /etc/init.d/httpd start
Starting httpd: [ OK ]
# /etc/init.d/httpd restart
Stopping httpd: [ OK ]


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM