Install Laravel on Windows (WAMP) Server

Here is how to install Laravel, one of the most popular PHP framework on a Windows server running Apache, MySQL and PHP (also called WAMP Server) in five easy steps.

Step 1. Install Composer

Composer is a tool for managing dependencies in PHP. It can find and install the right versions of libraries that are required for your PHP project. You can download and install Composer from the link here.

Step 2. Enable PHP extensions

Laravel requires following PHP extensions to be enabled in PHP:

  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Mbstring PHP Extension

You can enable them in the PHP initialization file, php.ini located on the PHP installation folder. Open this file in any text editor and search for each of the following lines.

extension=php_openssl.dll
extension=php_pdo_mysql.dll
extension=php_mbstring.dll

To enable the extension you only have to remove the semicolon (;) from the beginning of the line and Save the file.

Step 3. Download Laravel

Open Windows Command Prompt and run the command:

composer global require "laravel/installer"

Step 4. Install Laravel

Open command prompt and navigate to a location where you want to create your project. Run the command Laravel new which will create a new Laravel installation in the directory that you specify.

laravel new forum

The above command will create a folder named forum containing the following directories and file.

forum
 |-- app 	<DIR> 
 |-- bootstrap
 |-- config 	<DIR>   
 |-- database 	<DIR>          
 |-- public 	<DIR>          
 |-- resources 	<DIR>          
 |-- routes 	<DIR>          
 |-- storage 	<DIR>           
 |-- tests 	<DIR>          
 |-- vendor 	<DIR>          
 |-- .env
 |-- .env.example
 |-- .gitattributes
 |-- .gitignore
 |-- artisan
 |-- composer.json
 |-- composer.lock
 |-- gulpfile.js
 |-- package.json
 |-- phpunit.xml
 |-- readme.md
 |-- server.php

Note: If you get the error

'laravel' is not recognized as an internal or external command, operable program or batch file.

it means you need to add composer bin directory %UserProfile%\AppData\Roaming\Composer\vendor\bin to the PATH environment variable.
See instructions here to set PATH variable in Windows

Step 5. Configure Apache

Open Apache config file httpd.conf located in conf directory of Apache Installation folder. Change the directives DocumentRoot and Directory to point to the public folder inside your Laravel project. See example below:

DocumentRoot "${SRVROOT}/htdocs/forum/public"
<Directory "${SRVROOT}/htdocs/forum/public">

Also make sure the DirectoryIndex is set as below>


 DirectoryIndex index.php index.html

Save the file and restart Apache after making the changes.

Now open a web browser and point to your domain root, for example http://www.domain.com or http://localhost/
If the installation is successful you should see the Laravel welcome page here.


Post a comment

Name

Your Comment

Email (We dont publish it)

Comments

Nothing yet..be the first to share wisdom.