因为是问题、花时间、所以进行记录一番

(一)安装环境:虚拟机centos7系统

对于nginx在linux下的安装卸载是装了又卸,卸了又装。远程访问就是访问不了,周五的时候能访问,到后面又不能访问了。其实这里可以有些方法的。

(二)验证nginx是否安装成功

首先根据这篇文章进行安装,使用源的方式安装:

(三)本地机器测试nginx是否能正常启动

所谓的本地机器,就是你安装了nginx软件的那一台机器,输入命令:

curl http://192.168.241.129/

这里的ip地址为你本机的ip地址

然后会有结果:

[root@localhost nginx-1.12.1]# curl http://192.168.241.129/

Welcome to nginx!

body {

width: 35em;

margin: 0 auto;

font-family: Tahoma, Verdana, Arial, sans-serif;

}

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and

working. Further configuration is required.

For online documentation and support please refer to

nginx.org.

Commercial support is available at

nginx.com.

Thank you for using nginx.

[root@localhost nginx-1.12.1]#

以上验证了本地是已经安装成功的了,

但是我们远程访问的时候就是访问不了,一直说拒绝访问,那就是可能真的跟端口,防火墙有关了。

(四)防火墙、端口开启设置

打开80端口:

(1)

vi /etc/sysconfig/iptables

(2)

-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT

如图:

image.png

image.png

(五)远程访问:

image.png

(六)以下是整个成功安装的过程:

[root@localhost nginx-1.12.1]# ip addr

1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

inet 127.0.0.1/8 scope host lo

valid_lft forever preferred_lft forever

inet6 ::1/128 scope host

valid_lft forever preferred_lft forever

2: ens33: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

link/ether 00:0c:29:ac:77:31 brd ff:ff:ff:ff:ff:ff

inet 192.168.241.129/24 brd 192.168.241.255 scope global dynamic ens33

valid_lft 1732sec preferred_lft 1732sec

inet6 fe80::5afb:ed05:b1f5:5d3a/64 scope link

valid_lft forever preferred_lft forever

[root@localhost nginx-1.12.1]# systemctl start firewalld.servic

Failed to start firewalld.servic.service: Unit not found.

[root@localhost nginx-1.12.1]# curl http://192.168.241.129/

Welcome to nginx!

body {

width: 35em;

margin: 0 auto;

font-family: Tahoma, Verdana, Arial, sans-serif;

}

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and

working. Further configuration is required.

For online documentation and support please refer to

nginx.org.

Commercial support is available at

nginx.com.

Thank you for using nginx.

[root@localhost nginx-1.12.1]# vi /etc/sysconfig/iptables

[root@localhost nginx-1.12.1]# cd /etc/sysconfig/iptables

bash: cd: /etc/sysconfig/iptables: No such file or directory

[root@localhost nginx-1.12.1]# netstat -anop | grep 80

tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2226/nginx: master off (0.00/0/0)

unix 2 [ ACC ] STREAM LISTENING 13780 1/systemd /run/lvm/lvmpolld.socket

unix 3 [ ] STREAM CONNECTED 14680 496/systemd-journal /run/systemd/journal/stdout

unix 2 [ ] DGRAM 104613 48094/su

unix 3 [ ] STREAM CONNECTED 20180 1278/master

unix 2 [ ] DGRAM 19137 1280/qmgr

[root@localhost nginx-1.12.1]# netstat -anop | grep 80

tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2226/nginx: master off (0.00/0/0)

unix 2 [ ACC ] STREAM LISTENING 13780 1/systemd /run/lvm/lvmpolld.socket

unix 3 [ ] STREAM CONNECTED 14680 496/systemd-journal /run/systemd/journal/stdout

unix 2 [ ] DGRAM 104613 48094/su

unix 3 [ ] STREAM CONNECTED 20180 1278/master

unix 2 [ ] DGRAM 19137 1280/qmgr

[root@localhost nginx-1.12.1]# curl http://192.168.241.129/

Welcome to nginx!

body {

width: 35em;

margin: 0 auto;

font-family: Tahoma, Verdana, Arial, sans-serif;

}

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and

working. Further configuration is required.

For online documentation and support please refer to

nginx.org.

Commercial support is available at

nginx.com.

Thank you for using nginx.

[root@localhost nginx-1.12.1]# sudo yum install iptables-services

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

* base: mirror.lzu.edu.cn

* extras: mirrors.cn99.com

* updates: mirrors.cn99.com

Resolving Dependencies

--> Running transaction check

---> Package iptables-services.x86_64 0:1.4.21-24.1.el7_5 will be installed

--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================

Package Arch Version Repository Size

================================================================================================================

Installing:

iptables-services x86_64 1.4.21-24.1.el7_5 updates 51 k

Transaction Summary

================================================================================================================

Install 1 Package

Total download size: 51 k

Installed size: 25 k

Is this ok [y/d/N]: y

Downloading packages:

iptables-services-1.4.21-24.1.el7_5.x86_64.rpm | 51 kB 00:00:00

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

Installing : iptables-services-1.4.21-24.1.el7_5.x86_64 1/1

Verifying : iptables-services-1.4.21-24.1.el7_5.x86_64 1/1

Installed:

iptables-services.x86_64 0:1.4.21-24.1.el7_5

Complete!

[root@localhost nginx-1.12.1]# vi /etc/sysconfig/iptables

