admin管理员组

文章数量:1608631

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

(一)安装环境:虚拟机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.

Commercial support is available at

nginx.

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

(五)远程访问:

本文标签: 无法访问首次服务器Nginx