CentOS/Linux 装载系统的时候只开启了少数端口如22,80(有些连80都没有开放)等。

结果再装完Nginx+PHP+MySQL 后不能访问网站。

当然前提是在nginx.conf中先配置好访问地址

CentOS/Linux开放某些端口

 

现在提供一些解决方案:

1.查看防火墙设置发现没开启所要访问的端口

iptables -L -n

由于Linux防火墙默认是关闭的。可以用两种方式,一个是关闭防火墙(不推荐),另一个就是让防火墙开放这个端口。

 

2.开放某端口 

  1)vi  /etc/sysconfig/iptables 文件

     1.1 开放某端口

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

     1.2 开放一个范围的端口8000到9000

     -A INPUT -p tcp -m state  --state NEW -m tcp --dport 8000:9000 -j ACCEPT

     说明:dport后面的端口根据自己所需加上,访问时采用localhost:端口

     CentOS/Linux开放某些端口

  2)重启iptables

service iptables restart

 

3.重启防火墙,这里有两种方式重启防火墙

  1)重启后生效

     开启: chkconfig iptables on

  关闭: chkconfig iptables off

 

  2)即时生效,重启后失效

    开启: service iptables start

    关闭: service iptables stop

 

相关文章:

  • 2021-11-18
  • 2021-11-20
  • 2022-01-07
  • 2022-01-07
  • 2021-10-26
  • 2022-02-09
  • 2022-12-23
猜你喜欢
  • 2021-11-30
  • 2021-12-24
  • 2022-01-02
  • 2021-11-30
  • 2021-09-29
  • 2022-12-23
  • 2022-02-11
相关资源
相似解决方案