Setup LAMP Stack on Mac OS X Lion

I have just upgraded my old iMac to Mac OS X Lion, just documented down the process for setup LAMP Development environment, of course there is easier solution like using the MAMP all in one package.

First install Homebrew, so call the missing package manager for mac , it has become lots of OSX based developer favourite package manager. The Installation is only one line , just fire up your terminal and run it.

[box type=”info”]/usr/bin/ruby -e “$(curl -fsSL https://raw.github.com/gist/323731)”[/box]

Once Homebrew installed, let’s start the LAMP stack with MySQL first.

[box type=”info”]brew install mysql[/box]

once the downloading and installation done, follow the instructions to setup MySQL run as your user account.

[box type=”info”] unset TMPDIR[/box]

[box type=”info”]mysql_install_db –verbose –user=`whoami` –basedir=”$(brew –prefix mysql)” –datadir=/usr/local/var/mysql –tmpdir=/tmp[/box]

after this you  will be able to start the MySQL with [highlight]mysql.server start[/highlight]

MySQL are ready art now, time for Apache and PHP, which come with Mac OSX Lion, but there are some changes need to apply on the Apache config.

[box type=”info”]Chmod 755  /etc/apache2/httpd.conf  and open in your text/IDE editor[/box]

Enable the PHP library for Apache on line 111.

[box type=”info”]remove the  # from #LoadModule php5_module libexec/apache2/libphp5.so[/box]

You can skip this part if you are ok with using the GUI to start the Apache, if you prefer to start the Apache with terminal, this has to be done in order for the Apache Setting to kick in.Comment out 2 line of setting line 609 and 631.

[box type=”info”]Comment out ( add a # in front) <IfDefine WEBSHARING_ON> and the enclose [/box]

uncomment lin 624 , this allow the vhost kick in even the web sharing is not turn on.

[box type=”info”]remove the #  from Include /private/etc/apache2/extra/httpd-vhosts.conf[/box]

you can start configure the vhost in this httpd-vhosts.conf

Once all the setting are in place,start the Apache in terminal/GUI

[box type=”info”]sudo apachectl start OR check the check box at Preference ->Sharing->Web Sharing[/box]

create a standard PHPINFO script to test is the PHP running.

Update 1/10/2011 add your username on line 157 this will fixed the can’t access site issue.

You may also like...