首页 > 代码库 > 14.Apache配置 正在完善^_^
14.Apache配置 正在完善^_^
环境: ↗ atl.example.com (192.168.1.101)
↗ www.example.com (192.168.1.101)
↗system1.example.com (192.168.1.101)
centos7 (192.168.1.109) dns 服务器 →system2.example.com(192.168.1.105)
↘classroom.example.com(192.168.1.109)
Apache为server端 -> rhel7 server ->(192.168.1.101)(system1.example.com)已设置192.168.1.109为dns解析
其他主机为客户端 -> rhel7 clinet ->(192.168.1.105)(system2.example.com)已设置192.168.1.109为dns解析
1.安装Apache
yum install -y httpd
2.配置防火墙80/tcp对全网开放:firewall-cmd --permanent --add-port=80/tcp && firewall-cmd --reload
或者针对某个ip域开放:firewall-cmd --permanent --add-rich-rule ‘rule family=ipv4 source address=192.168.1.0/24 service name=http accept‘
3.设置开机自启与重新启动:
systemctl enable httpd && systemctl restart httpd
4.设置system1.example.com站点
echo ‘system1.example.com‘ > /var/www/html/index.html
执行systemctl restart httpd 然后再浏览器输入 http://system1.example.com
5.配置虚拟主机www.example.com站点
mkdir /var/www/virtual
cp /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf /etc/httpd/conf.d/
vim /etc/httpd/conf.d/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "/var/www/virtual"
ServerName www.example.com
</VirtualHost>
:x 保存退出
执行systemctl restart httpd 然后再浏览器输入http://www.example.com
6.www.example.com访问控制设置
<VirtualHost *:80>
DocumentRoot "/var/www/virtual"
ServerName www.example.com
<Directory /var/www/virtual>
<RequireAll>
Require all granted
Require not ip 172.25.0.11
</RequireAll>
</Directory>
</VirtualHost>
14.Apache配置 正在完善^_^