前提:已经配置好静态IP
以防万一,先安装好iptables服务(不管你装没装,先执行,免得后面添乱)
[root@localhost ~]# yum install iptables-services
[root@localhost ~]# systemctl mask firewalld.service
[root@localhost ~]# systemctl enable iptables.service
[root@localhost ~]# systemctl enable ip6tables.service
进入iptables配置80端口,因为nginx默认是由80端口访问
[root@localhost ~]# vim /etc/sysconfig/iptables
这是配置信息:
# Generated by iptables-save v1.4.21 on Fri May 12 21:28:29 2017
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [6:696]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT(我给vsftpd配置的端口)
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT(给nginx配置的端口,原样输入就行了)
-A INPUT -p tcp -m state --state NEW -m tcp --dport 30000:30999 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
# Completed on Fri May 12 21:28:29 2017
然后:wq,保存退出就行了
重启iptables,配置才生效
[root@localhost ~]# systemctl restart iptables.service
开启防火墙,不管你开没有,再开一遍:
[root@localhost ~]# systemctl start firewalld
开启http访问
[root@localhost ~]# firewall-cmd --permanent --add-service=http
加入80端口
[root@localhost ~]# firewall-cmd --permanent --zone=trusted --add-port=80/tcp
启动nginx!!!!(重点来了!!!)
centOS7的nginx启动与其他的有区别!!!注意:我是装的nginx1.80,在centOS6.X系列中,是通过
cd /usr/local/nginx/sbin/

./nginx

这两条命令启动的。
在Ubuntu中是通过/etc/nginx.....,你会发现你的centOS7里面,etc下面根本就没有nginx这个folder!
在centOS7中你会发现这行不通,我们应该这么启动:
[root@localhost ~]# /usr/local/nginx/sbin/nginx
如果发现:
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
说明80端口被占用,杀掉这个进程:
[root@localhost ~]# killall -9 nginx
再次启动nginx:
[root@localhost ~]# /usr/local/nginx/sbin/nginx
查看是否启动:
[root@localhost ~]# ps aux|grep nginx
输出:
root       7110  0.0  0.0  24348   752 ?        Ss   22:32   0:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody     7111  0.0  0.0  26860  1508 ?        S    22:32   0:00 nginx: worker process
root       7114  0.0  0.0 112664   968 pts/0    S+   22:33   0:00 grep --color=auto nginx
启动成功!
访问nginx
在浏览器地址栏输入你的Linux虚拟机的静态ip,会跳转到nginx的欢迎页面。

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)解决方案的更多相关文章

  1. 修改nignx报错Nginx [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)

    Nginx [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use) 这个错误是修改了nginx的配置时出现,表名80端口被程 ...

  2. nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) 错误解决

    今天在做LNMP的时候,启动nginx服务,无法开启,导致网页打不开.把服务从起一下发现提示错误如下: Starting nginx: nginx: [emerg] bind() to 0.0.0.0 ...

  3. nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address 

    http://blog.csdn.net/ownfire/article/details/7966645 今天在做LNMP的时候,启动nginx服务,无法开启,导致网页打不开.把服务从起一下发现提示错 ...

  4. nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)解决

    nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) 报错信息 nginx: [emerg] bind() t ...

  5. Linux教程之:Nginx [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)

    Nginx [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use) 使用命令关闭占用80端口的程序 sudo fuser - ...

  6. Nginx 学习笔记(七)如何解决nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)

    出现:nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) 错误,有以下两种情况 1.80端口被占用 2.ipv4端 ...

  7. nginx 中出现nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

    有其他的程序占用的80端口.只需把相关程序关闭,fuser -k 80/tcp 然后再次 /usr/local/nginx/sbin/nginx,就能开启nginx服务了

  8. nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) 解决办法

    遇到这个问题,是因为某个服务正在使用80端口; 解决步骤: 1.使用netstat命令查看80端口被哪个服务占用了 netstat -ant | grep 80 1 2.关闭80端口 /etc/ini ...

  9. Nginx [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)

    使用命令关闭占用80端口的程序 sudo fuser -k 80/tcp

随机推荐

  1. XMPP使用tls 和sasl登录

    转自:http://ycool.com/post/xc98m5k 名词解释 TLS:安全传输层协议 TLS:Transport Layer Security 名词: 安全传输层协议(TLS)用于在两个 ...

  2. mongoDB使用小记

    1.简介: MongoDB是由c++语言编写的,基于分布式文件存储的开源数据库系统.MongoDB将数据存储为一个文档,数据结构有键-值对,类似于JSON对象. MongoDB其中的一些概念如下: M ...

  3. 洛谷 P4307 [JSOI2009]球队收益 / 球队预算(最小费用最大流)

    题面 luogu 题解 最小费用最大流 先假设剩下\(m\)场比赛,双方全输. 考虑\(i\)赢一局的贡献 \(C_i*(a_i+1)^2+D_i*(b_i-1)^2-C_i*a_i^2-D_i*b_ ...

  4. 916. Word Subsets

    We are given two arrays A and B of words.  Each word is a string of lowercase letters. Now, say that ...

  5. 街机模拟.samsho2

    1.sdyrugal https://www.douyu.com/599516 2.红中哥:西瓜视频  搜索 "红中哥游戏解说" 我搜索到的地址:https://live.ixig ...

  6. 《大数据日知录》读书笔记-ch3大数据常用的算法与数据结构

    布隆过滤器(bloom filter,BF): 二进制向量数据结构,时空效率很好,尤其是空间效率极高.作用:检测某个元素在某个巨量集合中存在. 构造: 查询: 不会发生漏判(false negativ ...

  7. oracle 中的exists 和 in 效率问题

    oracle中的 exists 和 in 的效率问题 --------------------------------------------------------------- +++++++++ ...

  8. 导入数据到HBase的方式选择

    Choosing the Right Import Method If the data is already in an HBase table: To move the data from one ...

  9. <数据挖掘导论>读书笔记4--其他分类技术

    1.基于规则的分类器 2.最近邻分类器 3.贝叶斯分类器 4.人工神经网络 5.支持向量机 6.组合方法 7.不平衡类问题 8.多类问题

  10. C++公有继承、保护继承和私有继承

    C++中的继承方式有: public.private.protected三种(它们直接影响到派生类的成员.及其对象对基类成员访问的规则). (1)public(公有继承):继承时保持基类中各成员属性不 ...