[英]Virtual host in apache on Mint VM doesn't work
I have Apache running on a Mint VM on a Windows 8 host so I can use the VM for Drupal development. 我在Windows 8主机上的Mint VM上运行Apache,因此可以将其用于Drupal开发。 I created a VirtualHost entry in /etc/apache2/apache2.conf
so I can use www.mysite.dev
as a development URL, and I set up the hosts
files on the guest host machines. 我在/etc/apache2/apache2.conf
创建了VirtualHost条目,因此可以将www.mysite.dev
用作开发URL,并在来宾主机上设置hosts
文件。 The target platform for deployment is Acquia, in case that's relevant. 如果需要的话,部署的目标平台是Acquia。
The problem I'm having is that, when use a browser in the guest to go to http://www.mysite.dev/
, I get my site, but when I access http://www.mysite.dev/any-non-root-path
, I get a 404. Also, when I use a browser on the host to go to http://www.mysite.dev
, I instead get the Apache default home page. 我遇到的问题是,当在访客中使用浏览器访问http://www.mysite.dev/
,我得到了我的网站,但是当我访问http://www.mysite.dev/any-non-root-path
,我得到404。此外,当我在主机上使用浏览器访问http://www.mysite.dev
,我得到的是Apache默认主页。
In /etc/apache2/apache2.conf
on the guest, I have: 在来宾的/etc/apache2/apache2.conf
,我有:
<VirtualHost www.mysite.dev:80>
DocumentRoot /var/www/html/mysite/docroot/
ServerName www.mysite.dev
</VirtualHost>
In /etc/hosts
on the guest, I have: 在来宾的/etc/hosts
,我有:
127.0.0.1 localhost
127.0.1.1 vm-name
127.0.0.1 www.my-site.dev
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
In C:\\Windows\\System32\\drivers\\etc\\hosts
on the host, I have 在C:\\Windows\\System32\\drivers\\etc\\hosts
上的C:\\Windows\\System32\\drivers\\etc\\hosts
,
127.0.0.1 localhost
192.168.44.44 www.drupal7.dev
192.168.44.45 www.mysite.dev
192.168.44.45 is the IP address of the VM on the host-only network I created in VirtualBox. 192.168.44.45是我在VirtualBox中创建的仅主机网络上VM的IP地址。 (The 192.168.44.44 is from when I was trying Vagrant, but the shared folder performance was too slow. I figured instead of learning Vagrant just to muck around, I might as well skip straight to the muck!) (192.168.44.44是从我尝试Vagrant时获得的,但是共享文件夹的性能太慢了。我认为与其学习Vagrant并不是为了乱扔垃圾,不如直接跳到垃圾堆!)
I suspect the two issues I'm having are related. 我怀疑我遇到的两个问题有关。 So my question is this: how can I resolve these two issues so I get the content I want both while browsing from the host and while browsing from the guest? 所以我的问题是:如何解决这两个问题,以便在从主机浏览和从来宾浏览时都能获得所需的内容?
Thanks! 谢谢!
edit The specific error I was getting for the path issue was The requested URL [...] was not found on this server.
编辑我针对路径问题遇到的特定错误是The requested URL [...] was not found on this server.
New Answer : This answer solves both problems. 新答案 :这个答案解决了两个问题。
<VirtualHost 192.168.44.45 127.0.0.1>
DocumentRoot /var/www/html/site-name
ServerName www.site-name.dev
<Directory "/var/www/html/site-name/docroot/">
AllowOverride All
</Directory>
</VirtualHost>
So that's the answer, Mr. Spock! Spock先生,这就是答案!
Original Answer So a fresh look Monday morning got me part of the answer. 原始答案因此,周一早晨焕然一新使我成为了答案的一部分。 I guess this is really two questions. 我想这真的是两个问题。
The fix to the non-root URL was to add a directory element. 对非根URL的修复是添加目录元素。 See https://www.drupal.org/node/1038 . 参见https://www.drupal.org/node/1038 。
<VirtualHost www.site-name.dev:80>
DocumentRoot /var/www/html/site-name
ServerName www.site-name.dev
<Directory "/var/www/html/site-name/docroot/">
AllowOverride All
</Directory>
</VirtualHost>
I'm still looking into the other part. 我仍在研究另一部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.