我目前正在从一台服务器转移到另一台服务器的过程中。 而我目前正在build立我的apache2。 但是在旧的服务器上,我使用了几个子域。 现在我想在新的服务器上testing这些子域名,但似乎帽子subdomain.xx.xx.xx.xx(subdomain.ip-address)似乎不工作。 这是不可能的,或者只是我得到configuration错误?
我的configuration
NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/tld.com <Directory> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/tld.com> Options -Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all # This directive allows us to have apache2's default start page # in /apache2-default/, but still have / go to the right place #RedirectMatch ^/$ /apache2-default/ </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined ServerSignature On 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 </Directory> </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/subdomain ServerName subdomain.62.75.145.146 </VirtualHost>
如果其中任何一个都不能解决问题,那么至less需要给我们更多的信息 – 发布你的apache vhostconfiguration。
– 编辑 – 好的,首先, subdomain.62.75.145.146 .62.75.145.146不是有效的DNS名称。 你不能只添加任意主机名到你的服务器的IP地址。 您需要为此虚拟主机提供专用IP 或分配有效的DNS名称。 如果您只是在进行testing,您可以在客户端映射subdomain.example.com的主机文件中添加一个条目到62.75.145.146 。 这条线看起来像这样:
62.75.145.146 subdomain.example.com
然后在您的VirtualHost中将subdomain.example.com设置为ServerName。 此时,您应该可以在浏览器中访问subdomain.example.com ,它将从正确的虚拟主机提供服务。
如果主机文件不适合您,则需要为该子域创build适当的DNS A或CNAMElogging。 这个过程不在这个问题的范围之内,但是有关这个过程的其他ServerFault文章应该有大量的信息。