Setting up WordPress locally on Mac OS X

This is specifically for installing WordPress 4.0 and serving it locally using MacOS X built-in Apache.

My recent fascination with WordPress started with me heading to www.wordpress.org and downloading the zipped version. Once downloaded you have to unzip it using tar -xvf command (if unzipping from command line) – or just double click the file in Finder.

To setup WordPress, basically the following are required:

PHP ~ 5.4

MySQL

Apache HTTP server (NOT Tomcat – which is a Webserver)

These should already be available and can be easily checked.

Ensure PHP module is enabled

Go to /etc/apache2 and do a ‘vi httpd.conf’

This folder maybe write protected – so use a sudo if the it complains that the file is in read-only mode.

Uncomment the line:

#LoadModule php5_module libexec/apache2/libphp5.so

and ‘press Esc -> :wq’

That’s it. Now restart apache using ‘sudo apachectl restart’ and you’re good to go.

Just to check if PHP was enabled properly, create a file called info.php at /Library/WebServer/Documents folder and put the following in the file:

<?php phpinfo(); ?>

If you open a browser, and hit the URL : http://localhost/info.php, it should now spit out the entire PHP environment details thereby confirming that the PHP enablement in Apache had gone fine.

Prepare MacOS Apache to server the wordpress content.

The default location of the files being served is /Library/WebServer/Documents. If you can’t find the folder in Finder, Press Cmd + Shift + G, and then enter the location manually.

Next, either copy the unzipped WordPress folder in this directory OR make a new folder inside the above folder (say xyz) and paste the unzipped WordPress folder contents into this.

Now, head over to http://codex.wordpress.org/Installing_WordPress and follow the steps. Just make sure the DB connection details are correct.

WordPress is installed successfully. Enjoy !

Advertisements