ubuntu 12.04 配置虚拟主机

 我到apache是 apt-get install apache2 这么安装到,默认到安装目录是在/etc/apache2/ ,这个配置和windows不同,文件到位置也不同。 这里到httpd.conf 是空的,它是通过apache2.conf 包含过来的。 在本机配置多个域名到话,用到来两个文件夹sites-available 和 sites-enabled 打开sites-available ,里面有个的default,copy一份,我这里命名为 ci ,再copy 一份,命名为 test 编辑ci,看到到格式如下 ServerAdmin webmaster@localhost ServerName ci.xgw.com 这个是新添加到域名 DocumentRoot /var/www/ci 这个是域名根目录 Options FollowSymLinks AllowOverride None 这里也要修改 Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 这个文件之修改了红色部分,test也参考这个修改。 然后测试是否成功。检查apache配置文件 sudo apache2ctl configtest ,可能会看到这样到一行 是关于ServerName的,但是不影响使用。可以在httpd.conf 中加入一行ServerName localhost:80,提示就消失了。 重启apache service apache2 restert ,提示没有错误就成功了 hosts在/etc/ 在hosts中指定 127.0.0.1 ci.xgw.com 127.0.0.1 test.xgw.com 重新打开浏览器,输入域名 ci.xgw.com,ok。一切正常,哈哈

posted @ 2012-08-11 01:58  derek718  阅读(137)  评论(0编辑  收藏  举报