一、检查nginx安装成功
[root@localhost softRyc]# /usr/local/webserver/nginx/sbin/nginx -v
nginx version: nginx/1.21.2
二、配置检查成功
[root@localhost conf]# /usr/local/webserver/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/webserver/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/webserver/nginx/conf/nginx.conf test is successful
三、检查nginx已启动
[root@localhost conf]# ps -ef |grep nginx
root 18239 1 0 11:13 ? 00:00:00 nginx: master process /usr/local/webserver/nginx/sbin/nginx
www 18240 18239 0 11:13 ? 00:00:00 nginx: worker process
www 18241 18239 0 11:13 ? 00:00:00 nginx: worker process
root 18246 14959 0 11:13 pts/2 00:00:00 grep --color=auto nginx
问题:访问对应站点域名失败
http://192.168.XXX.XXX:80
首先想到的是端口被防火墙拦截了
顺利解决,方法如下
1、查看防火墙允许的端口:发现只有8080是放开的
[root@localhost conf]# firewall-cmd --list-ports
8080/tcp
2、查看自己的配置文件:/usr/local/webserver/nginx/conf/nginx.conf中,默认的端口是80
3、将80端口加到防火墙允许的端口
[root@localhost conf]#
[root@localhost conf]# firewall-cmd --permanent --zone=public --add-port=80/tcp
success
[root@localhost conf]#
4、重启下防火墙设置
[root@localhost conf]# firewall-cmd --reload
success
5、再次查看(已添加80端口)
[root@localhost conf]# firewall-cmd --list-ports
8080/tcp 80/tcp
6、再次访问,成功了,问题解决
标签:00,Nginx,--,ip,配置,nginx,conf,root,localhost From: https://www.cnblogs.com/rychh/p/16598174.html