I like developing my websites locally before I put them live. Since I’m on a Windows machine, I use WAMP (Windows Apache MySQL PHP). To install the Laravel 4 framework on WAMP, I took the steps outlined below. Ajust the values and version numbers to match your particular situation.
This was tested with WampServer 2.4.
OpenSSL must be enabled in the PHP configuration.
php.iniin your WAMP’s PHP folder, e.g.:
Note: This is not the
Find the following line:
Remove the leading semi-colon:
Now we need to install Composer. This is a dependency manager that will download the latest release of Laravel and specific versions of Laravel’s dependencies, such as Doctrine and Symfony.
Download the Composer Windows installer from getcomposer.org.
Run the installer.
When it asks for the location of
php.exe, point it to the executable in your WAMP’s PHP folder, e.g.:
Finish the installation.
Open a command-line interface (
cmd) and type:
It should return a list of options. If you get an error, restart your computer and try again.
Composer has now been installed and added to your
PATH environment variable. This means you can run it from any directory using the command-line interface.
Now that Composer has been installed, Composer can download and install Laravel onto your system.
- Open a command-line interface (
Go to the directory in which you want to install Laravel. This is usually your development directory. In this tutorial, we’ll use
Instruct Composer to install Laravel into a project directory. In this tutorial we use the project name
composer create-project laravel/laravel myproject --prefer-dist
Note: This will install Laravel in a subdirectory
myprojectof the current working directory.
Add a virtual host
Finally, we need to create a virtual host to point Apache to our new Laravel installation.
Go to the directory of your
In this tutorial we’ll bind the website to
http://myproject.dev/. Edit the
hostsfile to add the following line:
Note: Try running Notepad as Administrator to edit the
hostsfile; or copy it somewhere else, edit it, and copy it back.
httpd.conffrom this directory:
Find these lines:
# Virtual hosts #Include conf/extra/httpd-vhosts.conf
Remove the leading hash sign from the
Includeline, and save the file:
# Virtual hosts Include conf/extra/httpd-vhosts.conf
httpd-vhosts.conffrom this subdirectory:
Add the following just after the big block of comments in the file:
<Directory "C:/Users/Me/Documents/"> AllowOverride All Order Deny,Allow Allow from all </Directory>
Note: The slashes in the path are forward slashes.
Note: The path is a parent directory of your website.
Add the following to the end of the file, and save it:
<VirtualHost *:80> DocumentRoot "C:\Users\Me\Documents\myproject\public" ServerName myproject.dev </VirtualHost>
Note: There might be dummy entries in the
httpd-vhosts.conffile. You can safely remove them.
Note: The document root is the website’s
Click the WAMP tray icon to open its menu.
Click Restart all services.
Go to your local site in your browser, e.g.:
You should see the Laravel 4 welcome page: You have arrived.