Apache

您所在的位置:网站首页 网站显示已拒绝连接怎么解决 Apache

Apache

#Apache| 来源: 网络整理| 查看: 265

Apache-httpd服务器启动成功网页却不能访问的问题 环境: CentOS 7 。

在 Apache 成功启动后,可能会存在服务已经启动,但是网页却无法访问的情况。如下,查看服务 httpd 是否已经启动。

[centos@localhost ~]$ ps -ef|grep httpd root 2291 1 0 09:02 ? 00:00:00 /usr/local/apache2.4/bin/httpd -k start daemon 3905 2291 0 09:22 ? 00:00:00 /usr/local/apache2.4/bin/httpd -k start daemon 3906 2291 0 09:22 ? 00:00:00 /usr/local/apache2.4/bin/httpd -k start daemon 3907 2291 0 09:22 ? 00:00:00 /usr/local/apache2.4/bin/httpd -k start centos 8446 5647 0 10:27 pts/1 00:00:00 grep --color=auto httpd

可以看到已经成功启动。 这样的情况下可能是防火墙未关闭。 若是其他版本的 CentOS 系统,尝试以下命令:

$ service iptables status //查看防火墙状态 $ service iptables stop //关闭防火墙

请注意 ,CentOS 7 版本默认的防火墙是 firewall ,替代了以前的 iptables 。 firewall 使用更加方便、功能也更加强大一些。 firewalld 服务引入了一个信任级别的概念来管理与之相关联的连接与接口。它支持 ipv4 与 ipv6,并支持网桥,采用 firewall-cmd (command) 或 firewall-config (gui) 来动态的管理 kernel netfilter 的临时或永久的接口规则,并实时生效而无需重启服务。

$ firewall-cmd --version //查看'firewall'版本 0.6.3 //该展示表示防火墙已启动,版本号 FirewallD is not running //该展示代表防火墙未启动

请注意 ,如果系统未查找到,而你又想使用 firewall 管理你的防火墙,可以执行以下安装 firewall 命令,他的安装使用像 iptables 一样:

$ sudo yum install -y firewalld

firewalld 服务的基本使用,firewall 与 iptables 一样都是服务,所以可以使用 systemctl 服务管理工具来操作:

$ systemctl status firewalld //查看防火墙状态 $ systemctl stop firewalld //关闭防火墙,停止'firewall'服务 $ systemctl start firewalld //开启防火墙,启动'firewall'服务 $ systemctl restart firewalld //重启防火墙,重启'firewall'服务

你可以关闭整个防火墙,但这样显然是 危险 的操作,因此可以只开放 80 (要看你的 Apache 使用的默认端口是哪个就开启那个,默认是 80 )端口。

开启一个指定端口: $ firewall-cmd --zone=public --add-port=80/tcp --permanent //--permanent 永久生效,没有此参数重启后失效 重新加载 firewall,修改配置后,必须重新加载才能生效: $ firewall-cmd --reload

完整操作流程,请注意,需要有root的权限或者使用 sudo 命令:

[root@localhost centos]# firewall-cmd --zone=public --list-port //查看已打开的所有端口 3307/tcp [root@localhost centos]# firewall-cmd --zone=public --add-port=80/tcp --permanent success [root@localhost centos]# firewall-cmd --reload success [root@localhost centos]# firewall-cmd --zone=public --list-port 3307/tcp 80/tcp

这里顺便说一下关闭指定端口操作。

# firewall-cmd --zone=public --remove-port=9898/tcp --permanent //--permanent 表示永久生效,没有此参数重启后失效 # firewall-cmd --reload //重新加载使其生效

防火墙操作之后,一般Apache服务就能通过网页正常访问。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3