在linux下apache的多站点虚拟主机配置方法(xammp)
Step-one:在 /etc/hosts 添加本地ip解析的域名
127.0.0.1 alic.com
Step-two:加载模块rewrite和alias模块 /opt/lammp/etc/httpd.conf
LoadModule vhost_alias_module modules/mod_vhost_alias.so
(delete # linux default -> ok=not modify) 确保前面没有 # 注释符
.#Virtual hosts
Include etc/extra/httpd-vhosts.conf
(delete #)也就是确保引入了 vhosts 虚拟主机配置文件
Step-three:在/opt/lammp/etc/extra/http-vhosts.conf添加如下代码
ServerAdmin webmaster@alic.com
DocumentRoot "/opt/lampp/htdocs/ThinkPHP"
ServerName alic.com ---servername
ErrorLog "logs/alic.com-error_log" ---logs/servername/-error_log_log
CustomLog "logs/alic.com-access_log" common ---logs/server-access_og
Step-four:该段为我们自身加上去的虚拟主机目录
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
该段为localhost本身的目录(必须重写) else->localhost打不开
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Step-five:重启apache
sudo service apache restart
在windows下apache的多站点虚拟主机配置方法(xammp)
hosts路径为:
system32/drivers/etc/host
httpd-vhosts.conf路径为:
xampp/apache/conf/extra/httpd-vhosts.conf
httpd.conf路径为:
xammp/apache/conf/httpd.conf
注意DocumentRoot:绝对路径/xammp/htdocs 后面没有/
单独的ServerName为全局变量一个项目可以设置
但是多个项目 比如用到二级域名的话
必须注释 需要在xml里面添加