Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Jun 2008
    Posts
    68
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Help needed with virtual hosts & MAMP

    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:
    Code:
    ##
    # 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:

    Code:
    ### 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

  • #2
    Regular Coder
    Join Date
    Nov 2007
    Posts
    144
    Thanks
    64
    Thanked 0 Times in 0 Posts
    Does MAMP support vhosts? I thought only MAMP Pro did.. though I could be wrong.

  • #3
    Regular Coder
    Join Date
    Nov 2007
    Posts
    144
    Thanks
    64
    Thanked 0 Times in 0 Posts
    Just thought of another thing...

    You might need
    Code:
    NameVirtualHost *
    in your apache config file

  • #4
    New Coder
    Join Date
    Jun 2008
    Posts
    68
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by samuurai View Post
    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.

  • #5
    New Coder
    Join Date
    Jun 2008
    Posts
    68
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by samuurai View Post
    Just thought of another thing...

    You might need
    Code:
    NameVirtualHost *
    in your apache config file
    I already have that in the httpd.conf file?
    WOW Paradise - Exclusive - Insiders Report!
    Download Free Insiders Report!!! www.wowparadise.eu

  • #6
    Regular Coder
    Join Date
    Nov 2007
    Posts
    144
    Thanks
    64
    Thanked 0 Times in 0 Posts
    Sorry, I missed that.

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

    What happens if you remove it completely?

  • #7
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,866
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Don't know much about the technical details, though in my xampp's httpd-vhosts.conf file, I use
    Code:
    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?
    Last edited by abduraooft; 01-23-2009 at 07:47 AM.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #8
    Regular Coder
    Join Date
    Nov 2007
    Posts
    144
    Thanks
    64
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •