HOW TO INSTALL LARAVEL

These are the commands I used to install laravel on my linux ubuntu using virtualbox from a windows PC. What I did I installed a fresh ubuntu 18.04 version with minimal installation. if you did not installed a minimal installation, some of the required dependencies may already be in your system and you might get a message telling you that you already have the latest version. so lets try it.

1. UPDATE:
sudo apt-get update

2. install php
sudo apt install php
CONFIRM: php -v

OUTPUT:

PHP 7.2.19-0ubuntu0.18.04.1 (cli) (built: Jun 4 2019 14:48:12) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.19-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies


3. install curl
sudo apt install curl

4. install GIT
sudo apt install git

5. install homebrew: https://docs.brew.sh/Homebrew-on-Linux
UPDATE: Please note, The first time I ran these commands below, brew worked on my linux ubuntu machine, however, after I restarted my machine, brew did not work, however, I ran this command to make it work again:
sudo apt install linuxbrew-wrapper


cd ~ sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"

#MAKE A BACKUP OF PRFOILE TO UPDATE THE PATH:
cp ~/.profile ~/.profile-BACKUP

# SEND COMMMANDS TO SET PATH:

test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)
test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
test -r ~/.bash_profile && echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.bash_profile
echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.profile


DONE, YOU CAN TEST IT:
brew install hello

YOU SHOULD GET A MESSAGE LIKE THIS:
Warning: hello 2.10 is already installed and up-to-date
To reinstall 2.10, run `brew reinstall hello`

6. install composer globally https://getcomposer.org/download/

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"


YOU WILL GET A MESSAGE ON COMPLETION:
All settings correct for using Composer
Downloading...

Composer (version 1.8.6) successfully installed to: /home/developer/composer.phar
Use it: php composer.phar

TO RUN COMPOSER GLOBALLY: https://getcomposer.org/doc/00-intro.md
mv composer.phar /usr/local/bin/composer

NOW YOU SHOULD ONLY TYPE: composer AND YOU WILL SEE THE SAME OUTPUT AS php composer.phar

INSTALL laravel: https://laravel.com/docs/5.8/installation
composer global require laravel/installer

I GOT THIS ERROR:

Changed current directory to /home/developer/.config/composer
Using version ^2.1 for laravel/installer
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.


Problem 1

- Installation request for laravel/installer ^2.1 -> satisfiable by laravel/installer[v2.1.0].
- laravel/installer v2.1.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.

To enable extensions, verify that they are enabled in your .ini files:
- /etc/php/7.2/cli/php.ini
- /etc/php/7.2/cli/conf.d/10-opcache.ini
- /etc/php/7.2/cli/conf.d/10-pdo.ini
- /etc/php/7.2/cli/conf.d/20-calendar.ini
- /etc/php/7.2/cli/conf.d/20-ctype.ini
- /etc/php/7.2/cli/conf.d/20-exif.ini
- /etc/php/7.2/cli/conf.d/20-fileinfo.ini
- /etc/php/7.2/cli/conf.d/20-ftp.ini
- /etc/php/7.2/cli/conf.d/20-gettext.ini
- /etc/php/7.2/cli/conf.d/20-iconv.ini
- /etc/php/7.2/cli/conf.d/20-json.ini
- /etc/php/7.2/cli/conf.d/20-phar.ini
- /etc/php/7.2/cli/conf.d/20-posix.ini
- /etc/php/7.2/cli/conf.d/20-readline.ini
- /etc/php/7.2/cli/conf.d/20-shmop.ini
- /etc/php/7.2/cli/conf.d/20-sockets.ini
- /etc/php/7.2/cli/conf.d/20-sysvmsg.ini
- /etc/php/7.2/cli/conf.d/20-sysvsem.ini
- /etc/php/7.2/cli/conf.d/20-sysvshm.ini
- /etc/php/7.2/cli/conf.d/20-tokenizer.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

Installation failed, deleting ./composer.json.



FIX ERROR: https://lerie.us/blog/2019/01/11/laravel-installer-v2-0-1-requires-ext-zip-the-requested-php-extension-zip-is-missing-from-your-system/
sudo apt-get -y install php7.[x]-zip
* CHANGE [x] TO WHATEVER VERSION YOU HAVE OR ELSE YOU MIGHT GET THIS ERROR: GOT ERROR:

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package php7.0-zip
E: Couldn't find any package by glob 'php7.0-zip'
E: Couldn't find any package by regex 'php7.0-zip'


TRY AGAIN:

7. INSTALL laravel: https://laravel.com/docs/5.8/installation
composer global require laravel/installer

COMPLETED:

