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

    1.改网卡名 先vim /etc/sysconfig/grub:GRUB_TIMEOUT=5GRUB_DEFAULT=savedGRUB_DISABLE_SUBMENU=trueGRUB_TERMIN ...

  2. MFC六大核心机制之一:MFC程序的初始化

    很多做软件开发的人都有一种对事情刨根问底的精神,例如我们一直在用的MFC,很方便,不用学太多原理性的知识就可以做出各种窗口程序,但喜欢钻研的朋友肯定想知道,到底微软帮我们做了些什么,让我们在它的框架下 ...

  3. (笔记)angular 单选选项卡

  4. Android IOS WebRTC 音视频开发总结(三四)-- windows.20150706

    最近好不容易更新了PC版的WEBRTC,总结下有哪些调整,文章来自博客园RTC.Blacker,支持原创,转载请说明出处. 图1:解决方案工程结构对比: 说明: 1, 最大的调整就是移除了VideoE ...

  5. SQLserver2012 修改数据库架构

    还原数据库以后,发现有一张表的架构不对,执行sql提示:对象名无效.

  6. Python-2.7.11+Django-1.9.4安装配置

    1.去python官网下载2.7的最新版本 https://www.python.org/downloads 1.1 解压Python-2.7.11.tgz tar xvf Python-2.7.11 ...

  7. windows phone上下文菜单ContextMenu的使用示例

    新建一个WP项目,命名为contextmenu,然后往界面拖入一个ListBox控件listBox1,接着切换到XAML代码界面设置其属性,代码如下 <ListBox Height=" ...

  8. <b>和<strong>标签区别

    简单说, strong是web标准中xhtml的标签,加强语气,起强调作用(默认是采用加粗来实现强调),逻辑标签: b 是html的,bold粗体. web标准主张xhtml不涉及具体的表现形式,“强 ...

  9. 《第一行代码--Android》阅读笔记之数据持久化

    1.升级数据库 为了避免手工清空数据(或卸载重装APP),重写SQLiteOpenHelper里面的onUpgrade()方法   引用自http://blog.csdn.net/longvslove ...

  10. Eruda——手机网页前端调试面板

    前言 进行移动端网页开发时,想要查看手机浏览器信息从来都不是一件容易的事.特别是当目标环境为APP内置WebView,需要调用特定的JsBridge接口时,你根本都干不了什么,只能一遍又一遍地修改代码 ...