deploying a laravel app on Ubuntu 18.04

$ sudo su
$ apt install php mysql-server apache2 composer git npm vim
$ cd /var/www
$ git clone https://your.repo
$ cd /var/www/your_repo
$ composer install

composer usually throws an error here because you have to install php dependencies. Scroll to the top of the error message. It may be something like, Laravel requires ext-dom or Laravel requires ext-curl.

Whenever you see ext, replace it with php, and then run:

$ apt install php-dom php-curl

After you install dependencies and composer finishes installing the php portion of your app, do this:

$ vim .env.example

in the .env.example

do this:

:sav .env

Then edit the following environment variables.

DB_DATABASE=your_database
DB_USERNAME=your_mysql_username
DB_PASSWORD=your_password

if you are running prod, make sure you do this:

APP_DEBUG=false

additional dependency that must be installed

$ apt install php-mysql

then do this

$ php artisan key:generate
$ php artisan migrate
$ npm install
$ npm run dev

Oh yeah, very important. 90% of problems with Laravel deployment out of the box can be solved with this. Do this last.

$ chown -R www-data:www-data /path/to/app

and remember to exit root.