Setting up a local server on your Mac with MAMP, Wordpress and Coda - Chris Allen

Setting up a local server on your Mac with MAMP, WordPress and Coda

Working off a live server is fine, but what happens if you are in a situation where your connection is down or you need to work or demonstrate online features where your connection might be compromised (i.e. reduce the egg on your face factor).

This is where MAMP comes into play.

MAMP stands for Macintosh, Apache, Mysql and PHP, which basically means we can set up a local server on our very own Mac, perfect for building a test environment for your next WordPress site or any project that you might need to take your laptop to a client or presentation.

MAMP is used on a Mac, there are alternatives for other systems…

  • WAMP on Windows
  • LAMP on Linux
  • SAMP on Solaris
  • FAMP on FreeBSD

There are a few tutorials online that cover the above, but we’ll be sticking to MAMP.

What you’ll need for this tutorial ..

What you'll need

1. Install WordPress

Install WordPress and open your download, and to make things a bit easy and simple-ise (!) things in your download find and rename the folder ‘WordPress’ and call it something more memorable, we’ll use ‘chris-allen’ for this tutorial.

Drag the whole WordPress site (chris-allen) onto your work area, I like to put all my sites in the sites folder

Screen Shot 2015-07-25 at 13.58.56

2. Install and setup MAMP

Download MAMP, the standard version is fine for doing what we need, they’re is no need to pay for stuff we don’t really need at the moment.

Open the downloaded software and run an install, once MAMP has finished installing everything, press Preferences and then Apache we need to define the document root, so MAMP knows where you are going to be storing all the files for your local server, if you press select and navigate to the containing folder we just used, mine was Sites

tut-01-pic2

If you are using the above image as a guide, replace *yourusernamegoeshere* with your OSX username. Then click ok and your MAMP control panel should be displaying green status lights ! Your Mac is can know act as a local server !

tut-01-pic3

If you open your browser http://localhost:8888/ this should display whatever is stored in the localhost (the folder inside ‘Sites’ we declared before.) As can be seen, here we can find the WordPress site we added at the beginning.

We now need to attach a database to the local server (your Mac). Open the MAMP control panel at http://localhost:8888/MAMP/ and click the phpMyAdmin tab. We need to create a new database so if we add the name of the new database in the box, I’ll use ginger-beard. Then clock OK to create it.

3. Setting up WordPress

Now we have set up MAMP and created a database we can setup WordPress/ and get started. Firstly we need to change a few of the server settings in WordPress so it’ll work with our new local server.

Go back to the WordPressfolder we added at the start, mine was located in /Sites/ and find the file

wp-config-sample.php

and rename it to

wp-config.php

Open the file we’ve just renamed and change the database name (DB_NAME) to the title we gave it in the MAMP Admin panel, i used ginger-beard and change the username (DB_USER) and password (DB_PASSWORD) to root:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'ginger-beard');

/** MySQL database username */
define('DB_USER', 'root');

/** MySQL database password */
define('DB_PASSWORD', 'root');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

We should now be up and running, so lets install WordPress if we go back to our browser and go to the WordPress site we have downloaded at http://localhost:8888/ginger-beard/, remember to use the name we set when we renamed the wordpress folder in the sites folder at the start. Complete the quick WordPress installation process.

4. Accessing everything inside Coda

Now we have set up both WordPress and your MAMP local server we can use Coda to code some of the wordpress pages and maybe add features like SVN if we want to.

Firstly download Coda you can use the free trial for a while, its a great piece of software and only costs $99/£65ish which i think is amazing value for the money for the amount of features it has and the time your going to spend in it.

Once Coda is up and running we can create Sites which can be used for quick access to the projects we are working on, in the sites tab press Add Site and enter the following details.

tut-01-pic7

We don’t need to worry about any of the other sites for a local server, just the settings mentioned in the Site section. In the Local Root, remember to change *URNAME* to your OSX username.

Your local server should now we working and you can work on your WordPress site locally, if you have any questions, don’t forget to ask away !