Skip to content

Instantly share code, notes, and snippets.

@abhi9bakshi
Last active October 7, 2018 12:06
Show Gist options
  • Save abhi9bakshi/ef5bf8105f3d62731e0148658f97e94d to your computer and use it in GitHub Desktop.
Save abhi9bakshi/ef5bf8105f3d62731e0148658f97e94d to your computer and use it in GitHub Desktop.
How to install Laravel in Ubuntu 16.10

How to install Laravel in Ubuntu 16.10

===================================

Open your terminal using Ctrl+Alt+T and type the following commands

##Step 1: Update & Upgrade

sudo apt-get update
sudo apt-get upgrade

##Step 2: Install PHP

sudo apt-get install php7.0-cli php7.0-zip  php-mbstring php7.0-mbstring php-gettext libapache2-mod-php7.0 php7.0-mysql

##Step 3: Install Composer

sudo apt-get install composer

##Step 4: Install Laravel

composer global require "laravel/installer=~1.1"

##Step 5: Add composer to path to access laravel globally

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

##Step 6: Create a new Laravel application

laravel new testapp

##Step 7: Install missing packages and their dependencies

cd testapp
composer install

##Step 8: Generate APP_KEY for testapp

php artisan key:generate

##Step 9: Test the application

php -S localhost:8888 -t public

Open a web browser and visit localhost:8888 to see the laravel welcome page

##Step 10: Configuring Database Terminate php server in terminal by pressing Ctrl+C

Download mysql-server by typing the following command in the terminal

sudo apt-get install mysql-server

Once done, login to mysql shell

mysql -u root -p

Enter your root password

Create a new user

CREATE USER 'laravel'@'localhost' IDENTIFIED BY 'laravel';
GRANT ALL PRIVILEGES ON * . * TO 'laravel'@'localhost';

Thus you have successfully create a new user 'laravel' with the password 'laravel' and full privileges.

Now, logout from mysql shell by typing \q and login again from laravel user

mysql -u laravel -p

Enter password as laravel

Create a new database 'testapp'

create database testapp;

Logout from mysql shell by typing \q

##Step 11: Connect 'testapp' to 'mysql' database Open your .env file in 'testapp' directory

nano .env

Inside .env file, set

DB_DATABASE=testapp
DB_USERNAME=laravel
DB_PASSWORD=laravel

Save the file by pressing Ctrl+O followed by Enter. Exit nano editor by pressing `Ctrl+X'

Run migrations to create tables in mysql database

php artisan migrate

Thus you have successfully installed laravel and configured it to use mysql.

@r-brown
Copy link

r-brown commented Jul 1, 2017

Nice tutorial, thank you!
An easy way to try out Laravel in action is to use Laravel 5 Boilerplate / Starter Kit - https://github.com/Labs64/laravel-boilerplate
This is also offering Docker container, with this you don’t need a local PHP (composer, node.js, etc.) environment and can start to evaluate Laravel right away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment