Skip to content

Instantly share code, notes, and snippets.

@pbteja1998
Last active June 15, 2017 11:14
Show Gist options
  • Save pbteja1998/a735fad5d843a952c937f7b3ba8f058e to your computer and use it in GitHub Desktop.
Save pbteja1998/a735fad5d843a952c937f7b3ba8f058e to your computer and use it in GitHub Desktop.

Installation

Prerequisites

  • You are using any Debian based Linux distribution

Step 1 - Update the package manager cache by running:

$ sudo apt-get update

Step 2 - Install Zip and Git

$ sudo apt -y install zip git

Step 3 - Install apache2

$ sudo apt-get install libapache2-mod-php7.0

Step 4 - Install PHP and necessary mods

$ sudo apt install -y curl php
$ sudo apt install -y php-mysql php-fpm php-curl php-gd php7.0-mcrypt php-mbstring php-gettext php-token-stream php-zip

Step 5 - Enable mods for Laravel

$ sudo phpenmod mcrypt mbstring curl gettext

Step 6 - Install mysql

$ sudo apt -y install mysql-server

Step 7 - Disable CGI scripting for security reasons

$ sudo -- sh -c "echo 'cgi.fix_pathinfo=0' >> /etc/php/7.0/fpm/php.ini"

Step 8 - Restart to apply changes

$ sudo systemctl restart php7.0-fpm

Step 9 - Restart apache

$ sudo service apache2 restart

Step 10 - Restart to apply changes

$ sudo systemctl restart php7.0-fpm

Step 11 - Install Redis

$ sudo apt install -y redis-server

Step 12 - Install Composer which is a package manager for Laravel

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

To test your installation, run:

$ composer

And you should get output similar to this:

Output   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 1.0-dev (9859859f1082d94e546aa75746867df127aa0d9e) 2015-08-17 14:57:00

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.

. . .

This means Composer was succesfully installed on your system.

Step 13 - Install Laravel Installer

$ composer global require laravel/installer
$ echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bashrc
$ source ~/.bashrc

To test your installation, run

$ laravel

And you should get output similar to this

Laravel Installer 1.3.5

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.

Once Laravel Installer is installed, the laravel new command will create a fresh Laravel installation in the directory you specify. For instance, laravel new blog will create a directory named blog containing a fresh Laravel installation with all of Laravel's dependencies already installed:

$ laravel new blog
$ cd blog

Local Development Server

If you have PHP installed locally and you would like to use PHP's built-in development server to serve your application, you may use the serve Artisan command. This command will start a development server at http://localhost:8000:

$ php artisan serve

Directory Permissions

After installing Laravel, you may need to configure some permissions. Directories within the storage and the bootstrap/cache directories should be writable by your web server or Laravel will not run. If you are using the Homestead virtual machine, these permissions should already be set.

Application Key

The next thing you should do after installing Laravel is set your application key to a random string. If you installed Laravel via Composer or the Laravel installer, this key has already been set for you by the command

$ php artisan key:generate command.

Typically, this string should be 32 characters long. The key can be set in the .env environment file. If you have not renamed the .env.example file to .env, you should do that now. If the application key is not set, your user sessions and other encrypted data will not be secure!

Additional Configuration

Laravel needs almost no other configuration out of the box. You are free to get started developing! However, you may wish to review the config/app.php file and its documentation. It contains several options such as timezone and locale that you may wish to change according to your application.

PHP Storm Installation (optional but highly recommended)

Download PHP Storm

Then run the following command

$ tar xvzf <downloaded_file>

Replace <downloaded_file> with the name of the .tar.gz file that is downloaded

Then run

$ cd <extracted_directory>/bin
$ bash phpstorm.sh

Then follow the instructions that will be provided to install it.

Laravel IDE Helper

If you are planning to use PHP Storm as your editor, then install Laravel IDE Helper

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