客户那边有台服务器同一个局域网中都无法访问,排除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 ]

linux打开端口的更多相关文章

  1. Linux 打开端口方法

    关闭防火墙:service iptables stop 开启防火墙:service iptables start 防火墙状态:service iptables status 永久关闭:chkconfi ...

  2. linux打开80端口及80端口占用解决办法

    linux打开80端口天客户那边有台服务器同一个局域网中都无法访问,排除lamp环境问题,发现时服务器中的防火墙没有开启80端口. 代码如下 复制代码vi /etc/sysconfig/iptable ...

  3. Linux打开防火墙telnet端口

    检查端口情况:netstat -an | grep 22 关闭端口号:iptables -A INPUT -p tcp --drop 端口号-j DROP                    ipt ...

  4. 查看Linux下端口占用情况的命令

    在使用Linux系统的过程中,有时候会遇到端口被占用而导致服务无法启动的情况.比如HTTP使用80端口,但当启动Apache时,却发现此端口正在使用. 这种情况大多数是由于软件冲突.或者默认端口设置不 ...

  5. linux 查看端口被占用

    linux 查看端口被占用 1.lsof  -i : 端口号 用于查看某一端口的占用情况,比如查看8080端口使用情况,lsof  -i:8080 如果执行 lsof  -i:8080 系统提示 :  ...

  6. Linux通过端口转发来访问内网服务(端口转发访问阿里云Redis数据库等服务)

    # 安装rinetd wget http://www.boutell.com/rinetd/http/rinetd.tar.gz&&tar -xvf rinetd.tar.gz& ...

  7. window与linux查看端口被占用

    本文摘写自: 百度经验 https://www.cnblogs.com/ieayoio/p/5757198.html 一.windows:开始---->运行---->cmd,或者是wind ...

  8. linux 常用端口【转载】

    原文地址: http://blog.csdn.net/u013943420/article/details/65938696 一个计算机最多有65535个端口,端口不能重复.这65536个端口被分为两 ...

  9. windows、Linux 开放端口

    一.Linux开放端口: 1. CentOS7.x/RedHat7.x  , 参考 CentOS7使用firewalld打开关闭防火墙与端口 1.firewalld的基本使用 启动: systemct ...

随机推荐

  1. android + javascript 相互通信实例分析

    1.  AndroidManifest.xml中必须使用许可 "android.permission.INTERNET", 否则会出Web page not available错误 ...

  2. ant风格是什么?

    我们在看java技术书籍的过程中,当加载文件时总会遇到是否支持ant风格路径加载,这里说的ant风格是什么意思呢,今天我查了一下,明白了什么意思,现在总结一下 ANT通配符有三种: 通配符 说明 ? ...

  3. ASP.NET MVC 开源项目学习之ProDinner (一)

    首先在github上面将ProDinner项目通过 Git Bash 克隆到本地,接下来我们开始分析这个项目吧~ 系统采用.Net 4.5, Asp.net Mvc 5,VS2012,Sql serv ...

  4. H264转成RGB24格式-2016.01.21

    #include "libavcodec/avcodec.h" #include "libswscale/swscale.h" #include "l ...

  5. 网站性能优化(Yahoo 35条)

    Yahoo 网站性能优化 35条 一.内容部分 尽量减少 HTTP请求 减少 DNS查找 避免跳转 缓存 Ajxa 推迟加载 提前加载 减少 DOM元素数量 用域名划分页面内容 使 frame数量最少 ...

  6. PHP:PHP页面编码问题(转载)

    MySQL数据库编码.html页面编码.PHP或html文件本身编码要全部一致. 1.MySQL数据库编码:建立数据库时指定编码(如gbk_chinese_ci),建立数据表.建立字段.插入数据时不要 ...

  7. hdu2093

    #include <stdio.h> #include <string.h> #include <algorithm> #include <math.h> ...

  8. C++ streambuf用法

    class LogStreamBuf : public std::streambuf { public: // REQUIREMENTS: "len" must be >= ...

  9. 火狐浏览器设置placeholder的时候记得改opacity

    最近做项目的时候涉及到需要修改输入框的placeholder的字体颜色,我的CSS如下: ::-webkit-input-placeholder{ color: #c5c5c5;}::-moz-pla ...

  10. IIS 7.5 配置Asp+Access的几点注意的地方

    环境:window2008 R2 + iis 7.51 把网站程序放在一个www文件夹里面,给这个文件夹添加everyone的用户,赋予全部读写权限,这样安全些.2 选中要配置的网站,点击页面中间“A ...