Installing Laravel 4 on WAMP

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.

Enable OpenSSL

OpenSSL must be enabled in the PHP configuration.

  1. Edit php.ini in your WAMP’s PHP folder, e.g.:

    C:\wamp\bin\php\php5.4.12\
    

    Note: This is not the php.ini in C:\wamp\bin\apache\Apache2.4.4\bin.

  2. Find the following line:

    ;extension=php_openssl.dll
    
  3. Remove the leading semi-colon:

    extension=php_openssl.dll
    
  4. Save php.ini.

Install Composer

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.

  1. Download the Composer Windows installer from getcomposer.org.

  2. Run the installer.

  3. When it asks for the location of php.exe, point it to the executable in your WAMP’s PHP folder, e.g.:

    C:\wamp\bin\php\php5.4.12\
    
  4. Finish the installation.

  5. Open a command-line interface (cmd) and type:

    composer
    

    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.

Install Laravel

Now that Composer has been installed, Composer can download and install Laravel onto your system.

  1. Open a command-line interface (cmd).
  2. Go to the directory in which you want to install Laravel. This is usually your development directory. In this tutorial, we’ll use C:\Users\Me\Documents.

    cd C:\Users\Me\Documents
    
  3. Instruct Composer to install Laravel into a project directory. In this tutorial we use the project name myproject.

    composer create-project laravel/laravel myproject --prefer-dist
    

    Note: This will install Laravel in a subdirectory myproject of the current working directory.

Add a virtual host

Finally, we need to create a virtual host to point Apache to our new Laravel installation.

  1. Go to the directory of your hosts file:

    C:\Windows\System32\drivers\etc
    
  2. In this tutorial we’ll bind the website to http://myproject.dev/. Edit the hosts file to add the following line:

    127.0.0.1 myproject.dev
    

    Note: Try running Notepad as Administrator to edit the hosts file; or copy it somewhere else, edit it, and copy it back.

  3. Edit httpd.conf from this directory:

    C:\wamp\bin\apache\Apache2.4.4\conf
    
  4. Find these lines:

    # Virtual hosts
    #Include conf/extra/httpd-vhosts.conf
    
  5. Remove the leading hash sign from the Include line, and save the file:

    # Virtual hosts
    Include conf/extra/httpd-vhosts.conf
    
  6. Edit httpd-vhosts.conf from this subdirectory:

    C:\wamp\bin\apache\Apache2.4.4\conf\extra
    
  7. 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.

  8. 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.conf file. You can safely remove them.

    Note: The document root is the website’s public directory.

  9. Click the WAMP tray icon to open its menu.

  10. Click Restart all services.

  11. Go to your local site in your browser, e.g.:

    http://myproject.dev/
    

    You should see the Laravel 4 welcome page: You have arrived.

3 thoughts on “Installing Laravel 4 on WAMP

  1. having a problem, installed everything and followed the instructions to a tee. when going to http://myproject.dev/ it says “The server at myproject.dev can’t be found, because the DNS lookup failed”. any help would be appreciated.

    if it helps. I am on win 7 ultimate 32bit

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>