Friday, August 18, 2017

Install Laravel Framework on Ubuntu

Step 1 – Install LAMP

You will need to make sure your LAMP meets the following requirements:
  • PHP >= 5.6.4
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Mbstring PHP Extension
  • Tokenizer PHP Extension
  • XML PHP Extension
$ sudo apt-get install python-software-properties
$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt-get update
$ sudo apt-get install -y php5.6 php5.6-mcrypt php5.6-gd
$ sudo apt-get install apache2 libapache2-mod-php5
$ sudo apt-get install mysql-server php5.6-mysql

Step 2 – Install Composer

Install Composer which is a tool for dependency management in PHP.

$ curl -sS | php
$ sudo mv composer.phar /usr/local/bin/composer
$ sudo chmod +x /usr/local/bin/composer

Step 3 – Install Laravel

Now create a directory where Laravel will be downloaded.
$ mkdir /var/www/html/your_website

Now enter the newly created directory and download the latest Laravel version.
$ cd /var/www/html/your_website
$ git clone

Start the Laravel installation using Composer:
$ composer install

Dependencies installation will take some time. After than set proper permissions on files.
$ chown -R www-data.www-data /var/www/laravel
$ chmod -R 777 /var/www/laravel/storage

Step 4 – Set Encryption Key

# php artisan key:generate
You will notice the below error when running the command.

  file_get_contents(/var/www/html/your_website/.env): failed to open stream: No such file or directory

To solve this you should rename the .env.example file into .env:
$ mv .env.example  .env

Generate the encryption key again:
# php artisan key:generate

You should get the following output:
Application key [base64:ULQsledeS17HxCAsssA/06qN+aQGbXBPPpXVeZvdRWE=] set successfully.

Now edit the app.php file and configure the encryption key. Open the file with your favorite text editor. 

# vim config/app.php

Locate the ‘key’ => env(‘APP_KEY’ line and add the key next to it. After you are done the directive should look like this:

'key' => env('APP_KEY', 'base64:7fGASOGOSASA%^AYUFSA9TxZu8M2NwBWVEQsjPGRiasbdasYITIUG$%^$CSSA='),

    'cipher' => 'AES-256-CBC',

Save and close the file.

Now open your favorite web browser and navigate to  http://localhost/your_website  where you will be welcomed by a page as shown in the image below:
Laravel First Page

1 comment: