Walkthrough: Installing WordPress on an AMP stack

Part 0: AMP stack

An AMP stack will traditionally have the following services, which will let us get a copy of WordPress up and running:

  • Apache: HTTP Server
  • MySQL: Database Server
  • PHP: Server-side scripting language

Installing this has gotten very simple, but you probably don’t want to use these in production, since they’re primarily for development and tend to be stupidly easy to attack.

In order to get WordPress up and running, we need to set up the following things:

  1. Set up database and access credentials
  2. Set up WordPress files
  3. Run the installer

Part 1: Setting up the database

First of all, we need to set up the database. A thing to note: The MySQL instance isn’t secure at all, and has the following details to login:

User: root
Password: root

This is a big security no-no, and you should expect to be fired if you use this on your live sites. When we’re developing though, this is acceptable.

To do all these things, we’re going to use phpMyAdmin, a utility that basically applies a GUI to MySQL.

Creating the database

We’re gonna create a database called _wpminhnguyen. This has two effects:

  1. We know that it’s a WordPress database
  2. We know it belongs to someone named Minh Nguyen

Click on the ‘Databases’ tab, and enter in the name of the database. It’s pretty straight forward since the hard lifting is done by WordPress.

phpMyAdmin interface: Create database - _wpminhnguyen is entered as the database name.
We don’t tinker with the Collation of the database unless we’re using a different encoding scheme. If you don’t know what that means, don’t touch it!

With that done, let’s move on to creating a user!

Creating a user

Clicking on the little house icon to return to the beginning, click on the ‘Users’ tab, and then ‘Add user’.

phpMyAdmin interface. Add user - has five fields: User name, Host, Password, Password confirmation, Generate Password.
You might not know what the second field does. I’ll explain it below.

Oh boy, this looks scary. It’s not all that hard though. The ‘Host’ defines IPs from which we can use the user from, so if you’re into locking things down, that’s what we can do.

We’ll set the dropdown to localhost, so that means we can’t access it outside from the machine, but can use it if something has to execute on the server, like if we need to use WordPress:

003-userfill-fs8
Our example user has a weak password, but that’s for convenience. Use a good password in production!

We leave all the sections below unticked, since it grants a lot more privileges than we need to, and we just need to set it up for our database.

CREATE USER 'Minh'@'localhost' IDENTIFIED BY '***';GRANT USAGE ON *.* TO 'Minh'@'localhost' IDENTIFIED BY '***' REQUIRE NONE WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;

The above is the SQL required to create a user. Thank goodness for phpMyAdmin!

Granting privileges

After creating the user, we need to allow the user to access our newly created database _wpminhnguyen. Clicking on the Database tab below the SQL command, we click on the database we want to access and press ‘Go’.

Since we want our user to be in full control of this database, hit the ‘Check All’ checkbox so we can do all the things… within reason of course.

phpMyAdmin: Database-specific privileges. All options are ticked.
With power comes responsibility… but we don’t want too much responsibility.

With this all done, let’s move on to WordPress!

Part 2: Setting up the WordPress files

Getting WordPress is easy enough. Going to WordPress.org and clicking the download button will give us a file archive containing the software. The tar.gz file is smaller, but if you’re on Windows, it’ll require 3rd party software to extract. The zip file is probably the one you want.

The WordPress.org download page. The download button for .zip and link for .tar.gz are highlighted.
If you’ve seen .zip more than .tar.gz, use the .zip. Otherwise, feel free to use .tar.gz!

After extracting it, you’ll end up with many directories and files (hopefully you extracted it to a new folder):

The directory containing multiple folders and files, which make up WordPress.
This is WordPress. It just needs to get dressed first.

This is what we’ll copy over to the AMP root directory. Your AMP installation will typically have a folder from which it will serve files over HTTP (sometimes called htdocs, or www). In my case, it’s located at /Applications/MAMP/htdocs, but you should check the AMP documentation to find out where it is.

Copy the files from the WordPress directory into the htdocs directory:

006-htdocs-fs8
Your document root folder may or may not look like this.

Now we’re ready to go!

Part 3: Running the Installer

Navigate to your WordPress installation (mine is found at localhost:8888/wordpress/), and hopefully this shows:

The WordPress database starting screen, telling the user it needs 5 things: database name, database username, database password, database host, and table prefix.
WordPress needs some details so it can set itself up. Sounds like a misnomer, but it’s true!

The next page, fill in the database details and credentials from what we created above:

The form to insert database name, database username, database password, database host, and table prefix. All the fields are filled in
Using your name as the a database password is not advised. Don’t do it.

With that done, WordPress has enough information to start working! Pat yourself on the back and look at this image of a cute puppy:

A very cute labrador puppy, named Nori. 9 weeks old
Aww, so cute! Photo by Melanie, CC BY-NC-ND 2.0

After a few moments, we’ll need to fill in details for our site. This includes things like what we should call our site, as well as credentials to access the WordPress dashboard. Don’t mix this up with our MySQL credentials!

Once you’re done, just sign in with the details you just got, and if you see this next screen, you’re done!

The WordPress.com dashboard, welcoming the admin user and making suggestions to customise the site
This would be familiar to you WordPress.com users if they didn’t change the interface…

Here’s how my installation looks like from the base directory:

The default WordPress site.
If there’s a header image, it sure isn’t showing!