Ubuntu Apache环境下二级域名配置

Ubuntu Apache下二级域名配置

       网站二级域名:比如百度音乐(music.baidu.com),百度文库(wenku.baidu.com),在申请一级域名后,只要做相应的配置便可以通过二级域名访问网站,这里是以配置education.bigtreechina.com为例,步骤如下:

1、远程登录服务器后台,创建网站文件的目录(比如education)

         cd/var/www

         mkdir education

2、进入Apache2配置目录 :

         cd  /etc/apache2/

3、进入site-available目录创建新的site文件,建议文件名和二级域名一样:比如education.bigtreechina.com

       cd sites-avaiable

       vi education.bigtreechina.com.conf

       然后输入以下内容,并保存退出

<VirtualHost*:80>

    ServerAdmin education@qq.com

    DocumentRoot /var/www/education

    <Directory /var/www/education>

       Options ExecCGI FollowSymLinks

       AllowOverride all

       allow from all 

       Order allow,deny 

    </Directory>

    ServerName education.bigtreechina.com

    ErrorLog ${APACHE_LOG_DIR}/education.bigtreechina.com-error.log

    CustomLog ${APACHE_LOG_DIR}/education.bigtreechina.com-access.log combined

</VirtualHost>

4、激活site文件

         a2ensite  education.bigtreechina.com.conf

         激活成功后在/etc/apache2/sites-enabled/目录下就会出现这个文件,如果想disable某个site,可以用a2dissite

5、修改hosts

打开host文件:vi /etc/hosts

添加:127.0.0.1 education.bigtreechina.com

重启网络:sudo /etc/init.d/networking restart

6、重启apache

         service apache2 restart

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值