In five easy steps, you can install Laravel and get it set up on your system.
Before you install Laravel, you will need to check that you have all of the required elements, as follows:
Laravel requires a web server environment and will run in Apache, IIS, and Nginx easily. Laravel should run in any server environment that supports PHP. The easiest way to set up a local webserver for development is to install XAMPP (Windows), MAMP (Mac OSX), or Apache with PHP5 on through a package manager on Linux.
Laravel is written in the PHP scripting language. Currently, Laravel v3.2.5 requires a minimum of PHP v5.3 to run.
Laravel requires that you have the FileInfo and Mcrypt libraries installed. Conveniently, they are almost always installed by default.
.For our QuickStart application we require a database. Out of the box, Laravel supports MySQL, MSSQL, PostgreSQL, and SQLite.
The easiest way to download Laravel is as a compressed package from http://laravel.com/download.
Alternatively, you can download Laravel by cloning its git
repository from GitHub.com with the following command.
git clone [email protected]:laravel/laravel.git
It would be better that you download the most current stable build.
Extract the contents of the compressed package into the directory that you store your web-applications. Typical locations include /Users/Shawn/Sites
, c:\sites
, and /var/www/vhosts/
depending on your operating system.
We'll assume that your first Laravel installation is in c:\sites\myfirst\
.
Let's go ahead and set up our web server to host our site. We need to choose a host name for our example application. This is our first application and we're working on our local development environment, so let's use http://myfirst.dev?
.
In Linux and OSX, simply add the following line to your /etc/hosts
file:
127.0.0.1 myfirst.dev
Windows users should add that line to their c:\windows\system32\drivers\etc\hosts
file.
Now you should be able to ping myfirst.dev
and see that it resolves to 127.0.0.1
.
Now that we have a host name we need to tell our web server where to find the Laravel installation. Add the following VirtualHost
configuration to your Apache web server configuration and replace DocumentRoot
with the path to your Laravel installation's public directory.
<VirtualHost *:80> ServerName myfirst.dev DocumentRoot c:/sites/myfirst/public </VirtualHost>
It's very important to note that DocumentRoot
points to the Laravel's public directory. There are multiple security reasons for this. A momentary server misconfiguration can expose the secure information, such as your database passwords.
Now that you've installed the Laravel files, added your host declaration, and updated your web-server configuration you're ready to go! Restart your web-server software and go to http://myfirst.dev
in your browser. You should see the Laravel splash page!