Install Laravel in Cloud9 PHP Workspace

Before you start, you should update PHP to a current version.

Add Laravel Installer

composer global require "laravel/installer"
export PATH=~/.composer/vendor/bin:$PATH

Create new Laravel Project

laravel new YOUR_PROJECT

Change Webserver Document Root

sudo nano /etc/apache2/sites-enabled/001-cloud9.conf

Add the path to your public folder:

DocumentRoot /home/ubuntu/workspace/YOUR_PROJECT/public

Update MySQL Server

You should update the MySQL server to version >= 5.7 as described here, otherwise you have to set the Default String Length as described below.

Prepare the Database

mysql-ctl cli
CREATE DATABASE c9;
exit

Configure Database Connection

Change .env file

[...]
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=c9
DB_USERNAME=YOUR_CLOUD9_USERNAME
DB_PASSWORD=
[...]

Set Default String Length

Caution: Set default string length when using MySQL server < 5.7 (otherwise you will get migration problems). If you use MySQL server 5.7, you can skip to the next step.
Edit app/Providers/AppServiceProvider.php and add this to the boot method:

Schema::defaultStringLength(191);

At the top of the class, add:

use IlluminateSupportFacadesSchema;

Authentication Scaffolding

php artisan make:auth

Run Migrations

Run migrations:

php artisan migrate

Add SQLite

If you need it for testing, add sqlite:

sudo apt-get install php7.1-sqlite3

Some Optimizations

Ignore node_modules From ‘Navigate’ List

Add */node_modules to the “Ignore these files” list.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top