Can't get MAMP working with Virtual hosts

2.5k views Asked by At

I’m having a hard time getting multiple sites working with MAMP using Virtual hosts. Below is what I have set up on my MBA. If I open up my web browser and go to "http:local.login.dev" or "http://dev.login.localhost" (after reconfigure) I get the index page that’s saved in /Users/aaron/localhost. First item listed in my Virtual hosts section Not the index page saved in the Virtual Host I want to get to. Other sites I have setup give me the same result.. "http:next.site.localhost" = displays the index page in /Users/aaron/localhost.

Does anybody have any thoughts? My final goal is to configure MAMP Virtual hosts to work and test with SSL.

Bottom line is it seems like ONLY the first Virtual host entry is read and that's whats used for every host listed. Am I missing some setting somewhere??

Environment: - MBA with OS X, Yosemite

  • MAMP 3.0.7.3 using ports 80, and 3306 for http and mysql respectively

  • httpd.conf File: Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf

    127.0.0.1 localhost
    127.0.0.1 local.login.dev

    <VirtualHost *> 
         DocumentRoot "/Users/aaron/localhost" 
         ServerName localhost 
    </VirtualHost> 
    
    <VirtualHost *:80>  —  I tried both with and without :80
         DocumentRoot "/Users/aaron/localhost/training/login/public"
         ServerName local.login.dev  
    </VirtualHost>
    

Also tried configuring my hosts and httpd-vhosts.conf this way - From another post:

127.0.0.1 localhost
127.0.0.1 dev.login.localhost

<VirtualHost *> 
     DocumentRoot "/Users/aaron/localhost" 
     ServerName localhost 
</VirtualHost> 

<VirtualHost *:80>
     DocumentRoot "/Users/aaron/localhost/training/login/public"
     ServerName dev.login.localhost  
     ServerAlias dev.login.localhost  
    <Directory "/Users/aaron/localhost/training/login/public">
         Allow from All                                                                  
         AllowOverride all                                                               
         Options -Indexes +FollowSymlinks                                                
    </Directory> 
</VirtualHost>
1

There are 1 answers

0
user2341085 On

Just playing around more I commented out the first "Localhost" in my httpd-vhosts.conf file and looks like I can now navigate to my local sites correctly. Below is what I currently have configed..

httpd-vhosts.conf:

     # <VirtualHost *> 
     #     DocumentRoot "/Users/aaron/localhost/" 
     #     ServerName localhost 
     # </VirtualHost> 

     <VirtualHost *:80>
          DocumentRoot "/Users/aaron/localhost/training/login/public"
          ServerName dev.login.localhost  
          ServerAlias dev.login.localhost  
     </VirtualHost>

     <VirtualHost *:80>
          DocumentRoot "/Users/aaron/localhost/site1"
          ServerName dev.site1.localhost  
          ServerAlias dev.site1.localhost
     </VirtualHost>

     <VirtualHost *:80>
          DocumentRoot "/Users/aaron/localhost/site2"
          ServerName dev.site2.localhost  
          ServerAlias dev.site2.localhost
     </VirtualHost>

Hosts File:

     127.0.0.1  localhost
     ######Locahost Dev Sites
     127.0.0.1  dev.login.localhost dev.site1.localhost dev.site2.localhost

Now to see if I can get SSL working.

If any of this is incorrect, please let me know... but this config is the only way I can get the Virtual hosts working, as of now, using port 80... If I have issues mixing with 443 I'll update