Mac,linux和windows下apache多站点配置

Mac下配置步骤:

1:/etc/hosts下新增

# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost
127.0.0.1       www.bluelady.com
127.0.0.1       www.bluestudio.com

2:xampp下/Applications/XAMPP/xamppfiles/httpd.conf文件打开Include etc/extra/httpd-vhosts.conf

3:Include etc/extra/httpd-vhosts.conf配置

 <VirtualHost *:80>
DocumentRoot “/Applications/XAMPP/xamppfiles/htdocs/bluelady”
ServerName www.bluelady.com
</VirtualHost>

<VirtualHost *:80>
DocumentRoot “/Applications/XAMPP/xamppfiles/htdocs/bluestudio”
ServerName www.bluestudio.com
</VirtualHost>

<VirtualHost *:80>
DocumentRoot “/Applications/XAMPP/xamppfiles/htdocs”
ServerName localhost
</VirtualHost>

Linux和windows配置注意:

Windows要在C:\windows\system32\drivers\etc下hosts文件
Linux虚拟主机配置80端口在同一文件中的配置前要加 NameVirtualHost *:80

问题解决:

常见问题是无访问权限,一般配置httpd.conf如下即可:

<Directory />
Options Indexes FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>

发表评论