Jump on it. Apache 2 comes with OSX by … 

Jump on it.

Apache 2 comes with OSX by default. It can be activated using the system settings sharing panel. However, Apple customises this distribution of Apache to do one thing very well: share the sites folder on one’s computer. In order to get around this, and to avoid any potential issues with system updates overwriting server settings, I began from scratch with a fresh tarball, directly from the Apache people.

I learned the tar command, and used it to unzip the tarball. The modifiers x,v,z, and f are applied. X sets the tar operation to extraction; tar can also compress archives, inspect them, and so on.. V asks tar to operate in verbose mode, f uses the file ‘archive’ to unpack files and folders, rather than the compilation dependent source location, and z tells tar to use the gzip library to decompress tarballs.

Once the installation files are unzipped, I navigated into their directory, and ran the configure script included. This creates installation files optimised for the setup of my particular computer.

I ran the make script generated to build an installation for the laptop. Lastly, I sudo ran the make install script, to install the server with administrative privileges.

The final step is to start the server. Inside the /usr/local/apache2 folder where apache’s default install puts itself, there is a bin folder, and therein a script called apachectl. This script handles starting, stopping, and restarting the apache server, and must be run as an administrator.

Using the VI text editor, I set the home directory for apache, in apache’s httpd.conf file. I then create a short html document for testing purposes and placed it in this home directory. To test that the server is working, I pointed a browser at http://localhost.

After some careful checking of settings, the html file loaded. Time to get PHP running!