Linux opens port 80
Day client There is a server in the same LAN can not access, eliminate the lamp environment problem, found that the firewall in the server did not open 80 ports. So I went to search the web and saw a way to add code to the script house.
The code is as follows |
Copy Code |
Vi/etc/sysconfig/iptables -A input-m state–state new-m tcp-p tcp–dport 80-j (allow 80 ports through the firewall) -A input-m state–state new-m tcp-p tcp–dport 3306-j (Allow 3306 ports through the firewall) |
In this way, you can find that when you restart the firewall, you return both lines of error.
[Root@localhost ~]#/etc/init.d/iptables Restart
Iptables: Clear Firewall rules: [OK]
Iptables: Set the chain as policy accept:filter [OK]
Iptables: Uninstalling module: [OK]
Iptables: Applying firewall rules: bad argument ' –-state '
Error occurred at Line:11
Try ' iptables-restore-h ' or ' Iptables-restore--help ' for the more information.
[Failed]
Finding this method does not make sense, try another way to add a port by command.
The code is as follows |
Copy Code |
[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 |
That's it, look at the effect.
The code is as follows |
Copy Code |
[Root@centos httpd]#/etc/init.d/iptables Status |
Linux start Apache error: 80 Port occupied solution
Apache starts the error address already in Use:make_sock:could don't bind to address [::]:80
#/ETC/INIT.D/HTTPD Start
Starting httpd: (+) address already in use:make_sock:could don't bind to address [::]:80
(98) Address already in use:make_sock:could don't bind to address 0.0.0.0:80
No listening sockets available, shutting down
Unable to open logs
[FAILED]
The code is as follows |
Copy Code |
1.netstat-lnp|grep 80 TCP 0 0 192.168.180.68:61027 0.0.0.0:* LISTEN 6289/oproxyd TCP 0 0:: £ º::* LISTEN 846/HTTPD TCP 0 0:: ffff:192.168.180.68:7001:::* LISTEN 32015/java Find PID 846 #ps 846 View #kill-9 846 Kill #./apachectl start |
Start successful
*****************************************************************************
Treatment methods:
The code is as follows |
Copy Code |
# 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] |