...

View Full Version : Help needed with virtual hosts & MAMP



leemarquis
01-21-2009, 10:47 PM
Can someone help me set up virtual hosts with MAMP on OSX10.4? I cant get it to work properly...

In MAMP I have:

APACHE PORT: 80
MYSQL PORT: 3306

and Document Root is:
/Users/Lee/Sites

My hosts file is:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost beautybytara.local
255.255.255.255 broadcasthost
::1 localhost



My httpd.conf file ends with:



### Section 3: Virtual Hosts
#
# VirtualHost: If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs-2.0/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#

NameVirtualHost *

<VirtualHost *>
DocumentRoot /Users/Lee/Sites
ServerName localhost
</VirtualHost>

<VirtualHost *>
DocumentRoot /Users/Lee/Sites/beautybytara
ServerName beautybytara.local
</VirtualHost>


In my Sites folder I have a folder named beautybytara in which all the site files exist.

After restarting MAMP and pointing my browser to : http://beautybytara.local
I just get the Test page for apache Installation page - even though there is an index file in the folder. If I type http://beautybytara.local/index.html I still get the same page.

If I go to http://localhost then I get a test index page load up that I placed in the Sites directory.

If I go to http://localhost/beautybytara then site load as expected but because the document root is at the Sites folder and not the beautybytara folder the PHP code does work as it uses document root in the code to find includes etc.

What am I doing wrong? I want each folder in the Sites directory to act as its own document root.

Thanks

samuurai
01-22-2009, 12:07 PM
Does MAMP support vhosts? I thought only MAMP Pro did.. though I could be wrong.

samuurai
01-22-2009, 12:11 PM
Just thought of another thing...

You might need


NameVirtualHost *


in your apache config file

leemarquis
01-22-2009, 04:31 PM
Does MAMP support vhosts? I thought only MAMP Pro did.. though I could be wrong.

Yes MAMP does support virtual hosts but you have to edit the hosts file and the httpd.conf file.

Ive followed all the tutorials on it but cant get it to work.

leemarquis
01-22-2009, 04:34 PM
Just thought of another thing...

You might need


NameVirtualHost *


in your apache config file

I already have that in the httpd.conf file?

samuurai
01-22-2009, 04:51 PM
Sorry, I missed that.

Looking at your config, the first vhost is a little redundant.

What happens if you remove it completely?

abduraooft
01-22-2009, 04:55 PM
Don't know much about the technical details, though in my xampp's httpd-vhosts.conf file, I use

NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot "G:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "G:/xampp/htdocs/myfolder"
ServerName mydomain.com
</VirtualHost>
Don't you need to add your port number there?

samuurai
01-22-2009, 07:49 PM
You shouldn't need to specify port number. * will listen on any port. Somewhere in apache2.conf, it'll have "Listen 80". You can add "Listen 443" or any other port. The vhost will then respond on either port.

You'd usually only supply the port if you wanted to lock it down to https, for example.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum