1.安装
yum -y install httpd
2.开启apache服务
systemctl start httpd.service
3.设置apache服务开机启动
systemctl enable httpd.service
4.验证apache服务是否安装成功
在浏览器中输入你的主机外网IP地址,若安装成功则会出现一个Apache欢迎页面,有Testing 123…字样,便是成功安装了apache服务了;
如果不能连接上也不用担心,是因为还没有设置防火墙,解决方法:
CentOS7用的是Firewall-cmd,CentOS7之前用的是iptables防火墙;要想让外网能访问到apache主目录,就需要做以下的操作:
firewall-cmd –permanent –zone=public –add-service=http
firewall-cmd –permanent –zone=public –add-service=https
firewall-cmd –reload
如果上述方法不行也可以尝试把firewalld服务关闭换用CentOS 6以前的防火墙服务iptables,具体如下:
systemctl stop firewalld.service //关闭firewalld
systemctl start iptables.service //开启iptables
systemctl enable iptables.service //自启动iptables
还有很重要的一点是,要在你的阿里云服务器安全组里面设置允许外访问,否则无法从外部访问网站
正文完