July 8th, 2006 Posted in MAC OSX | 1 Comment »
This post discusses the installation of Apache 2.2.2and PHP 5.1.4 on Mac OS X 10.4.7. Initially I tried to build the open source applications and install but after a few attempts I decided to use DarwinPorts to automatically build and install these two applications.This weekend I decided to upgrade my apache and php versions on my MacBook to the latest version. I searched the web for any existing articles regarding this upgrade and came across the following article:
Building and Installing Apache 2.2.2 and PHP 5.1.4 on Mac OS X 10.4.6
I had no problem building and installing Apache 2.2.2, at least after I installed XTools from the OS X development disk. During the make of PHP there was an issue with dependency. After doing more research others having the same problem had to buid php with mySQL 4.x instead of 5.x. I decided to utilize DarwinPorts to build and install the open source software.
I downloaded and installed DarwinPorts-1.2.1. After DarwinPorts was install I peformed the following steps to install apache2:
- Build and install Apache2.
sudo port install apache2
- Create a default conf file for apache.
cd /opt/local/apache2/conf
sudo cp httpd.conf.sample httpd.conf
- Start apache2 on startup.
sudo launchctl load -w /Library/LaunchDaemons/org.darwinports.apache2.plist
When apache2 is installed the default DocumentRoot is /opt/local/apache2/htdocs/. I modified the DocumentRoot to point back to the default OS X location of /Library/WebServer/Documents/.
I would refer to the apache2 documentation to configure the httpd.conf according to your requirements.
To start apache2 execute the followng command:
sudo /opt/local/apache2/bin/apachectl -k start
The following steps were followed to install php5.
- Install wget which is required by php5.
sudo port install wget
- Build and install php5.
sudo port install php5 +apache2 +mysql4
- Register PHP with Apache.
cd /opt/local/apache2/modules
/opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so
- Create php.ini file
cp /opt/local/etc/php.ini-dist to /opt/local/etc/php.ini
One other article was useful in installing apache2 using DarwinPorts: DarwinPorts:MAMP
I hope this post helps in setting up apache2 and php5.