处理开发子域

我有一个虚拟主机转发到我的主域(例如显示相同的内容,我的主要域显示)。


现在我的网站使用一个主域名:www.example.com

和各种别名域:example.com short.com

我正在创build一个新的围墙花园开发网站:dev.example.com

但是我的虚拟主机没有被识别为该url。

我必须在DNS主机中创build* .example.com的通配符logging吗?

以下是我的默认虚拟主机设置(当前位于/etc/apache2/sites-enabled/000-default )中的相关部分:

 <VirtualHost *:80> ServerAdmin [email protected] ServerName www.example.com ServerAlias example.com ServerAlias shortUrlEx.com ServerAlias www.shortUrlEx.com RewriteEngine On RewriteCond %{HTTP_HOST} ^example.com [NC] RewriteRule ^(.*)$ http://www.example.com$1 [L,R=301] RewriteCond %{HTTP_HOST} ^shortUrlEx.com [NC] RewriteRule ^(.*)$ http://www.example.com$1 [L,R=301] RewriteCond %{HTTP_HOST} ^www.shortUrlEx.com [NC] RewriteRule ^(.*)$ http://www.example.com$1 [L,R=301] DocumentRoot /var/www/examplepath php_value date.timezone "America/New_York" php_value expose_php "Off" php_value upload_max_filesize 10M php_value post_max_size 10M ... other config options 

dev.example.comconfiguration如下(从/etc/apache2/sites-enabled/dev.example.com ):

 <VirtualHost *> <Directory /> AuthType Basic AuthName "Check Site" AuthUserFile /srv/dev-example/config/.htpasswd Require valid-user </Directory> ServerName dev.example.com DocumentRoot /srv/dev-example/public_html/ Alias /favicon.ico /srv/dev-example/docs/dev_favicon.ico php_value date.timezone "America/New_York" php_value expose_php "Off" php_value upload_max_filesize 10M php_value post_max_size 10M <Directory /> Options FollowSymLinks -Indexes AllowOverride None </Directory> <Directory /srv/dev-example> Options FollowSymLinks MultiViews -Indexes AllowOverride All Order allow,deny allow from all </Directory> ... further options that shouldn't be applicable... 

我在这里做错了什么? 我应该如何configuration默认和dev.example.com虚拟主机,以允许访问dev子域,并使用主域的一切?

当您尝试ping“dev.example.com”时会发生什么? 它是否parsing为IP地址? 如果是这样,那它是Apache服务器的IP地址吗?

在这种情况下,我怀疑你需要在DNS(或者至less在/ etc / hosts)中configuration一个新的“dev.example.com”logging,这样你的工作站才能知道DNS应该去哪里。

尝试更新您的开发站点的<VirtualHost *:80>条目: <VirtualHost *:80>

注意增加:80。

您的虚拟主机定义应该与NameVirtualHost设置的值匹配。 运行apachectl configtest通常报告任何不匹配。

我不得不:

将虚拟主机设置更改为:

 <VirtualHost *:80> 

取消对NameVirtualHost设置的注释:

 NameVirtualHost *:80 

并将ServerAlias添加到dev.shermanbrothers.com虚拟主机。

 ServerAlias dev.shermanbrothers.com 

不应该/etc/apache2/sites-enabled/dev.shermanbrothers.com/etc/apache2/sites-enabled/dev.shermanbrothers.com.conf ? 我认为Apache需要* .conf文件,至less在CentOS中是这样。 或者你有手动吗?