This is a follow-up to my previous article on installing a LAMP Stack on Snow Leopard and explains the steps that you need to get Lion up and running for LAMP development. (Linux, Apache, MySQL and PHP in case you don’t already know). Lion comes pre-installed with Apache and PHP 5.3.6 so you only need to enable those features. MySQL is the only component that you have to install.
UPDATE: I’ve posted a new tutorial for OSX 10.8 Mountain Lion
1.Turn on Apache
Go to System Settings->Sharing and turn on Web Sharing. If necessary click the button that says “Create Home Folder” which will create a folder called “Sites” in your home directory. You now have a web server that you can access at http://localhost/~username/ (“username” being your own account login name)
2. Edit /private/etc/apache2/httpd.conf
To enable PHP uncomment (remove the number sign at the beginning of) the line:
#LoadModule php5_module libexec/apache2/libphp5.so
(optional) you can re-map the server root to your home website directory by editing DocumentRoot:
If you wish to use .htaccess files then look a bit further down AllowOverride and set it to “All” like so:
Deny from all
3. Edit /private/etc/apache2/users/username.conf
Your user directory has it’s own permissions as well which are located in this separate file. You may wish to enable FollowSymLinks and AllowOverride again here by changing these two lines like so:
Options Indexes MultiViews FollowSymLinks
4. Copy /private/etc/php.ini.default to /private/etc/php.ini
OSX includes a default php.ini file that you can use but you must rename or copy it first. If you don’t do this then PHP will still run but it will just be using the default initialization settings with no way for you to override them.
Edit these settings in php.ini (some of these settings will not come into play until they are installed)
display_errors = On
mysql.default_socket = /tmp/mysql.sock
date.timezone = ‘America/Chicago’
include_path = “.:/usr/lib/php/pear”
5. (Optional) Install PEAR
If you use the PEAR libraries you can install them using the included phar file like so:
sudo php /usr/lib/php/install-pear-nozlib.phar
sudo pear config-set php_ini /private/etc/php.ini
sudo pecl config-set php_ini /private/etc/php.ini
sudo pear upgrade-all
6. Install MySQL
This doesn’t really require instructions, simply download the latest MySQL from mysql.com. I installed the 64 bit version.
7. (Optional) Install Apache Plugins
If you use encryption you may need to install mcrypt. Instructions have been provided by Michael Gracie
If you use the Zend debugger you can install that using these instructions.
These are here for my selfish purposes, install if you so choose!
sudo pear install --alldeps -f Spreadsheet_Excel_Writer