Apache 搭建虚拟主机
Apache 搭建虚拟主机方法
DocumentRoot: /home/fdipzone/sites/demo.fdipzone.com
ServerName:demo.fdipzone.com
1.进入apache虚拟主机设置目录
cd /etc/apache2/sites-available
2.创建文件demo.fdipzone.com
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /home/fdipzone/sites/demo.fdipzone.com ServerName demo.fdipzone.com ServerAlias demo.fdipzone.com <Directory "/home/fdipzone/sites/demo.fdipzone.com"> allow from all Options + Indexes </Directory> </VirtualHost>3.激活虚拟主机配置
sudo a2ensite demo.fdipzone.com4.进入 /etc/apache2/sites-enabled/目录,可以查看所有激活的虚拟主机。可以用 sudo a2dissite demo.fdipzone.com 注销
cd /etc/apache2/sites-enabled ls -lt 显示 lrwxrwxrwx 1 root root 36 2013-04-05 17:29 demo.fdipzone.com -> ../sites-available/demo.fdipzone.com5.重启apache服务
sudo /etc/init.d/apache2 restart6.ubuntu 设置host
vim /etc/hosts 127.0.0.1 demo.fdipzone.com7.<Directory>设置开启.htaccess与显示目录结构列表
<Directory "/home/fdipzone/demo.fdipzone.com"> AllowOverride none AllowOverride all Options -Index FollowSymLinks </Directory>AllowOverride none 表示关闭.htaccess,如要开启可设置为AllowOverride all
Options -Indexes 表示关闭目录结构显示,如要开启可设置为 Options Indexes
Options FollowSymLinks 表示支持symbol link(软连接),如要关闭可设置为Options -FollowSymLinks