Changed current directory to /home/developer/.config/composer
Using version ^2.1 for laravel/installer
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 14 installs, 0 updates, 0 removals
- Installing symfony/process (v4.3.2): Downloading (100%)
- Installing symfony/polyfill-ctype (v1.11.0): Downloading (100%)
- Installing symfony/filesystem (v4.3.2): Downloading (100%)
- Installing psr/container (1.0.0): Downloading (100%)
- Installing symfony/service-contracts (v1.1.5): Downloading (100%)
- Installing symfony/polyfill-php73 (v1.11.0): Downloading (100%)
- Installing symfony/polyfill-mbstring (v1.11.0): Downloading (100%)
- Installing symfony/console (v4.3.2): Downloading (100%)
- Installing guzzlehttp/promises (v1.3.1): Downloading (100%)
- Installing ralouphie/getallheaders (3.0.3): Downloading (100%)
- Installing psr/http-message (1.0.1): Downloading (100%)
- Installing guzzlehttp/psr7 (1.6.1): Downloading (100%)
- Installing guzzlehttp/guzzle (6.3.3): Downloading (100%)
- Installing laravel/installer (v2.1.0): Downloading (100%)
symfony/service-contracts suggests installing symfony/service-implementation
symfony/polyfill-mbstring suggests installing ext-mbstring (For best performance)
symfony/console suggests installing symfony/event-dispatcher
symfony/console suggests installing symfony/lock
symfony/console suggests installing psr/log (For using the console logger)
guzzlehttp/psr7 suggests installing zendframework/zend-httphandlerrunner (Emit PSR-7 responses)
guzzlehttp/guzzle suggests installing psr/log (Required for using the Log middleware)
Writing lock file
Generating autoload files



DONE laravel Completed Installation


8. PUT COMPOSER'S SYTEM-WIDE VENDOR BIN DIRECTORY IN YOUR $PATH
$HOME/.config/composer/vendor/bin

9. CHECK for a 'vendor' directory in /home/developer/.config/composer
ls ~/.config/composer/vendor/bin

10. NOW SET YOUR BIN $PATH:

sudo nano ~/.bashrc
ADD OR CHECK FOR THIS LINE:
export PATH=~/.config/composer/vendor/bin:$PATH
RESTART SHELL:
source ~/.bashrc

11. create a projects directory:
mkdir -p ~/laravel/projects/

12. Change to the newly created projects directory:
cd ~/laravel/projects/

13. DONE: YOU ARE READY TO GO:
laravel new myfirstsite

I GOT THESE ERRORS:

Crafting application...
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for erusev/parsedown 1.7.3 -> satisfiable by erusev/parsedown[1.7.3].
- erusev/parsedown 1.7.3 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
Problem 2
- Installation request for laravel/framework v5.8.28 -> satisfiable by laravel/framework[v5.8.28].
- laravel/framework v5.8.28 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
Problem 3
- Installation request for phar-io/manifest 1.0.3 -> satisfiable by phar-io/manifest[1.0.3].
- phar-io/manifest 1.0.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
Problem 4
- Installation request for phpunit/php-code-coverage 6.1.4 -> satisfiable by phpunit/php-code-coverage[6.1.4].
- phpunit/php-code-coverage 6.1.4 requires ext-dom * -> the requested PHP extension dom is missing from your system.
Problem 5
- Installation request for phpunit/phpunit 7.5.14 -> satisfiable by phpunit/phpunit[7.5.14].
- phpunit/phpunit 7.5.14 requires ext-dom * -> the requested PHP extension dom is missing from your system.
Problem 6
- Installation request for theseer/tokenizer 1.1.3 -> satisfiable by theseer/tokenizer[1.1.3].
- theseer/tokenizer 1.1.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
Problem 7
- laravel/framework v5.8.28 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- beyondcode/laravel-dump-server 1.2.2 requires illuminate/console 5.6.*|5.7.*|5.8.* -> satisfiable by laravel/framework[v5.8.28].
- Installation request for beyondcode/laravel-dump-server 1.2.2 -> satisfiable by beyondcode/laravel-dump-server[1.2.2].

12. Lets install the required dependcies:
sudo apt-get -y install php7.2-mbstring

sudo apt-get -y install php7.2-dom

13. LET"S TRY AGAIN:
rm -rf myfirstsite/
laravel new myfirstsite
NO MORE ERRORS! YOU SHOULD SEE SOMETING LIKE THIS:
Application ready! Build something amazing.

cd myfirstsite

ls

you will see your project file!
app bootstrap composer.lock database phpunit.xml resources server.php tests webpack.mix.js
artisan composer.json config package.json public routes storage vendor yarn.lock


You are ready to start your server:
php artisan serve

You can now see the default laravel project at
http://127.0.0.1:8000


15. install visual studio code, sublime or any other text code editor


Next you might want to install Ionic if so, you will need node.js:

sudo apt install nodejs

sudo apt install npm

sudo npm install -g ionic

Start an IONIC app:

sudo npm install -g ionic

ionic start myApp tabs

cd myApp

ionic serve


Good luck!