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