前些天安装了Nginx,为了好玩我就又安装Apache,Apache的安装还算顺利。在此作一下学习记录和经验分享。css
一、先查看一下系统有没有已经安装了httpd的,若是啥都没查到,那就是没安装呗。若是有#rpm -e 查到的rpm报名,进行删除便可。html
#rpm -qa | grep httpd
二、我这里就直接使用yum安装了(会自动安装依赖包),为了简单方便。mysql
yum -y install httpd
三、httpd -v 查看安装版本,安装成功以后,查找配置文件位置,对httpd进行配置sql
#find / -name "httpd.conf"
四、固然,最好将原有配置文件备份一份如:vim
#cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.origin
一、特别是要注意这个配置,这是Apache 2.4的一个新的默认值,拒绝全部的请求!centos
<Directory />
AllowOverride none
Require all denied
</Directory> 浏览器
把none改成ALL, centos里用的是vi或vim进行编辑,在指令模式下输入/要查询的内容,enter,能够进行内容的查找,而后对其进行修改。(vim查找教程:http://jingyan.baidu.com/article/219f4bf793a0c2de442d38f1.html)服务器
二、配置WEB站点tcp
如个人网站页面文件为默认的ide
Listen 8080
<VirtualHost *:8080>
DocumentRoot "/var/www/html"
ServerName localhost:8080
<Directory "/var/www/html">
AllowOverride All
Options FollowSymLinks Includes ExecCGI
Require all granted
</Directory>
</VirtualHost>
三、添加防火墙端口
我这使用的是centos7默认的firewall防火墙,添加8080端口。
#firewall-cmd --permanent --zone=public --add-port=8080-8081/tcp --永久添加端口
#fire-cmd --permanent --zone=public --list-ports --查看开启端
#systemctl restart firewalld.service //修改配置后须要重启服务使其生效
固然,若是你使用的云服务器,那么还须要在控制台添加端口支持(我在mysql的安装和配置中有谈到这个问题)
四、测试
在本身window的浏览器上输入192.168.x.x:8080/index.html便可解析出在服务器路径中html文件了。