环境搭建-Apache的安装(Linux)

命令查看是否已经安装了apache服务器httpd

rpm -qa | grep httpd

查看httpd服务是否启动

ps -ef | grep httpd

卸载httpd服务

yum remove httpd

安装httpd服务

yum install httpd -y

查看是否安装成功

yum list installed | grep httpd

 查看配置文件

启动httpd服务

service httpd start

主机无法访问apache解决方法

可能是Linux内置防火墙的限制,需要将tcp端口配置为允许任何ip访问

iptables -I INPUT -p TCP --dport 80 -j ACCEPT

这种方法是临时生效的,需要设置/etc/selinux/config中SELINUX的值

vim /etc/selinux/config

注释掉#SELINUX=enforcing,增加SELINUX=disabled

保存退出,并更改用户运行级别

chkconfig --level 3 iptables off

chkconfig --level 5 iptables off

 输入ip加端口号就能访问到apache默认页面

输入ip加端口号就能访问到apache默认页面

原文地址:https://www.cnblogs.com/katyhudson/p/13413123.html