|Jul 19, 2009, 06:34 AM||#1|
MAMP Virtual Hosts
Is the free MAMP actually able to take on board virtual hosts?
I've previously, umpteen times, added virtual hosts to the installed Apache (comes with 10.4). It's so easy it is like falling off the proverbial log.
Which is why it strikes me as odd I should suddenly become incapable of adding the correct amends to conf/host files with MAMP. Everything I look at outlines the usual standard entries - yet, my MAMP seems to be ignoring the entries in the conf file giving me "connection refused" messages. I think the hosts file is being picked up, but I don't know of a way of actually testing whether it is hosts or conf that's being ignored - if anyone knows, that'll be really cool and maybe a step to resolving this.
I'm really stumped as all the instructions on the net seem to spell out the 'usual' falling-off-the-log amends that, as I say I've done successfully umpteen times with the Mac out-of-the-box Apache.
The ports are the default for MAMP - 8888 and 8889 respectively.
Root folder as default: /Applications/MAMP/htdocs (specified in the preference of the start-up dialogue)
Entry in hosts
127.0.0.1 localhost 127.0.0.1 mySite.dev etc.,
Entry in /Applications/MAMP/conf/apache/httpd.conf
NameVirtualHost * <VirtualHost *> ServerName mySite.dev DocumentRoot /Applications/MAMP/htdocs/mySite </VirtualHost>
<VirtualHost *> ServerName localhost:8888 DocumentRoot /somewhereElse/htdocs </VirtualHost>
|Jul 21, 2009, 06:36 PM||#2|
Here's what I have for my virtual hosts. First edit your httpd.conf file located at /Applications/MAMP/conf/apache/httpd.conf. I added the following code block to the very end of the file. I should also note that I have my port set as 80 rather than the default 8888 in MAMP. The below configuration uses a folder named site.com that holds the web root for the site (like the htdocs folder that MAMP uses), and we'll be setting up a virtual host to access the site locally using the alias site.local. This name can be just about anything, but people often use their domain name and then just change the extension to something like local or dev.
The DocumentRoot and ServerName lines inside each VirtualHost section are the only required lines. Other parts are optional.
# # Use name-based virtual hosting. # NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot /Applications/MAMP/htdocs ServerName localhost </VirtualHost> <VirtualHost *:80> DocumentRoot /Volumes/website/site.com ServerName site.local ErrorLog /Volumes/website/logs/apache_error_log CustomLog /Volumes/website/logs/access_log combined <Directory "/Volumes/website/site.com"> Options All Indexes </Directory> </VirtualHost>
sudo pico /etc/hosts
Last edited by angelwatt; Jul 21, 2009 at 06:55 PM.
|Jul 22, 2009, 04:32 AM||#3|
Yes, Angelwatt is correct. Looks complicated, but is all do-able.
The key thing here - which is consistent with what I was finding on the net generally relating to this - is the switching from the default MAMP port 8888 to the standard port 80 setting in order to achieve virtual hosts with MAMP. The two Apache servers (Built-in one and MAMP one) will not run together because ports only support one-at-a-time.
I decided that if I did assign the 80 port to MAMP, I'd want to put into place something else and.... while researching it, decided I'd want to put something else-else into place too... and possibly so-on. So together with my (probably nonesensical) discomfort with running a server from my applications folder I decided (yep, hands up, rather arbitrarily) on another route.
Some resources I came across in my searches/deliberations:
sitepen.com - Super Charge Your MAMP
postpostmodern.com - A Smarter MAMP
Symbolic link production from the desktop - contextual menu plug-in
Hope that's helpful - I've only implemented the Symbolic link plug-in (quite useful in a not-very-often-but-when-it-is kinda way), not undertaken any of the work outlined on the first two sites above. Regards.
Last edited by Kelon; Jul 23, 2009 at 03:53 AM.
|Apr 4, 2010, 02:14 AM||#4|
How do I force my browser get the local data instead of remote?
Hi, I'm a copy/paste developer, so far, and believe it or not, I've managed to create nice wordpress websites.
So now I'm one year later, installing MAMP to have them all (like 8 of them) on my local, or at least the new ones, so I'm experimenting with this and it's very interesting.
I've managed to setup two different websites locally, so when I use them without www, it takes the virtual domain saved in my httpd.conf and my hosts. I expected, when I use www to be taken to the remote site (the remote site is set up without www everywhere)
NameVirtualHost *:80 # # VirtualHost example: # Almost any Apache directive may go into a VirtualHost container. # The first VirtualHost section is used for all requests that do not # match a ServerName or ServerAlias in any <VirtualHost> block. # <VirtualHost *:80> ServerAdmin firstname.lastname@example.org DocumentRoot "/Users/sergio/Sites" ServerName Sites </VirtualHost> <VirtualHost *:80> ServerAdmin email@example.com DocumentRoot "/Volumes/Trabajos/mysite1/site" ServerName mysite1.info </VirtualHost> <VirtualHost *:80> ServerAdmin firstname.lastname@example.org DocumentRoot "/Volumes/Trabajos/mysite2/website" ServerName mysite2.com </VirtualHost>
127.0.0.1 mysite1.info 127.0.0.1 mysite2.com
Is there any way to force the content to be loaded from the local ip?
|Aug 18, 2011, 10:05 PM||#6|
That way if I screw up and accidentally leave in a hard coded link to http://dev.website.com, it won't be a broken link on the live site since the live site will interpret the "dev" subdomain as an alias of "www".
Of course, I have my name servers customized in such a way that it'll honor "dev" as a CNAME (alias) of "www".
BTW, MAMP Pro is totally worth the money. Upgrade from the free version if you haven't done so already. If you work on a lot of different sites or have a habit of testing a lot of different software, the ease of setting up new virtual hosts on the pro version just can't be beat.
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|want to set up virtual host w/mamp pro to access development site with 2 computers||todsu168||Web Design and Development||4||Dec 25, 2009 07:03 AM|
|virtual hosts get 403||mcgarry||Web Design and Development||2||Aug 29, 2009 03:18 PM|
|Virtual Hosts on Leopard||advocation||Web Design and Development||1||May 26, 2008 04:04 PM|
|apache virtual host question||Cybix||Web Design and Development||1||Feb 8, 2007 09:20 PM|
|Staging server on local machine - can't get name-based virtual hosts working||Rower_CPU||Web Design and Development (archive)||14||Nov 18, 2004 12:55 AM|
All times are GMT -5. The time now is 12:46 PM.