前提:已经配置好静态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. 前端统计图 echarts 实现简单柱状图

    前端统计图   echarts实现简单柱状图 1. 引入 ECharts <!DOCTYPE html> <html> <head> <meta charse ...

  2. mongoDB使用小记

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

  3. Go语言字符串

    Go语言的字符串是一个用UTF-8编码的变宽字符序列,它的每一个字符都用一个或多个字节表示 . 在Go语言中,没有字符类型,字符类型是rune类型,rune是int32的别称.可使用 []byte() ...

  4. stark - 2 ⇲路由分发

    在介绍前面三个注意点后,开始写stark组件内容. from django.apps import AppConfig from django.utils.module_loading import ...

  5. SQL的CharIndex用法

    和C#一样判断一个字符串中是否包含另一个字符串举例1:select charindex('test','This Test is test!!')->返回 6 (空格也算一个 下标从1开始)2: ...

  6. sklearn的train_test_split

    train_test_split函数用于将矩阵随机划分为训练子集和测试子集,并返回划分好的训练集测试集样本和训练集测试集标签. 格式: X_train,X_test, y_train, y_test ...

  7. Oracle SQL Developer 查询时间格式

    工具->首选项->数据库->NLS->日期格式: DD-MON-RR 修改为: YYYY-MM-DD HH24:MI:SS

  8. Canvas 同心圆旋转示例解析

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. post调试postman

    载地址:https://www.getpostman.com/ 教程地址:http://www.cnblogs.com/s380774061/p/4624326.html

  10. springboot+redis实现缓存数据

    在当前互联网环境下,缓存随处可见,利用缓存可以很好的提升系统性能,特别是对于查询操作,可以有效的减少数据库压力,Redis 是一个开源(BSD许可)的,内存中的数据结构存储系统,它可以用作数据库.缓存 ...