Mac Apache2 Mysql5 Php5.3+
[MAMP 10.7.2]
Posted by johnny on Monday Jan 9, 2012 Under Tutorials Notice: Undefined index: share_plugin in /var/www/huement.com/blog/wp-content/plugins/gigya-socialize-for-wordpress/resources/handlers.php on line 38

Getting it to work
Alot of people, like myself, are not real happy with the newest version of OSX server. Its an app you install via the App Store. It will likely break anything you have done on mac servers previous versions. No more /Library/WebServer/Documents for your default folder. Its now /Library/Server/Web/Data/Sites/Default/. Yeah. SIX DIRECTORIES DEEP! I want /var/www like a LAMP server. Is that to much to ask? Apparently. One would think things would just work, (it is apples mantra), like you could just, get to hosting. As everyone knows however, one does not simply, umm, do that thing..
Step One. Server App
I am going to assume you already have OSX Lion Installed. Next, we are going to setup our webserver. This is the easiest thing to do, or is it… Just get the app from the app store, and click it. Yeah. Boom. It will guide you through setting up everything. Mail, VPN, Push notifications, its all sooo easy. Until you get to your webserver. What a nightmare. The server app will be almost no help for setting up a traditional Mac Apache Mysql PHP [MAMP] webserver.
The server app will assist you with the Apache part, and you will now have Apache2 up and running. Visit localhost or your servers WAN or LAN ip to see this….

EDIT: Lion Server.app is only half the battle. Get Lion’s ServerAdminTools
I did not find this out until many hours into my Lion Server Install. I think alot of the butthurt hate from the switch to snow leopard server to lion server could be alleviated if people installed all the server tools. However when I installed the server app, it made no indication I could install more tools, or that more tools even existed. You are GOING TO WANT to download and install this. Its like another 200MBs of Mac Server that you’re missing. Thanks to this review I found the link. macgasm
Server Admin Tools Download Link
Step Two. Cold Hard Realities
So that looks neat. You can also click a button and have PHP instantly enabled. Saving you all that time of uncommenting one line! Thanks apple. What a time saver. From here on out, you can just close the server app. It will no longer assist you in your web serving/hosting needs.
Enough Boo Hooing, Lets keep going with our MAMP setup. Next we need the M and P. or Rather MySql and PHP. I used this tutorial (I have a few notes below this before you start) (pops) http://akrabat.com/php/setting-up-php-mysql-on-os-x-10-7-lion/ for getting PHP and MySql setup. He also has a link for getting mcrypt setup and PhpMyAdmin.
Notes on that tutorial: I skipped phpunit and the symphony setup. If you dont use those frameworks, you dont need them either.
At the end of the tutorial there is a link for the installing the mcrypt extension on Lion. If you want to have PHPMyAdmin installed YOU NEED THAT. Also, before you start to install MCrypt, you will likely need to click his download links and get could potentially get the wrong thing. The first file your told to get, pay attention!! you dont want to download mcrypt, you want to download libmcrypt. The download link at the top of the page is for mcrypt. Its like 3 more pages in to get the libmcrypt link.
Here is the actual libmcyrpt download link.
http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz?r=&ts=1326152550&use_mirror=superb-sea2
And in case you missed it, here is the libmcrypt tutorial Link: Lion LibMcrypt Tutorial
Once you have gone through BOTH the tutorials, you should be able to visit your phpinfo() (info.php) script and see something like this:

PHPMyAdmin can be installed now, so lets get on with it. Download PHPMyAdmin from their website.
Then either use the terminal or finder to
- unpack it
- move it to /usr/local/
- rename it to phpMyAdmin
sudo ln -s /usr/local/phpMyAdmin/ /Library/Server/Web/Data/Sites/Default/pma
You should now be able to visit http://localhost/pma and see your phpMyAdmin install.

Checkpoint Reached
You should now have [M]ac [A]pache2 [M]ySQL [P]hp Setup on your Lion Server and be capable of admin’n everything. PHP, Pear, Pecl, phpMyAdmin and mcrypt have all also been installed. Phew. But we can still only host one website. To enable hosting of multiple websites we will need to configure virtual hosts. In Snow Leopard this could be done through the server application, not so in lion. You will need a good text editor and the terminal to get virtual hosts to work in lion.
Open up your httpd.conf file for apache2 in a text editor. It’s located in /etc/apache2/httpd.conf
Next edit it to look something like this (just replace with your info):
... # Virtual hosts Include /private/etc/apache2/extra/httpd-vhosts.conf ...
If you want to change your server root back to what it was in snow leopard, edit the file 0000_any_80.conf in /etc/apache2/sites folder to look like this.
ServerAdmin you@your_email.com DocumentRoot "/Library/WebServer/Documents" ... Options All +MultiViews -ExecCGI -Indexes AllowOverride All
Next we need to edit etc/apache2/extra/httpd-vhosts.conf. So open it up in your editor of choice, and edit that to look something like this, but again, with your information.
NameVirtualHost *:80
DocumentRoot /Library/WebServer/Documents/site1.com
ServerName site1.com
Order allow,deny
Allow from all
DocumentRoot /Library/WebServer/Documents/site2.com
ServerName site2.com
Order allow,deny
Allow from allNow this should enable virtual hosts on your OSX 10.7.2 Lion Server. Congrats. You could actually host alot of stuff now. Multiple sites, latest php version. Also if you are looking for a package manager and are sick of macports, checkout HomeBrew!



