質問

I have a virtual hosts running on my mac via MAMP Pro. After looking at this: Access Apache VirtualHost from any computer on LAN? I've decided to check my httpd-vhosts.conf file to see if the correct settings were being used.

I have not touched a single Apache config files to get these virtual hosts up and running because MAMP Pro provides an interface that allows me to do so (ie: https://i.stack.imgur.com/8zkwS.png). I've checked my ../conf/Apache/extra/httpd-vhosts.conf to see if any changes were made but nothing. This is the content of the file:

    NameVirtualHost *:80
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/Applications/MAMP/Library/docs/dummy-host.example.com"
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "logs/dummy-host.example.com-error_log"
    CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "/Applications/MAMP/Library/docs/dummy-host2.example.com"
    ServerName dummy-host2.example.com
    ErrorLog "logs/dummy-host2.example.com-error_log"
    CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>

(condensed, this is the full content of the file: http://pastie.org/9158063)

Where can I find the relevant httpd-vhost.conf files? Will altering the one line of code as pointed out in the link I've provided above allow be to access the virtual host from another device?

役に立ちましたか?

解決

I guess this is because you have mapped your virtualhost to www.dummy-host.example.com and it won't work to access the server using only its IP-address. You will need to add a mapping between the servers IP-address and server alias. This could easily be done by adding a new line into your /etc/hosts file on you client machine i.e:

192.168.1.1 www.dummy-host.example.com

Since you're using a phone you won't be able to edit any hosts file and then you could use IP-based virtual hosts or perhaps a setup a local DNS server.

Here are a couple of links with different solutions for this problem

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top