查看 SELinux状态及关闭SELinux,Linux 打开或关闭防火墙端口

查看SELinux状态:

1、/usr/sbin/sestatus -v      ##如果SELinux status参数为enabled即为开启状态

SELinux status:                 enabled

2、getenforce                 ##也可以用这个命令检查

关闭SELinux:

1、临时关闭(不用重启机器):

setenforce 0                  ##设置SELinux 成为permissive模式

                              ##setenforce 1 设置SELinux 成为enforcing模式

2、修改配置文件需要重启机器:

修改/etc/selinux/config 文件

将SELINUX=enforcing改为SELINUX=disabled

重启机器即可

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

安装tomcat后,在客户端输入地址http://serverAddress:8080,发现默认端口8080不能访问。

  由于Linux防火墙默认是关闭8080端口。因此,若要能够访问8080端口,可以用两种方式,一个是关闭防火墙,另一个就是让防火墙开放8080端口。

  开放8080端口的解决步骤如下:

  1、修改/etc/sysconfig/iptables文件,增加如下一行:

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

       重启        iptables
       service iptables restart

  2、重启防火墙,这里有两种方式重启防火墙

  a) 重启后生效
  开启: chkconfig iptables on
  关闭: chkconfig iptables off

  b) 即时生效,重启后失效
  开启: service iptables start
  关闭: service iptables stop

  再次从客户端访问,成功!

http://bguncle.blog.51cto.com/3184079/957315

http://www.blogjava.net/gdufo/archive/2009/11/17/302717.html

猜你喜欢

转载自oywl2008.iteye.com/blog/2170010
今日推荐