Setting Up A Local Server Environment with MAMP

Today I wanted to show you how easy it is to get a local server environment up and running on your Mac. This tutorial will be specifically for Mac users.

Before we can get started, we need to download MAMP and install it on your machine.

Editing the Host File

Now we need to edit the host file to map our local host ip to the pretty http://lumen.development/

Open up your command line terminal and run:

sudo nano /etc/hosts

If you don’t have that file run: touch /etc/hosts then run the above, but you should have it.

Once you are editing the hosts file, add a line for this project, I went with this pointer for this example:

###########################
## LARAVEL / LUMEN SITES ##
###########################
127.0.0.1       lumen.development

So this is a little generic, but for the above line, it creates a pointer for http://lumen.development/ on your local environment, allowing you to have some custom urls for projects. You can and should change lumen to something a little more project specific.

Updating the Apache vhost Config File

Now we need to set up apache to point to our Lumen site’s file directory along with the reference we made above so that you can actually navigate to http://lumen.development/

Open up your command line terminal and run:

cd /Applications/MAMP/conf/apache/

Open this directory in your favorite code editor and then open the file: /extra/httpd-vhosts.conf and add the following

<VirtualHost *:80>
    DocumentRoot "/Applications/MAMP/htdocs/[project_directory_here]"
    ServerName lumen.development
</VirtualHost>

Again, keep in mind, change the appropriate pathing/namings to fit your preferences.

Edit httpd.conf If Needed

If this is your first time using a vhost with MAMP, you’ll need to do one extra step.

Head over to the file: /httpd.conf and uncomment the following line.. (file line number ~585)

# Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf

The include, correct example shown above, should no longer have a # in front of it.

Save that and we are good to go! Restart your MAMP server and you should be able to navigate to the url desired…

Load 0 Comments