我有一个域domain.com和一个子域sub.domain.com 。
在apache2 / sites-available中,我有2个vhosts文件: domain和sub 。
当我做a2ensite子子域覆盖域,所以当我去看到主域我看到子域的内容。 当添加子域时,域和子域指向子域。
我究竟做错了什么?
这是虚幻的
域
<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName www.domain.com DocumentRoot /var/www/domain/ <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/domain/> Options Indexes FollowSymLinks MultiViews AllowOverride All 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>
SUBDOMAIN
<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName sub.domain.com DocumentRoot /var/www/sub/ <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/sub/> Options Indexes FollowSymLinks MultiViews AllowOverride All 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>
我还没有读取configuration文件。 但是我希望你一定要去检查/ etc / apache2 / sites-enabled
子域是否与domain.com 之前的数字链接?
例子010-sub链接到/etc/apache2/subdomain.conf
和020-sub链接到/etc/apache2/domain.conf
这样Apache就会parsing第一个给出请求的subdomain.conf。