一、Apache创建虚拟目录
题目要求:
1、配置网站主目录为/www/netdj
2、配置访问日志路径和名称为/var/log/httpd/www1.chinaskills.net-access_log
实验步骤:
1、创建网站主目录并创建测试文件
[root@localhost /]# mkdir -p /www/netdj/
[root@localhost /]# cd /www/netdj/
[root@localhost netdj]# touch index.html
[root@localhost netdj]# echo "this is test web" >> index.html
2、创建虚拟配置文件
[root@localhost /]# cat /etc/httpd/conf.d/vhost.conf
<VirtualHost 192.168.199.142:80>
ServerAdmin root@localhost
DocumentRoot "/www/netdj/"
ServerName www2.chinaskills.net
CustomLog "/var/log/httpd/www1.chinaskills.net-access_log" common
</VirtualHost>
<Directory "/www/netdj/">
AllowOverride None
Require all granted
</Directory>
3、关闭selinux
[root@localhost /]# setenforce 0
4、防火墙放行http服务端口
[root@localhost /]# firewall-cmd --add-port=80/tcp --permanent
success
[root@localhost /]# firewall-cmd --reload
success
5、启动服务
[root@localhost /]# systemctl restart httpd
[root@localhost /]# systemctl enable httpd
6、测试服务
[root@localhost ~]# curl www2.chinaskills.net
this is test web