If you happen to do a lot of WordPress development and your tool of choice is a Mac, then setting up a local test environment can be a bit challenging, but necessary. Nothing can be more time-consuming and frustrating than having to upload changes, test online, back out changes, etc. The best part is when you're developing new access-control-lists for your blog and everything looks good to you. This happened to me a few days ago and when I viewed my site via another browser, I realized there were no pics. They were blocked. Yea!
Anyway, local development and testing is a great thing. But sometimes it's more hassle than it seems worth it. After all, I'm sure there are many out there who are perfectly comfortable editing files in TextEdit
So, this should get you up and running with the latest elements in a matter of minutes:
- Download the latest version of wordpress. In my case, I'm using version 2.7.
- Regardless of whether the file is in zip or tarball, you'll need to extract the contents to where your Mac is configured for serving its web direcories. By default, this is in /Library/WebServer/Documents. The file will decompress as wordpress, so the full path will be /Library/WebServer/wordpress. You can always change the name of your wordpress directory to the name of the site.
- You'll need to copy the wp-config-sample.php file to wp-config.php.
- Of course you'll need to modify the resulting wp-config.php file to point to the proper database. There are essentially three changes to be made. For example:
- You can use whatever editor you'd like.
- Download the latest version MySQL. I'm using the 5.1.3 package format for x86_64 (Intel Macs). Once you decompress the package, simply run the package installer. It will do the bulk of the work.
- Download the fixed version of the MySQL control pane. You'll need to unzip it. Then simply double click to actually install it in your Preferences. After it's installed, you'll need to startup MySQL.
- Modify your /etc/apache2/httpd.conf file to remove the comment in front of LoadModule php5_module. You can do this easily by simply opening a Terminal and then typing 'sudo vi /etc/apache2/httpd.conf'. To quickly get to the line you're looking to change, just type ':' to go into command mode. You'll have a cursor right after the colon. Then type the following '%s/#LoadModule php5_module/LoadModule php5_module/g'. This will look get rid of the comment. Simply hit :wq to save the file. This enables the php5 support in Apache.
- In your Preferences=>Sharing=>Web Sharing, click on the check box to enable the Web Server.
- You're going to need to set your root password for MySQL. There are three interfaces we're going to do this for and then we're going to create our first database. To do this, you'll have to go into mysql's interface by typing 'mysql -u root':
MySQL:
-
SET password for root@localhost = password('yourpassword');
-
SET password for root@127.0.0.1 = password('yourpassword');
-
SET password for 'root'@'hostname.local' = password('yourpassword');
-
CREATE DATABASE dbname;
-
GRANT all PRIVILEGES on dbname.* to db_username@localhost identified BY 'you';
-
SET password for db_username@localhost = old_password('db_password');
-
quit
-
- If you haven't figured it out, I've made the MySQL entries correspond to the entries in your wordpress configuration file.
- That's pretty much it. You should simply have to point your browser to http://localhost/sitename/ to see things actually running. WordPress will take care of setting up the various tables for itself.
Enjoy!
02/01/2009 at 8:58 am Permalink
I very liked this post. Can I copy it to my site?
Thanks in advance.
Sincerely, Timur Alhimenkov.
02/01/2009 at 9:59 am Permalink
I really liked this post. Can I copy it to my site?
Thank you in advance.
Sincerely, Timur.
03/01/2009 at 8:53 pm Permalink
Timur: Sure you can. Thanks!