一个谜语:哪个不起作用 - sites.php或我的vhost设置?

时间:2017-01-27 21:07:34

标签: apache drupal-7

我在自己旁边。我拥有这些我在GIT管理的3个Drupal 7站点。我不使用默认网站,只使用3个多站点。我只想在浏览器中访问本地版本,但我不能。我从本地代码库复制了以下内容。

去年我花了大约三四天时间试图找到悲伤的根源,但无济于事。我非常感谢专业诊断。

默认网站,未使用。

子站点:

main/sites/abc.com
main/sites/def.org
main/sites/xyz.com

sites.php:

$sites['localhost.main'] = 'default';
$sites['localhost.abc'] = 'abc.com';
$sites['localhost.def'] = 'def.org';
$sites['localhost.xyz'] = 'xyz.com';

我认为这有效

(删除时,不会加载“网站”文件夹) - > /Users/Peanut/Sites/vhosts/localhost.conf:

<VirtualHost *:80>
    DocumentRoot /Users/Peanut/Sites
    ServerName localhost
</VirtualHost>

我认为这有效

(我收到安装表格) - &gt; /Users/Peanut/Sites/vhosts/main.conf:

<VirtualHost *:80>
    DocumentRoot /Users/Peanut/Sites/main
    ServerName main
</VirtualHost>

所以我认为这也有效

- &GT; /Users/Peanut/Sites/vhosts/abc.conf:

<VirtualHost *:80>
    DocumentRoot /Users/Peanut/Sites/main
    ServerName abc
</VirtualHost>

当我删除此文件

时,此网站仍会神秘地加载

,这是drupal 7的单独站点安装 - &gt; /Users/Peanut/Sites/vhosts/othersite.conf:

<VirtualHost *:80>
    DocumentRoot /Users/Peanut/Sites/othersite
    ServerName othersite
</VirtualHost>
drupal root中的

.htaccess包含:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^def.org$
RewriteRule ^/?$ "http\:\/\/www\.def\.org\/" [R=301,L]

RewriteCond %{HTTP_HOST} ^xyz\.com$
RewriteRule ^/?$ "http\:\/\/www\.xyz\.com\/" [R=301,L]

RewriteCond %{HTTP_HOST} ^abc\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.abc\.com$
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ "https\:\/\/www\.abc\.com\/$1" [R=301,L]

RewriteCond %{HTTP_HOST} ^abc\.com$
RewriteRule ^(.*)$ "https\:\/\/www\.abc\.com\/$1" [R=301,L]

的/ etc /主机:

##
127.0.0.1       localhost
127.0.0.1       main
127.0.0.1       abc
127.0.0.1       def
127.0.0.1       xyz
127.0.0.1       othersite

55.255.255.255  broadcasthost
::1             localhost
fe80::1%lo0     localhost

/Applications/MAMP/conf/apache/httpd.conf:

# Virtual hosts
  Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf

# Virtual host files that Peanut created, one for each site.
  Include /Users/Peanut/Sites/vhosts/*.conf

/Applications/MAMP/conf/apache/extras/httpd-vhosts.conf

包含以下内容,我尝试过这两种方法:

 NameVirtualHost *:80
#NameVirtualHost *

2 个答案:

答案 0 :(得分:0)

我可能会尝试删除您的MAMP安装,并尝试按照这样的指导安装进行操作 - https://www.youtube.com/watch?v=sEe12h9Lryo

我知道,这不是一个好的答案,但也许它会有所帮助。

答案 1 :(得分:0)

解决。

现在我可以使用此网址模式访问本地网站...

    http://dev.abc

sites.php:

$sites['dev.defaultsite'] = 'default';
$sites['dev.abc'] = 'abc.com';
$sites['dev.def'] = 'def.org';
$sites['dev.xyz'] = 'xyz.com';

这可行

- &GT; /Users/Peanut/Sites/vhosts/defaultsite.conf:

<VirtualHost *:80>
    DocumentRoot /Users/Peanut/Sites/main
    ServerName dev.defaultsite
</VirtualHost>

- &GT; /Users/Peanut/Sites/vhosts/abc.conf:

<VirtualHost *:80>
    DocumentRoot /Users/Peanut/Sites/main
    ServerName dev.abc
</VirtualHost>

- &GT; /Users/Peanut/Sites/vhosts/def.conf:

<VirtualHost *:80>
    DocumentRoot /Users/Peanut/Sites/main
    ServerName dev.def
</VirtualHost>

的/ etc /主机:

##
127.0.0.1       localhost
127.0.0.1       dev.defaultsite
127.0.0.1       dev.abc
127.0.0.1       dev.def
127.0.0.1       dev.xyz
127.0.0.1       dev.othersite

55.255.255.255  broadcasthost
::1             localhost
fe80::1%lo0     localhost

/Applications/MAMP/conf/apache/httpd.conf:

# Virtual hosts
  Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf

# Virtual host files that Peanut created, one for each site.
  Include /Users/Peanut/Sites/vhosts/*.conf

/Applications/MAMP/conf/apache/extras/httpd-vhosts.conf

包含以下内容:

 NameVirtualHost *:80
#NameVirtualHost *

我不知道它是否有帮助,但我确实将settings.php中的base_url更改为:

    $base_url = 'http://dev.abc';  // NO trailing slash!