Deploy Laravel Web App to Windows Server 2012

Some software is required as follows:

Install Laravel application as follows:

  • Git clone Laravel project by using the command
    git clone https://link_to_project mywebapp 
    
  • Jump into a project folder and install Laravel by using composer
cd mywebapp 
composer install
  • Copy .env.example file to .env file and change the database connection to PostgreSQL database
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=mywebappdb
DB_USERNAME=username
DB_PASSWORD=password
  • Generate an application key
php artisan key:generate
  • Change php.ini to enable pdo driver for Postgres
## find and uncomment those lines
extension=pdo_pgsql
extension=pgsql

Increase memory for php

memory_limit= 1028MB
  • Migrate database and insert some default data
php artisan migrate
php artisan db:seed
  • Run composer to autoload file
composer dump-autoload
  • Link public folder to apache httpdocs (run on command prompt)
mklink /d C:\xampp\htdocs\mywebapp C:\Project\mywebapp\public
  • Change host file in “C:\Windows\System32\drivers\etc\hosts”
## add more under 127.0.0.1 localhost
127.0.0.1 mywebapp.localhost.com
  • Add VirtualHost in “C:\xampp\apache\conf\extra\httpd-vhosts.conf”
    NameVirtualHost 127.0.0.1:80
    <VirtualHost *:80>
    <Directory "C:/xampp/htdocs/mywebapp">
        Options FollowSymLinks Indexes
        AllowOverride All
        Order deny,allow
        allow from All
    </Directory>
    ServerName bids.localhost.com
    ServerAlias www.bids.localhost.com
    DocumentRoot "C:/xampp/htdocs/bids" 
    </VirtualHost>
    
  • Test it on the browser with “mywebapp.localhost.com”

Leave a comment