This is my note on how to to install Apache, PHP and MySQL on a an OS X box. Although some of these applications are come with the operating systems, it is always good to know how to upgrade them to the latest version.
1. Apple Developer Tools and Mac Port
Before installing Mac Port, you will need the Apple Developer Tools. You can download it from the Apple Developer’s Network.
After installing Apple Developer’s Tools, you can install Mac Port. You can get it from the here.
Update Mac Port
sudo port selfupdate
Add the Mac Port path in the profile: ”’~/.bash_profile”’:
Install MySQL from Mac Port:
sudo port install mysql5
Go to the [http://dev.mysql.com/downloads/mysql/5.0.html#macosx-dmg MySQL’s website] to download the package.
Setup the a master password for root user:
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
Add the MySQL path in the profile: ”’~/.bash_profile”’:
Install Apache from Mac Port:
sudo port install apache2
Open the configuration file: ”’/opt/local/etc/rc.conf”’ and add the following at the end of the file:
Install PHP from Mac Port:
sudo port install php5 +apache2 +mysql5 +pear
When that is done, register PHP 5 with Apache 2:
sudo /opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so
And create a php.ini file (which you can edit to configure PHP 5):
sudo cp /opt/local/etc/php.ini-dist /opt/local/etc/php.ini
Edit the Apache configuration file ”’/opt/local/apache2/conf/httpd.conf”’ and add the following lines to the end of the file:
AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
Replace this line:
by the following:
DirectoryIndex index.php index.html
If the MySQL is installed from package rather than from Mac Port, we need to modify the mysql.default_socket value.
mysql.default_socket = /tmp/mysql.sock
Install MemCached from Mac Port:
sudo port install memcached
sudo port install php5-memcache
We need to enable MemCached in PHP5.
First, we need to add the following in ”’/opt/local/etc/php.ini:”’:
extension_dir=/opt/local/lib/php/extensions/no-debug-non-zts-20060613 extension = memcache.so
Run the following command to start MemCached:
sudo /opt/local/bin/memcached -d -u nobody