虚拟主机——一台服务器部署多个网站

注:针对一台服务器部署多个网站的应用(这里用的是比较常见的基于域名的虚拟主机)

实现:在同一台服务器上部署两个网站:
www.a.com
www.b.com
这里就展示一个www.b.com的部署

1.配置b.com

[root@centos7 ~]# vim /etc/httpd/conf.d/b.conf
# www.b.com的配置文件

<VirtualHost 192.168.101.128:80>
        ServerName      www.b.com
        DocumentRoot    /var/web/b.com
        ErrorLog        /var/log/httpd/b.com/error_log
        CustomLog       /var/log/httpd/b.com/access_log combined
<VirtualHost>

如果/var/web/这个目录没有做授权的话还需要做授权
也是在/etc/httpd/conf.d/b.conf,这个配置文件中,后面添加:

<Directory "/var/web/">
        Allowoverride   None
        Require all granted
</Directory>

2.创建所需要的文件

[root@centos7 ~]# mkdir -p /var/web/b.com
[root@centos7 ~]# mkdir -p /var/log/httpd/b.com/

3.给b.com设置一个主页面:

[root@centos7 ~]# vim /var/web/b.com/index.html

<html>
                hello,
                welcome to b.com
</html>

4.检查配置文件的语法有没有问题:

[root@centos7 ~]# httpd -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using centos7.localdomain. Set the 'ServerName' directive globally to suppress this message
Syntax OK

5.语法没有问题就可以重启httpd了:

[root@centos7 ~]# systemctl restart httpd

重启了之后,在目录/var/log/httpd/b.com/这个目录下就会自动建好error_log和access_log这两个日志文件

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值