How to Install Laravel on Windows

Most tutorials on the Internet are using Linux/Ubuntu. However, in this post I will show you how to install the latest Laravel  on Windows. I will be using Microsoft Windows 8.1 and WAMP. I’m using Laravel 4.2 for this tutorial. But you don’t have to worry as long as it’s version 4 and above, you can use this tutorial.

Let’s begin.

1. Install WAMP first.

There are several things that you need to make sure in order to run Laravel successfuly.

– You have to make sure it’s PHP 5.3.7 or higher

To make sure of this, use the latest version available at WAMP Server website.

– mCrypt module enabled

mCrypt module comes enabled at default so you don’t have to worry about this.

2. Enable OpenSSL in PHP.ini

Update for Laravel 5.4.

Laravel version 5.4 require these:

PHP >= 5.6.4
OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension
XML PHP Extension

After you installed WAMP, you need to do this. This is how you make sure OpenSSL is enabled:

On your right hand side of your taskbar, click WAMP and then choose PHP.ini.

And then find php_openssl, and then remove the semicolon in front of php_openssl.

And then, save. Close that file and now go to wamp manager again, and now enable OpenSSL there just to be safe.

After you do that, restart Wamp.

3. Install Composer

Go to https://getcomposer.org/ and download Windows installer.

The setup will ask for your PHP. if you install your WAMP in default setting, it will usually end up in C:\wamp\bin\php\php5.4.12.

If your installation is successful, by running composer on command prompt, you will see all kinds of info just by running that command.

If you can see it, that means your Composer installation is complete. Let’s move to the next one.

4. Make sure that your htppd.conf includes httpd-vhosts.conf

Now let’s make sure that your htppd.conf also includes httpd-vhosts.conf. This is beneficial if you want to make a pretty URL just like this one:

Instead of writing up localhost/mylaravel, it would be “nicer” to have that pretty URL, right?

Anyway, let’s go on.

Go to C:\wamp\bin\apache\Apache2.4.4\conf and then open up httpd.conf.

After that, search for httpd-vhosts.conf and make sure that there is no ‘#’ (pound sign) in front of it. Save. After that restart Wamp just to be safe.

Now let’s begin the fun part: installing Laravel.

5. Install Laravel in specified folder

You usually want to install your Laravel in your www folder. (Obviously!)

So open up your command prompt, and then change directory to your WWW folder inside your wamp. For me it will be: C:\wamp\www

To change directory, just type cd c:\wamp\www

Basically you are changing folder to your www folder.

And then, you can install Laravel. Just use this in your command prompt:

composer create-project laravel/laravel your-project-name –prefer-dist

And then hit enter.

Just wait a while until it is finished downloading and installing.

 

Wait until… everything finished.

6. Create Virtual Host

Now let’s create your pretty URL. You have to go to C:\wamp\bin\apache\Apache2.4.4\conf\extra and then open up httpd-vhosts.conf.

After that, you just need to paste the following and change your laravel folder to appropriate ones.

<VirtualHost *:80>
DocumentRoot “c:/wamp/www/mylaravel/public”
ServerName laravel.dev
</VirtualHost>

In my case, I used mylaravel for my laravel installation. You have to change it to something else. For server name, you can change it to whatever you want. In my case, I am using laravel.dev. (You don’t want to use google.com because if you do, you won’t be able to open up Google).

Obviously, you have to save and then restart your WAMP again.

7. Update Windows Hosts file

After you have changed your virtual host, you need to change your host file.

Go to C:\Windows\System32\drivers\etc and copy hosts and paste it on your Desktop. And click on the host file you have pasted on your Desktop. Open that up using Notepad.

Put this in that host file:

127.0.0.1 laravel.dev

Change laravel.dev into what you already decided in your virtual host file. For me, mine will be laravel.dev.

Copy the one that you modified just now and put it back into your C:\Windows\System32\drivers\etc folder.

You’re done!

That’s it! That’s the way you can install Laravel and have a pretty sexy URL together. If you have any questions, please send your questions in the comment form below and I will try as best to answer your question.

 

4 Replies to “How to Install Laravel on Windows”

  1. I can access the home page, but when I access http: //laravel.dev/find not find the path, Which Can be the problem?

Leave a Reply