Skip to main content

How to install Laravel on Ubuntu

To install Laravel you must have install LAMP stack (Linux, Apache2, MySql, and PHP) on your Ubuntu system

Install LAMP: If not installed LAMP

sudo apt-get install apache2

sudo apt-get install php5

sudo apt-get install mysql-server

sudo apt-get install php5-mysql


Install PHP extensions
Some PHP extensions are necessary to install before installing Laravel

1. unzip used for the unzip laravel
sudo apt-get install unzip

2. Use Composer (which needs CURL)
sudo apt-get install curl

3. Use Composer (which downloads via HTTPS, usable only with install Openssl)
sudo apt-get install openssl

4. Use Laravel 4 (which needs mcrypt)
sudo apt-get install php5-mcrypt


Install Composer

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

Activate mod_rewrite

sudo a2enmod rewrite

sudo service apache2 restart

Open the default vhost config file:

sudo nano /etc/apache2/sites-available/default

Now search for "AllowOverride None" then change to "AllowOverride All"


System Requirement for Laravel
  • PHP >=5.4 for Laravel 5 and PHP >=5.3 for Laravel 4
  • mcrypt PHP extension

Install Laravel

Goto your web root directory
cd /var/www

Method 1: Install via laravel installer
composer global require "laravel/installer=~1.1"

Note: Make sure to place the ~/.composer/vendor/bin directory in your PATH so the laravel executable is found when you run the laravel command in your terminal.

To set PATH use following command
export PATH="~/.composer/vendor/bin:$PATH"

Then create new laravel project using laravel new {project-name} command
for example: laravel new blog. It will create a new laravel project directory in your web root directory.

Method 2: Install laravel using composer create-project command in your terminal
composer create-project laravel/laravel {directory} {laravel version} --prefer-dist

for example: composer create-project laravel/laravel blog 4.2 --prefer-dist
Note: Mention version number to install specific Laravel version. If you don't mention it then it will automatically install the latest version. The latest version of laravel is 5.
If you don't mention dirctory then it will install in "laravel" by default.

Method 3: Install via download
Download the Laravel framework and extract the content into your web root directory.
Next, in the root of your Laravel application, run the php composer.phar install (or composer install ) command to install all of the framework's dependencies. This process requires Git to be installed on the server to successfully complete the installation.

Final Step : If you are using LAMP or MAMP, you need to give permission to storage folder (i.e. for Laravel v5.x, folder path is /storage, permission command is $sudo chmod -R 777 storage)

After setting permission run project either use laravel CLI tool (Artisan) or set virtual host.
1. By CLI tool type in console $php artisan serve
2. For setting virtual host refer this link http://tecadmin.net/install-laravel-framework-on-ubuntu/






Comments

Popular posts from this blog

Use Case Diagram for Online Book Store

Linear search & Binary search using Template

Write a program to search an element from a list. Give user the option to perform Linear or Binary search. Use Template functions. #include<iostream> using namespace std; template <class T> void Lsearch(T *a, T item, int n) { int z=0; for(int i=0;i<n;i++) { if(a[i]== item) { z=1; cout<<"\n Item found at position = "<<i+1<<"\n\n"; } else if(z!=1) { z=0; } } if(z==0) cout<<"\n Item not found in the list\n\n"; } template <class T> void Bsearch(T *a, T item, int n) { int beg=0,end=n-1; int mid=beg+end/2; while((a[mid]!=item) && (n>0)) { if(item>a[mid]) beg=mid; else end=mid; mid=(beg+end)/2; n--; } if(a[mid]==item) cout<<"\n Item found at position = "<<mid+1<<"\n\n"; else cout<<"\n Item not found in the list\n\n"; } void main() { int iarr[10] = {2,42,56,86,87,99,323,546,767,886};...

Occurrences of each letter of alphabet in the text

Program to print a table indicating the no. of occurrences of each letter of alphabet in the text entered as command line arguments. #include<iostream> #include<string> using namespace std; int main(int argc, char *argv[]) { string str=""; static int alphabet[26]; int x; cout<<"\n\n Command-Line Argument\n"; for(int i=0;i<argc;i++) { cout<<"\n "<<argv[i]; str+=argv[i]; } for(int i=0;i<str.length();i++) { if(str[i]>='A' && str[i]<='Z') { x=((int)str[i])-65; alphabet[x]++; } else if(str[i]>='a' && str[i]<='z') { x=((int)str[i])-97; alphabet[x]++; } } //Displaying No. of occurrences of each alphabets in the command line argument cout<<"\n\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n Alphabet No. of Occurrences\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"; for(int i=0;i<26;i++)...