Prerequisites / WordPress Dependencies
Local Apache web server with PHP & Mysql.
If you don’t already have your local dev environment set up, consider installing MAMP or MAMP Pro. MAMP is a one-click install which will provide you with a clean, isolated stack for local development that has Mysql and PHP pre-configured. Another benefit of MAMP is that it is very popular so there are countless tutorials and examples to follow.
If for some reason you don’t want to use MAMP or you’ve already configured your local enviro somewhat but you still need PHP and/or MySQL, check out this article: Install and Configure WordPress on Mac OS X Snow Leopard Step-By-Step by awilliams of Thermal Exposure. It takes you from zero to WordPress using Leopard’s built-in Apache server, although I do recommend you supplement these instructions with these tips and my other article Install Mysql for Local Dev on Mac OSX 10.6
Download and extract the latest WordPress package.
Move it somewhere good like in your /Sites/ folder (most usual place but depends on your config, it can go anywhere you desire so long as your local web server is configured to look there).
I moved mine to
/users/me/Sites/wordpress and renamed ‘wordpress’ to ‘wptest.loc’ resulting in:
/users/me/Sites/wptest.loc. You can rename it whatever you want – probably the name of your project or client’s site is a good idea.
WordPress needs permission to modify files during installation and runs as user “_www” so make sure it can do this.
sudo chown -R _www wptest.loc
sudo chmod -R g+w wptest.loc
Create a Database
Now we need a database, a database user and a password. Technically you can use any user or add WordPress tables to an existing database but I like to keep things separate so it’s easy to port elsewhere or start over without worrying about wrecking other things. I’m going to create a database called wptest, database user named wptest_user. You can do this using a GUI (phpMyAdmin, etc.) but I guarantee you cannot do that faster than I can type this ;)
bash > mysql -u root -p
mysql > create database wptest;
mysql > GRANT ALL ON wptest.* TO wptest_user@localhost IDENTIFIED BY "secretpassword";
mysql > exit
Configure Site Address
Remember how I renamed the
wordpress folder to
wptest.loc? This is because I plan on accessing it in the browser via http://wptest.loc instead of http://127.0.0.1/ or http://localhost.
To do this I use Virtual Hosts in my environment and point the virtual domains to my local IP address in my hosts file. It’s confusing at first but once you do it a time or two it will be second nature. It’s important if you’d like to work on multiple sites on your local environment concurrently and don’t want to rely on weird subdirectories or other work-arounds that wouldn’t easily port to a live web server.
Setting Up Virtual Hosts on MAMP explains how to set this system up. I provide only abbreviated steps below (MAMP not assumed).
Setting up Virtual Hosts (in short)
- In your httpd.conf file there should lines like this:
# Virtual Hosts Include /path/to/your/httpd-vhosts.conf
- In your httpd-vhosts.conf file there should be a line like this:
NameVirtualHost *:80 Include /path/to/your/httpd-vhosts.conf
Create A Virtual Host
Now, whenever you want to create a new virtual (local only) site:
- In your httpd-vhosts.conf file add an entry like this:
<VirtualHost *> ServerName wptest.loc DocumentRoot "/Users/me/Sites/wptest.loc" <Directory "/Users/me/Sites/wptest.loc"> Order allow,deny Allow from all DirectoryIndex index.php index.html </Directory> </VirtualHost>
- In your hosts file (mine is /etc/hosts) add another entry for your local IP:
Point your browser to http://wptest.loc
If no config file is found you can edit it yourself,
wp-config.php and adding the correct information for the database you created. Try using
18.104.22.168 as the Dataase Host if
localhost doesn’t work.