If you’re going to do any WordPress development — indeed, even if you want to just test plugins, themes, etc before deploying them to a production site—it will serve you well to learn how to set up a testing environment on your own computer. That way, you can experiment or test things without worrying about breaking a live site.
Fortunately, a package called MAMP greatly simplifies this task.
MAMP originally stood for Mac Apache MySQL PHP. Apache is the most common web server, MySQL is a very popular database, and PHP is the most common server-side language used in dynamic (database-generated) sites.
However, now that there is a Windows version of MAMP, the official line is the the initial M now means my. ( Whatever… )
There are a number of other AMP packages, for Mac, Windows, or Linux—including WAMPServer, XAMPP, Bitnami, and more—but MAMP is very versatile and easy to use, so that’s what we’ll use in the class.
The instructions below will explain how to install MAMP & WordPress on Mac. Windows instructions will be similar.
The first few times you do this, you might find it intimidating or confusing, but soon you’ll be able to set up a new installation of WordPress in a minute or two.
With a few clicks, we can install a web server, a database server, and the php language in a self-contained package on our computers.
With a couple more clicks, we can create a database and configure WordPress to run in our test environment.
Note: if you’re sitting in a class at Langara or Emily Carr, MAMP is already in the lab you are using, so you can just read, rather than do, this first section—which is for setting up a test environment on your own computer.
Download MAMP from http://mamp.info/en/index.html. You don’t need to buy MAMP Pro: the regular version is fine. Once you’ve downloaded MAMP, install it by double-clicking the package.
Two screens in the installation are worth commenting on.
In the Destination Select screen, the Continue button is not available until you click on the Install for all users… option.
In the Installation Type panel, select Customize and deselect MAMP Pro. You don’t need it at this point.
Once you’ve installed MAMP, open the MAMP folder inside the Applications folder. There you will see a folder called htdocs.
That is the folder in which you will put WordPress. Because you will be returning to this folder a lot, drag it into a Finder window sidebar so you can get to it quickly.
Get WordPress & Install it on your MAMP Server
Now go to the WordPress.org website and download a copy of WordPress.
I will typically drag the downloaded zip archive into htdocs. That way, I can later use it to make additional WordPress installations.
In htdocs, unpack the downloaded zip archive by double-clicking. This will create a folder called wordpress. Rename it mynewsite for this exercise.
This way, we can have multiple installations of WordPress to test different sites, designs, etc. Just be sure to use web-safe naming: no spaces, or funny characters, etc.
In the screenshot below, we can see that I have multiple projects going (including mynewsite), each sitting within htdocs. For this exercise, the mynewsite folder is enough.
Create A Database
Start MAMP by double-clicking its icon. This will bring up the main Application screen. If you see two green lights (for Apache server and for the MySQL server), you’re ready to go. If not, click on the Start Servers button.
Once you’ve got the servers running, click the Open Web Start page button on the MAMP screen.
When that page opens, go to the menu bar at the top of the page, click on Tools and select the phpMyAdmin link.
If the phpMyAdmin link is greyed out, go to MAMP Preferences, select the PHP tab, and set STANDARD VERSION back 7.0.15 from 7.1.1.
The opening screen of phpMyAdmin will probably look like this (apart from mine having some already-created databases listed on the left):
Click on the Databases tab. In the Create database field, type in the name of your database (no spaces or funny characters).
I will typically name mine the same as what I named the WordPress folder (in this case, mynewsite) but you don’t have to if you have a better memory than I do. Follow websafe naming conventions.
A security aside: if you were creating a database for a live site, you would want to use an obscure a name as possible, in order to deter people from hacking your site. But since this is just your development environment, you won’t have it exposed to the internet.
To summarize: all you need to do in phpMyAdmin is type a database name into the Create New Database field and then click Create Database.
Once you’ve done that, phpMyAdmin will list the database on the left.
You can now close phpMyAdmin.
Connect WordPress up to the Database
So we’ve created a database. Let’s tell WordPress about it.
To do that, in a web browser go to localhost:8888 (no www in the URL: you’re not on the web, remember). (Another way to get to here is to click on the My Website link in the MAMP Start Page).
This will list what’s inside your htdocs folder. Click on the mynewsite link (or whatever you called your site).
Now you’ll see that the first part of your site’s URL is localhost:8888 + whatever you’ve named your WordPress folder.
WordPress will now ask you to set up your local installation, starting with the language you’ll use. I’m just going to use English (United States), but if you get all teary-eyed about that feel free to choose English (Canada) or any other language.
After you submit your language choice, WordPress will then tell you that it needs to know about your database:
Click the big Let’s Go button. The next step will configure WordPress with that information. If you remember the name of the database you created, you’re in good shape. Use the values in this screenshot. If you named your database something different, use the name you used when you created it. For the other values, use those below:
The Database Username and Password are always root (in your testing environment only: don’t do this on the web!).
For Host and Database Prefix, use the default values.
If everything goes to plan, you should now get the famous All Right Sparky! message.
Click Run The Install, and you will then be asked to fill out the typical WordPress installation details. Site Name, Admin User, etc.
Don’t use root for the admin user here. For this testing environment, consider using, say, your first name for the user name and something easy and obvious for the password. If you forget the password, it’s quite tricky to reset it (unlike on a live WordPress site, where you can get a reset link sent to you).
Enter that info. Click Install WordPress.
Once the installation is complete, you will be presented with the WordPress login screen. Login with the WordPress user you made just now (not the database user root).
An Additional Note for Langara Students
Owing to network restrictions at Langara, if you wish to install themes or plugins in your test environment in the lab, you cannot do it directly from the WordPress dashboard. Instead, you have to download the theme or plugin from the WordPress.org website and manually install it in the test environment.
The paths for this are as follows:
Where YOUR_WP = the WordPress installation you set up according to the instructions above.
You will not have these restrictions on your own computer, just the Langara lab ones.