CentOS 7 配置apache虚拟目录

一、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

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值