Laravel Installation/Setup in Linux

In this article i a going to explain how to do Laravel Installation/Setup in Linux environment. Laravel is a very popular framework, used for developing Web applications and it’s the current trend.
So, Let’s start with some basic installations. Before, Installing/Set upping Laravel, we need a working/development php environment. If you are not set upped it yet, go through the basic installations.

Basic Installations

Apcahe Installation

sudo apt-get update
sudo apt-get install apache2

For more detailed installation procedure and troubleshoot use the link : Install Apache MySQL PHP and PHPmyadmin
Mysql Installation

sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

You can find detailed installation procedure in this link : Install Apache MySQL PHP and PHPmyadmin
PHP Installation

sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

Other useful tools/Not necessary for Laravel setup

Git Installation

sudo apt-get install git

Curl Installation

sudo apt-get install curl

Vim Installation

sudo apt-get install vim

Laravel Installation

OK.Now we have done all the basic/necessary installations.
Let’s start with Laravel Installation

Composer Installation

Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.
To install Composer, open a terminal and type (curl should be installed,if you are not installed curl, i have explained it above)

curl -sS | sudo php -- --filename=composer --install-dir=/usr/local/bin

Laravel project can be created in two ways via Laravel Installer and Via Composer

To install Via Laravel Installer use this

sudo apt-get install php5-mcrypt
composer global require "laravel/installer=~1.1"

Now, setup the project and give permissions

laravel new homestead
cd homestead
chmod 777 -R app/storage

To install Via Composer Create-Project use this :

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

Also, you can give the folder name as this

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

Now, give permissions to the storage folder

laravel new homestead
cd homestead
chmod 777 -R app/storage

Note:If you don’t give permissions, you can’t see the default Laravel home page,Also, do this always when you checkout a project from Git/anywhere.

To Setup Virtual host to your Laravel project

Create a Apache configuration file and edit it with the Virtual host configurations

sudo touch /etc/apache2/sites-available/homestead.conf
sudo gedit /etc/apache2/sites-available/homestead.conf

Add the Lines to configuration file, with appropriate changes

< VirtualHost *:80 >
DocumentRoot /home/User/Development/homestead/public

Require all granted
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All

< / VirtualHost >

Now, edit he host file and add the new local domain

sudo gedit /etc/hosts

Add the Lines to configuration file, with appropriate changes 

Now, enable the configuration and restart apache web server.

sudo a2ensite homestead.conf
sudo service apache2 restart

Now, type the in your web browser to see the default Lavarel home page.