Laravel, Ubuntu and PHP 7.2

Sometimes this task seems daunting; you have Ubuntu 16 as your default OS and each time while installing Laravel 5.*.*, you are left with error messages reminding you that you don’t have many PHP extensions in your system; PHP extensions that support Laravel.
What you can do?
It’s a problem and must have a solution.
Here is the solution.
You need to make your system Laravel friendly. That is the first step when you have to purge old PHP from your system and install the latest ones.

Run this commands one after another:

$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt-get update

$ sudo apt-get purge php7.0 php7.0-common

$ sudo apt-get install php7.2-curl php7.2-xml php7.2-zip php7.2-gd php7.2-mysql php7.2-mbstring

$ sudo shutdown -r now

It will take some time, depending on your Internet speed.

Then install Laravel and remember, you can prefer the Laravel distribution.

ss@ss-H81M-S1:~$ cd /var/www/html/
ss@ss-H81M-S1:/var/www/html$ ls
index.html index.php info.php mvc myframework mymvc pdo test
ss@ss-H81M-S1:/var/www/html$ mkdir blog
ss@ss-H81M-S1:/var/www/html$ cd blog/
ss@ss-H81M-S1:/var/www/html/blog$ composer create-project --prefer-dist laravel/laravel blog "5.5.*"
Cannot create cache directory /home/ss/.composer/cache/repo/https---packagist.org/, or directory is not writable. Proceeding without cache
Installing laravel/laravel (v5.5.28)
Cannot create cache directory /home/ss/.composer/cache/files/, or directory is not writable. Proceeding without cache
- Installing laravel/laravel (v5.5.28): Downloading (100%)
Created project in blog
Cannot create cache directory /home/ss/.composer/cache/repo/https---packagist.org/, or directory is not writable. Proceeding without cache
Cannot create cache directory /home/ss/.composer/cache/files/, or directory is not writable. Proceeding without cache
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 71 installs, 0 updates, 0 removals
- Installing symfony/thanks (v1.1.0): Downloading (100%)
- Installing vlucas/phpdotenv (v2.5.1): Downloading (100%)
- Installing symfony/css-selector (v4.1.4): Downloading (100%)
- Installing tijsverkoyen/css-to-inline-styles (2.2.1): Downloading (100%)
- Installing symfony/polyfill-mbstring (v1.9.0): Downloading (100%)
- Installing symfony/var-dumper (v3.4.15): Downloading (100%)
- Installing symfony/routing (v3.4.15): Downloading (100%)

........

Published by

Sanjib Sinha

Written six books for Apress; also publish at Leanpub and Amazon to share learning-experience.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.