Installing ExpressionEngine locally using MAMP

June 10th, 2010 • 4

This is the first is a series of weekly posts on useful tips and tricks for EllisLab‘s ExpressionEngine that I’ve picked up along the way from the forums, training classes and my own experience.

ExpressionEngine continues to grow in popularity, but it can seem very complicated at times, especially if you’re coming from another publishing tool such as WordPress. With these posts, I’m hoping to ease the transition of new ExpressionEngine developers as much as possible.

The first thing that we’ll look at is how you can get ExpressioneEngine to run locally on your own computer. The benefits of this are:

  • It speeds up development quite a bit (possibly the biggest benefit).
  • You don’t have to be online to work on a site
  • You have a sandbox area where you can easily test new extensions, modules and plugins.
  • You can set up a base EE install with all of the plugins, extensions and modules that you use on every project, and then simply move this over to your next project’s webserver so you don’t have to reinstall and reconfigure every EE install that you do for new projects. More on this in a later post.

Download and Install MAMP

Note: I’m using a Mac, so these instructions will obviously be Mac-centric, but there is a Windows-equivalent tool – XAMMP – which is very similar.

We’ll be using MAMP, which stands for Mac, Apache, MySQL and PHP, to create a local webserver. So the first thing you need to do is head over to the MAMP site and download a copy of MAMP, which comes in two flavours.

MAMP

The free version, which would be quite adequate. But if you want to create multiple virtual hosts you’ll need to do a bit of manual editing of files.

MAMP Pro

This version costs $60 and easily allows an unlimited number of virtual hosts and comes with a few other features, in addition to a nicer user interface.

Whichever one you download, simply over the .app files into your Applications directory after downloading and you’ve installed MAMP.

Open up MAMP, and there are two settings we’d like to change in the preferences tab.

Click on “Set to default Apache and MySQL ports”. This will make it so that you don’t have to append :8888 to your virtual host’s name every time you want to access your site. So instead of having to go to http://localhost:8888 you can now simply go to http://localhost and it will work perfectly fine.

You may also want to go over to the Apache tab and change the default folder and instead use something like your Sites folder. The path to that would be /Users/[username]/Sites. We’ll do this because we’ll eventually be hosting multiple virtual hosts locally so we don’t want to use the htdocs folder in the MAMP directory in our Applications folder. We’ll create a folder named “default” in our Sites folder and it is here that we’ll install ExpressionEngine.

Download and Install ExpressionEngine

The next step is to download ExpressionEngine. You can either download the Core version or if you’ve already paid for a Personal or Commercial license you can use it. You are free to use a Personal or Commercial license locally for development purposes only in addition to having it being used live on a website. As always, let the license guide you or contact the support group at EE if you have any questions.

Go ahead and follow the installation instructions. The default MySQL connection information for a MAMP installation is:

Host: localhost
Port: 3306
Username: root
Password: root

Once complete you should be able to visit http://localhost in your browser and have the default ExpressionEngine site appear.

Create multiple virtual hosts for each site that you will be working on

At some point you’ll need to have more than one virtual host to work on different sites, or keep different base installations of ExpressionEngine. As I mentioned before, MAMP Pro makes this process really easy by simple clicking on the Hosts tab and adding the names and directories of new virtual hosts.

However, you can create multiple virtual hosts with the free version of MAMP. My recommendation would be to create new folders right in your Sites directory for the other virtual hosts that you may need so you can keep them all in one place and allow for easy backups.

  1. Open /private/etc/hosts in a text editor. You need to be able to view hidden files to see this folder on the root.
  2. Find the line that says:
    127.0.0.1	localhost
    

    And simply add the name of the new virtual host that you want. We’ll create a new virtual host named base-ee.dev. So the line now becomes:

    127.0.0.1	localhost base-ee.dev
    
  3. Save the file.
  4. Go into your Sites folder and create a new directory. The directory can be named anything, but to make things easy to keep track of, we’ll name it base-ee.dev. You should already have a directory in your sites folder named default which contains the ExpressionEngine installation.
  5. Open the /Applications/MAMP/conf/apache/httpd.conf file and adding the following code at the bottom:
    NameVirtualHost *:80
    
    < VirtualHost *:80>
    ServerName localhost
    DocumentRoot "/Users/myusername/Sites"
    < /VirtualHost>
    
    < VirtualHost *:80>
    ServerName base-ee.dev
    DocumentRoot "/Users/myusername/Sites/base-ee.dev"
    < /VirtualHost>

    Removing the space between the < and the /VirtualHost>

And there you go, you should be able to access http://base-ee.dev in your browser and have it show up whatever is in your directory (there’s nothing there as yet, but you can drop in a simple test.txt file with some text in it to ensure it’s working).

So that’s the end of the first entry in this series. If you have any questions, feel free to ask in the comments. You can also add suggestions for future installments.

Filed under Development, ExpressionEngine.

Follow me on twitter and subscribe to the RSS feed.

4 Responses to “Installing ExpressionEngine locally using MAMP”

  1. Steven Grant June 10th, 2010 at 1:26 pm

    Good to see more EE tutorials out there for the newbies. I’ve started to share more of my template code as well through Train EE.

    I’m thinking about building Code EE as a place to share template snippets.

  2. tony June 10th, 2010 at 1:54 pm

    Thanks Steven. Code EE sounds like an interesting idea!

  3. Troy September 8th, 2010 at 5:08 pm

    Great info. We have never tried to install locally as a sandbox. It seems like it would be a pain to move to the live server, moving the database, EE and all the permission/link changes.

  4. Tony September 8th, 2010 at 5:39 pm

    Hey Troy, thanks for commenting. It is a bit tedious at first, but really once you move one site over it becomes really easy to do. It basically boils down to:

    1. Moving over all the files
    2. Exporting your local database and importing it on the remote host.
    3. Using Deploy Helper to changes all of the URLs and path info.

    Developing locally is so much faster that I do as much work as possible locally and then move over to the remote server when it’s a good time to have the client start working on it in preparation.

    You might find this forum thread useful: http://expressionengine.com/forums/viewthread/161130

Subscribe to RSS Feed

RSS feed