apache 上的虚拟主机配置
我的 apache 服务器有问题。
我刚刚进行了全新安装(debian 6.0)。
了服务器(/etc/init.d/apache2 reload)
我在 /etc/apache2/sites-available 中创建了两个配置文件:mysite.com 和 dev.mysite.com,我使用 a2ensite 命令启用了它们,然后重新加载 修改我的主机文件以将两个请求重定向到我的服务器。尝试访问 mysite.com 时没有问题,但是当我尝试访问 dev.mysite.com 时,我得到了 mysite.com 的内容。
这是我的配置文件:
apache2.conf 的一部分
# Include ports listing
Include ports.conf
# Include the virtual host configurations:
Include sites-enabled/*
ports.conf 文件
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz
NameVirtualHost *:80
Listen 80
<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to <VirtualHost *:443>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
site-available/mysite.com 文件:
<VirtualHost *>
ServerAdmin [email protected]
ServerName www.mysite.com
ServerAlias mysites.com
ServerAlias www.mysites.com
ServerAlias mysite.com
DocumentRoot /media/Data/www/mysiteCom
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /media/Data/www/mysiteCom>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error_mysiteCom
LogLevel warn
CustomLog /var/log/apache2/access_mysiteCom combined
ServerSignature Off
</VirtualHost>
我的sites-available/dev.mysite.com 文件:
<VirtualHost *>
ServerAdmin [email protected]
ServerName dev.mysite.com
ServerAlias dev.mysites.com
DocumentRoot /media/Data/www/devMysiteCom
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /media/Data/www/devMysiteCom>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error_devMysiteCom
LogLevel warn
CustomLog /var/log/apache2/access_devMysiteCom combined
ServerSignature Off
</VirtualHost>
知道我做错了什么吗?
I've a problem with my apache server.
I just did a fresh install(debian 6.0).
I created two config files: mysite.com and dev.mysite.com in /etc/apache2/sites-available, I enabled them with the a2ensite command, and I reloaded the server(/etc/init.d/apache2 reload)
I modified my host file to redirect the two requests to my server. I've no problem when trying to reach mysite.com, but when I try to access dev.mysite.com I get the content of mysite.com.
Here are my config files:
part of apache2.conf
# Include ports listing
Include ports.conf
# Include the virtual host configurations:
Include sites-enabled/*
the ports.conf file
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz
NameVirtualHost *:80
Listen 80
<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to <VirtualHost *:443>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
the sites-available/mysite.com file:
<VirtualHost *>
ServerAdmin [email protected]
ServerName www.mysite.com
ServerAlias mysites.com
ServerAlias www.mysites.com
ServerAlias mysite.com
DocumentRoot /media/Data/www/mysiteCom
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /media/Data/www/mysiteCom>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error_mysiteCom
LogLevel warn
CustomLog /var/log/apache2/access_mysiteCom combined
ServerSignature Off
</VirtualHost>
my sites-available/dev.mysite.com file:
<VirtualHost *>
ServerAdmin [email protected]
ServerName dev.mysite.com
ServerAlias dev.mysites.com
DocumentRoot /media/Data/www/devMysiteCom
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /media/Data/www/devMysiteCom>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error_devMysiteCom
LogLevel warn
CustomLog /var/log/apache2/access_devMysiteCom combined
ServerSignature Off
</VirtualHost>
Any idea of what I did wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现了我的错误。
事实上,似乎必须提及将访问哪个端口,因此我必须在 VirtualHost 中进行设置:
I found my error.
In facts, it seems to be mandatory to mention which port will be accessed, so I had to set it in the VirtualHost: