How To Install Laravel in Ubuntu 16.04

1. Open Terminal and Install PHP

Validate if php is currently installed in your system:

$ php -v

Otherwise, run the following command as root to install it:

$ sudo apt-get install php7.0-cli

$ sudo apt-get install php7.0

It will ask you if you want to install its dependencies:

$ y

After it is done installing you should be able to type:

$ php -v

And you should see the following message:

Screenshot from 2016-08-28 13-20-21

2. Install Composer

Type the following commands in terminal, one at a time:

$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

$ php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

$ php composer-setup.php

$ php -r "unlink('composer-setup.php');"

Validate composer was installed correctly:

$ composer --version

And you should see the following message:

Screenshot from 2016-08-28 13-20-39

3. Install Laravel

Download the Laravel installer using Composer:

$ composer global require "laravel/installer"

Add laravel to your $PATH:

$ echo 'export PATH="~/.config/composer/vendor/bin:$PATH"' >> ~/.bashrc

Big thanks to Stack Overflow user: iUseMagnetoNow for clarifying that in Ubuntu 16.04
the path is under the ~/.config directory as shown above.

Validate laravel was installed:

$ laravel -v

And you should see the following message:

Screenshot from 2016-08-28 13-21-00

4. Test the newly installed Laravel

Switch to your home directory:

$ cd ~

Make a new directory to store your websites and switch into it:

$ mkdir Sites

$ cd Sites

Create a new lavarel project:

$ laravel new [project-name]

Screenshot from 2016-08-28 14-07-26

5. Install Missing Dependencies:

6. Properly Craft Your App

Run the create statement once again to craft your new app:

$ laravel new [project-name]

Screenshot from 2016-08-28 15-17-46

Once the installation completes, switch into the project directory and begin to write some code:

Screenshot from 2016-08-28 15-28-26

Generate the autoload files by running:

$ composer update

Then, you can test your app using the built-in artisan web server:

$ php artisan serve

Screenshot from 2016-08-28 16-03-05

Copyright: Giovanni Orlando Rivera

Twitter: @Giovanni0918

Website: http://giovanni-orlando.com

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s