Home / Laravel

Laravel

How to install Laravel 5 with Virtual Host configurations

I am sharing steps below with terminal command run screenshots that how to install laravel5 with Virtual Hosts configurations. we need to install composer to download laravel from remote server. for this first command will be for download composer using curl then second one move composer to local user directory for make composer globally use .

# installing composer
curl -sS https://getcomposer.org/installer | php
# move composer globally
sudo mv composer.phar /usr/local/bin/composer
# check composer working
composer

Composer

Now we’ve composer installed successfully!!. and then there are two method to install laravel
1. Via Laravel Installer
2. Via composer

1. Via Laravel Installer :

laravel installer is a new method to install added for laravel 5. it’s much faster method than installing via Composer.

# Download installer

Rasel Khan:~$ composer global require "laravel/installer=~1.1"
Changed current directory to /home/khan/.composer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files

#Setting up path

Rasel Khan:~$ export PATH="~/.composer/vendor/bin:$PATH"

# If you’ve successfully configure then command type ‘laravel’ , you’ll see your laravel installer version 1.2.1

Rasel Khan:~$ laravel
Laravel Installer version 1.2.1

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  help  Displays help for a command
  list  Lists commands
  new   Create a new Laravel application.

#Change dir where to install

Rasel Khan:~$ cd /var/www/project/

# Download and installing

Rasel Khan:~$ laravel new laravel5

# giving permission

Rasel Khan:~$ sudo chmod -R 777 laravel5

2. Via Composer :-

After install composer you can directly install laravel by create-project command and give your destination path where you want to install laravel.

# checking composer is successfully installed

Rasel Khan:~$ composer

# Create a ditectory where to install

Rasel Khan:~$ sudo mkdir /var/www/project/laravel5
[sudo] password for khan: 

# downloading and install via composer

Rasel Khan:~$ sudo composer create-project laravel/laravel /var/www/project/laravel5

# setting up writable permission

Rasel Khan:~$ sudo chmod -R 777 /var/www/project/laravel5

Another way you can do manually download and install

Now, let’s go configure with Virtual Hosts, create a config file into /etc/apache2/sites-available/ directory, i’ve create this file name called laravel5.com.conf, another way you’ll use Vagrant environments

Rasel Khan:~$ sudo mkdir /etc/apache2/sites-available/laravel5.com.conf

# now open laravel5.com.conf file using any editor, I’m using nano editor .

Rasel Khan:~$ sudo nano /etc/apache2/sites-available/laravel5.com.conf

# past below this code into laravel5.com.conf file and save .


<VirtualHost *:80>
    ServerName laravel5.dev
    DocumentRoot "/var/www/project/laravel5/public/"
    DirectoryIndex index.php
    <Directory /var/www/project/laravel5/public/>
        AllowOverride All
    </Directory>
</VirtualHost>

# Enable this file

Rasel Khan:~$ sudo a2ensite laravel5.com.conf

# Reload apache server

Rasel Khan:~$ sudo service apache2 reload

# go to hosts file

Rasel Khan:~$ sudo nano /etc/hosts

# create a new one 127.0.0.1 laravel5.dev

127.0.0.1       localhost
127.0.1.1       raselkhan
127.0.0.1       symfony.dev
127.0.0.1       laravel5.dev

# If you’ve all configuration is ok then need to restart your server

Rasel Khan:~$  sudo service apache2 restart

# now go any browser addressbar url and type

http://laravel5.dev/

you’ll see laravel5 successfully install and configuration with virtual hosts.

laravel5

Enjoy 🙂

Laravel 4 install & configuration

At first need composer setup, open your terminal , I’m using git bash use command below by terminal

curl -sS https://getcomposer.org/installer | php

you can showing downloading running… when download complete then use command

php composer.phar

see below many commands

Rasel Khan:~$ composer
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ / __ `__ / __ / __ / ___/ _ / ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
____/____/_/ /_/ /_/ .___/____/____/___/_/
                    /_/
Composer version 1.0-dev (8e9659bd8317ad3f623c4d17940380443cf8772c) 2015-06-14 09:10:46

Usage:
 command [options] [arguments]

Options:
 --help (-h)           Display this help message
 --quiet (-q)          Do not output any message
 --verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
 --version (-V)        Display this application version
 --ansi                Force ANSI output
 --no-ansi             Disable ANSI output
 --no-interaction (-n) Do not ask any interactive question
 --profile             Display timing and memory usage information
 --working-dir (-d)    If specified, use the given directory as working directory.

Available commands:
 about            Short information about Composer
 archive          Create an archive of this composer package
 browse           Opens the package's repository URL or homepage in your browser.
 clear-cache      Clears composer's internal package cache.
 clearcache       Clears composer's internal package cache.
 config           Set config options
 create-project   Create new project from a package into given directory.
 depends          Shows which packages depend on the given package
 diagnose         Diagnoses the system to identify common errors.
 dump-autoload    Dumps the autoloader
 dumpautoload     Dumps the autoloader
 global           Allows running commands in the global composer dir ($COMPOSER_HOME).
 help             Displays help for a command
 home             Opens the package's repository URL or homepage in your browser.
 info             Show information about packages
 init             Creates a basic composer.json file in current directory.
 install          Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json.
 licenses         Show information about licenses of dependencies
 list             Lists commands
 remove           Removes a package from the require or require-dev
 require          Adds required packages to your composer.json and installs them
 run-script       Run the scripts defined in composer.json.
 search           Search for packages
 self-update      Updates composer.phar to the latest version.
 selfupdate       Updates composer.phar to the latest version.
 show             Show information about packages
 status           Show a list of locally modified packages
 update           Updates your dependencies to the latest version according to composer.json, and updates the composer.lock file.
 validate         Validates a composer.json

If you want globally install it then use command mv composer.phar /usr/bin/composer Now, you have composer install globally !!

At this time needs laravel install & downloading, change your directory where you want install it, My directory changes for Desktop ! type command

Rasel Khan:~: cd ~/Desktop 

and with create a new directory called (laravel_lesson) mkdir laravel_lessson then change this directory user command

Rasel Khan:~$ cd laravel_lesson 

Now install laravel by composer use command

composer create-project laravel/laravel your-project-directtory-name 

This (your-project-directtory-name) means laravel_lesson directory, Because before I create directory Desktoplaravel_lesson, So finally command use

composer create-project laravel/laravel laravel_lesson

You can show all laravel files downloading running…. When download complete then you need third party dependency
Now, use command

composer update 

You have all files downloaded into laravel_lesson directory

Now you need server running use command

Rasel Khan:~$ php artisan serve
Laravel development server started on http://localhost:8000/

Finally you showing by browser complete install laravel 4 !!