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.
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.
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:
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.
- Open /private/etc/hosts in a text editor. You need to be able to view hidden files to see this folder on the root.
- Find the line that says:
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
- Save the file.
- 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.
- 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.