Linux Open 80 port and 80 port occupancy solution

Source: Internet
Author: User
Tags bind centos iptables

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]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.