[root@localhost nginx-1.12.1]# systemctl stop firewalld

[root@localhost nginx-1.12.1]# systemctl stop iptalbes

Failed to stop iptalbes.service: Unit iptalbes.service not loaded.

[root@localhost nginx-1.12.1]# vi /etc/selinux/config

[root@localhost nginx-1.12.1]# curl http://192.168.241.129/

Welcome to nginx!

body {

width: 35em;

margin: 0 auto;

font-family: Tahoma, Verdana, Arial, sans-serif;

}

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and

working. Further configuration is required.

For online documentation and support please refer to

nginx.org.

Commercial support is available at

nginx.com.

Thank you for using nginx.

[root@localhost nginx-1.12.1]#

nginx服务器远程无法访问,nginx首次安装远程无法访问相关推荐

  1. nginx服务器网站文件存放处,Nginx服务器安装部署

    获取新版本的Nginx服务器 Nginx的官方下载网站为http://nginx.org/en/download.html .进入网站可以看到三种版本,开发版本(Development version ...

  2. nginx服务器网站目录浏览,Nginx开启目录浏览功能 | 系统运维

    说明:Nginx在默认安装好之后,是禁止目录浏览的,如下图所示 系统运维 www.osyunwei.com 温馨提醒:qihang01原创内容版权所有,转载请注明出处及原文链接 http://www. ...

  3. 向nginx服务器上传文件,Nginx搭建上传服务器

    使用 Nginx Upload Module 上传文件 安装编译环境:yum -y install gcc gcc-c++kernel-devel 创建目录:mkdir /tmp/nginx 进入目录 ...

  4. 宝塔修改Nginx服务器类型,宝塔面板nginx更改日志格式的方法

    宝塔默认的日志格式比较简单,可能有些站长需要自定义日志格式,而不知道从何下手,其实这个就是简单的定义nginx的过程 只是宝塔的nginx配置文件存放位置与一般nginx不一样 宝塔存放nginx配置 ...

  5. nginx服务器缓存文件清理,清除nginx缓存文件并不总是有效

    我运行nginx服务器+ PHP webservices API.我使用nginx的fastcgi_cache来缓存所有GET请求,当更新某些资源时,我清除一个或多个相关的缓存资源. 我用来执行此操作 ...

  6. nginx服务器查看日志文件,nginx服务器中access_log日志分析与配置详解

    前言 nginx的log日志分为:access log 和 error log 其中access log 记录了哪些用户,哪些页面以及用户浏览器.ip和其他的访问信息 error log 则是记录服务 ...

  7. 修改thinkphp配置nginx服务器,thinkphp5.0配置nginx重写规则

    thinkphp5.0配置nginx重写规则 2018年07月06日 09:29:03阅读数:1529 server { listen 80; #端口号 server_name demo.aa.com ...

  8. matlab访问被拒绝,安装MATLAB拒绝访问问题的解决方法

    我在安装Matlab R2009a的时候总是出现拒绝访问的问题 我在网上查找解决方案全都无效 现在总算找到了问题所在,我发现很早就有这个问题了就是没有解决的方法 所以我把我自己的解决方法贴出来,希望对 ...

  9. Nginx 服务器 SSL 证书安装部署

    问题描述: 小编遇到https协议过期了,于是重新申请,在Nginx服务器部署SSL证书 安装步骤 1.准备工作 在 SSL 证书管理控制台 中下载并解压缩 cloud.tencent.com 证书文 ...

最新文章

  1. 程序员持续成长,需要持久而痛苦的学习
  2. 借鉴丰田方法对大型软件组织进行敏捷改造 (上)
  3. 面试官:给我说一下 Spring MVC 拦截器的原理?
  4. KMP POJ 3461 Oulipo
  5. JS中对象创建的五中方式
  6. MySQL 复制滞后怎么办?
  7. 朋友圈9宫格留白_九宫格招聘拼图图片
  8. python字典元素的值是否相等_对Python中等值和大小比较
  9. 速达数据库服务器密码修改,速达,管家婆SQL Server帐套密码PJ方法 -电脑资料
  10. c++八大排序算法详解
  11. IQ不平衡数字域校准方案
  12. android ios开发难度对比,ios VS android:这不就是简洁与复杂最明显的对比
  13. 马步站桩-快速健身法 程序员朋友们 注意身体
  14. Centos7__CA认证
  15. 背景颜色渐变 background
  16. 华为机试在线训练-牛客网(20)【中级】字符串运用-密码截取
  17. 30天自制操作系统 (一个操作系统的实现)
  18. cf四大服务器位置,CF:从最初的42个服务器到现在的四大战区,穿越火线还能火多久?...
  19. 卷积神经网络及其在图像处理中的应用
  20. [Markdown] 如何隐藏某些内容

热门文章

  1. 复现经典:《统计学习方法》第 2 章 感知机
  2. 深入了解数据人才 | 中国数据人才白皮书
  3. 技术宝典 | ToB 业务场景下自动化测试的实践及探索
  4. 浅谈分布式 ID 的实践与应用
  5. 音视频通话:小议音频处理与压缩技术
  6. 【OCP-052】052考试题库一变再变,完整题库收集整理-第15题
  7. bash builtin eval
  8. 多线程-NSOperation
  9. Lexus OpenCart 自适应主题模板 ABC-0017
  10. Httpwatch 工具介绍