Embracing Everything.

How to setup an AMP environment running Laravel And MariaDB locally

I personally find the nicest repo of Laravel to be Chris Borgia’s Radiate package. It nicely pulls together some of the best bits of the web including version 4 of the excellent PHP framework and all the basics you’ll need with tastiest front-end kit like HTML5 Boilerplate, Font Awesome, Sass, Twitter Bootstrap and simple register form.

Note: As you’ll notice with most of my posts, I assume you’re using a Mac. If not, buy one! You’ll also need sudo permissions

So, to get started, let’s prepare the environment…

You’ll need Xcode install, so if you haven’t got it, go grab it from the Apple Store, then install the command line tools:

Now create a new folder for your project (I use PhpStorm to set this up)

$ cd /Users/leemcintosh/Sites/
$ mkdir myproject

Now let’s configure Apache to run your website…

To make things easier where permissions are concerned, I would recommend running Apache as your local user. This will allow you to set your VirtualHost to point to your local project without encountering permission issues).

VirtualHosts make it easier to run your projects locally and there are a number of ways to set up a VirtualHost environment in Apache, I’ll show you how to add multiple websites using the “sites-available” folder…

At the end of the file, add the following

Include /private/etc/apache2/other/*.conf
Include /private/etc/apache2/sites-enabled/*

Save the file

$ cd /etc/apache2/
$ mkdir sites-available

We’ll add “sites-enabled” shortly, once we’ve configured your new site first

Save the file (ctrl+x then Y), and now copy that to the “sites-enabled” folder, on Linux distributions you can use the a2ensite command, but on a Mac you have to do things manually using a symbolic link (symlink)…

$ ln -s sites-available/ sites-enabled

Now that we have our site configured, we must trick our browser into believing that the website is on the Internet, we do that by forcing an entry in our hosts file…

$ nano /etc/hosts

At the bottom of this file, add your new project

127.0.0.1 dev.myproject.com

Save the file, clear the dns cache and then restart Apache

$ dscacheutil -flushcache
$ apachectl restart

You should now be able to visit http://dev.myproject.com (obviously replace myproject and name with your own) and it will load the web application under /Users/leemcintosh/Sites/myproject/.

If you don’t see the website, check Apache

$ apachectl configtest

From that you should be able to see any errors that have occurred. Simply rectify and restart Apache. If problems still persist, either tail the logs as defined in the VirtualHost configuration, or contact me!

Download the Laravel framework and components…

Clone Radiate into your new project (you’ll need an ssh key mapped to github for this part)