Apache中Virtual Host虚拟主机配置及rewrite参数说明
Virtual Host配置过程
这里例子中我们的路径为这样
DocumentRoot: /home/jb51 /sites/demo.jb51.net
ServerName:demo.jb51.net
1.进入apache虚拟主机设置目录
cd /etc/apache2/sites-available
2.创建文件demo.jb51.net
<VirtualHost *:80> ServerAdmin webmaster@localhost DirectoryIndex index.html index.php DocumentRoot /home/jb51 /sites/demo.jb51.net ServerName demo.jb51.net ServerAlias demo.jb51.net <Directory "/home/jb51 /sites/demo.jb51.net"> allow from all Options + Indexes </Directory> </VirtualHost>
3.激活虚拟主机配置
sudo a2ensite demo.jb51.net
4.进入 /etc/apache2/sites-enabled/目录,可以查看所有激活的虚拟主机。可以用 sudo a2dissite demo.jb51.net 注销
cd /etc/apache2/sites-enabled ls -lt
显示
代码如下:
lrwxrwxrwx 1 root root 36 2013-04-05 17:29 demo.jb51.net -> ../sites-available/demo.jb51.net