基本概念
Apache:Apache HTTP服务器项目是为现代操作系统(包括UNIX和Windows)开发和维护开源HTTP服务器的一项工作。该项目的目标是提供一个安全,高效且可扩展的服务器,该服务器提供与当前HTTP标准同步的HTTP服务。
安装与配置
1、指令直接安装
yum install httpd # 中间过程中输入:y
2、修改配置文件:yum的安装位置在:/etc/httpd/conf
# 放掉95行的注释,修改为:ServerName [你的IP]:80
3、启动服务
systemctl start httpd.service
4、关闭服务
systemctl stop httpd.service
5、重启服务
systemctl restart httpd.service
6、设置开机自动启动
chkconfig httpd on
7、验证apache服务是否安装成功
在浏览器中输入你的主机外网IP地址,若安装成功则会出现一个Apache欢迎页面
如果不能连接上,需要设置防火墙
解决方法:
CentOS7用的是Firewall-cmd,CentOS7之前用的是iptables防火墙;要想让外网能访问到apache主目录,就需要做以下的操作:
firewall-cmd –permanent –zone=public –add-service=httpfirewall-cmd –permanent –zone=public –add-service=httpsfirewall-cmd –reload
如果上述方法不行也可以尝试把firewalld服务关闭换用CentOS 6以前的防火墙服务iptables,具体如下:
systemctl stop firewalld.service //关闭firewalldsystemctl start iptables.service //开启iptablessystemctl enable iptables.service //自启动iptables
还有很重要的一点是,要在你的阿里云服务器安全组里面设置允许外访问,否则无法从外部访问网站
参考文章
/leijiahui/article/details/88113196
/qq_41020714/article/details/88080192
/php-weizijiaocheng-403839.html