How install PHP 5.6, Composer and Laravel 5.2 on Ubuntu 16.04

1 -Add PPA of PHP 5.6

sudo add-apt-repository ppa:ondrej/php

2 - Update repositories

sudo apt-get update

2.x - If you got error updating:

W: GPG error: artful InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY XXXXXXXXXYYYYYYYY

Run this command, where YYYYYYYY is the last 8 digits on error above

sudo apt-key adv --keyserver --recv-keys YYYYYYYY

3 - Install PHP 5.6 and dependencies for laravel

sudo apt-get install -y php5.6
sudo apt-get install php5.6-xml
sudo apt-get install php5.6-mbstring
sudo apt-get install -y zip unzip php5.6-zip

4 - Create a SWAP file if you is under less than 1GB RAM VPS

sudo fallocate -l 1G /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

5 - Download and Install composer

cd ~
curl -sS | php

6 - Rename composer to access just typing composer

sudo mv composer.phar /usr/local/bin/composer

7 - Install git, composer will need to download laravel packages

sudo apt-get install git

8 - Install Laravel 5.2 by creating a project

sudo composer create-project laravel/laravel /var/www/project_name 5.2

9 - If you already have a Laravel project, just clone from repository and make composer install inside this root folder

composer install

10 - Set folder permissions for the new project or already existent

sudo chown -R :www-data /var/www/project_name
sudo chmod -R 775 /var/www/project_name/app/storage


sudo apt-get purge dpkg -l | grep php| awk '{print $2}' |tr "\n" " " Add the PPA

sudo add-apt-repository ppa:ondrej/php If you get add-apt-repository: command not found run the following command first :

sudo apt-get install software-properties-common Install your PHP Version

sudo apt-get update sudo apt-get install php5.6 You can install php5.6 modules too for example

sudo apt-get install php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml Verify your version

If you have installed php5.6-cli

sudo php -v If you don't have php5.6-cli, put this on a .php file

<?php //outputs php configuration info phpinfo(); ?>

Por Marcos Mendes @marcoshmendes