Today I had the joy of installing an old Magento version on my local MAMP setup. Most everything went well. I first tried to install the old sample data with it but the download that was available was obviously not correct, resulting in tons of SQL errors. So I decided to just install it clean with no sample data. Everything went fine until I tried to log into the admin and PHP can’t store the session into a TLD like localhost, so it was time to fire up some virtualhosts with period in them so that Magento can work, cause…
Remember when I said PHP was the Nickelback of programming languages? I apologize. That was unfair to Nickelback.— Jeff Atwood (@codinghorror) January 8, 2013
Seriously, you should read more if you’re thinking about learning PHP.
But, onto MAMP. First we need to set up virtualhosts on our Mac. Open terminal or iTerm2 and edit your hosts file like this:
sudo nano /etc/hosts
Change the 127.0.0.1 line to add additional “domains”.
127.0.0.1 localhost magento.loc
In this case magento.loc will be the address that we can view our dev site at. You can add as many as you want. An additional one for wordpress for instance would be:
127.0.0.1 localhost magento.loc wordpress.loc
You ge the idea. Save the file by hitting ctrl+x and hit enter.
Now we need to add virtual hosts to MAMP so it knows where to point apache to serve these sites from. To do that edit /Applications/MAMP/conf/apache/httpd.conf and uncomment (remove the # before) line 525 so it looks like this.
Then open that file and lets set up the virtual hosts by changing the example
<VirtualHost *:80> ServerAdmin email@example.com DocumentRoot "/Applications/MAMP/htdocs/magento" ServerName magento.loc </VirtualHost>
Obviously the DocumentRoot needs to point to the folder that is set in MAMP apache settings. The above example points to the default MAMP document root of htdocs with a magento folder inside it. Now I can point my browser to magento.loc:8888/ and have it serve the site correctly. And I can log into the admin. Yeah!comments powered by Disqus