Get started with Laravel


The Laravel framework is installed in the frameworks/laravel directory in the installation directory. This directory includes an example application. Application configuration files are in the conf/ directory and public files, such as HTML pages, CSS and JavaScript files, images and other media assets are stored in the public/ directory.

Activation and Testing

To enable the example application, edit the Apache configuration file at /opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf and uncomment the following line

Include "/opt/bitnami/frameworks/laravel/conf/httpd-prefix.conf"

Then, restart the Apache server.

$ sudo /opt/bitnami/ restart apache

You can now verify that the example application is working by visiting its URL using your browser at http://SERVER-IP/laravel.

Here is an example of what you might see (Laravel 4.x):

Laravel 4 welcome page

Here is an example of what you might see (Laravel 5.x):

Laravel 5 welcome page


Before using the example application, here are a few important points to consider:

  • To start a new project, edit the file at /opt/bitnami/frameworks/laravel/app/routes.php (Laravel 4.x) or /opt/bitnami/frameworks/laravel/app/Http/routes.php (Laravel 5.x) and add a new route:

    Route::get('my-first-route', function()
        return 'Hello World!';

    This will create the application route /my-first-route. To see this route in action, append this route to the application URL and visit it in your browser, such as http://SERVER-IP/laravel/index.php/my-first-route. If all is working correctly, you will see the output “Hello World!”.

  • If your application will use a database, edit the database settings in the app/config/database.php (Laravel 4.x) or config/database.php (Laravel 5.x) file.

    return array(
            'connections' => array(
                    'mysql' => array(
                            'driver'    => 'mysql',
                            'host'      => 'localhost',
                            'database'  => 'database_name',
                            'username'  => 'user',
                            'password'  => 'pass',
                            'charset'   => 'utf8',
                            'collation' => 'utf8_unicode_ci',
                            'prefix'    => '',

    MySQL support is already available by default. If you plan to use PostgreSQL, enable the php_pdo_pgsql extension in the /opt/bitnami/php/etc/php.ini file.

  • To move the Laravel application such that it is available at the root URL of the server (without the /laravel URL suffix), follow these steps:

    • Edit the /opt/bitnami/frameworks/laravel/conf/httpd-prefix.conf file so that it looks like this:

      DocumentRoot "/opt/bitnami/frameworks/laravel/public"
      #Alias /laravel/ "/opt/bitnami/frameworks/laravel/public/"
      #Alias /laravel "/opt/bitnami/frameworks/laravel/public"
      Include "/opt/bitnami/frameworks/laravel/conf/httpd-app.conf"
    • Edit the /opt/bitnami/frameworks/laravel/conf/httpd-app.conf file and replace the AllowOverride None directive with the AllowOverride All directive:

      AllowOverride All
    • Restart the Apache server:

      $ sudo /opt/bitnami/ restart apache

    You should now be able to access the example application at the root URL of your server.

Key Regeneration

A random key of 32 characters is generated during the installation. You can change it later to another random key.

$ cd /opt/bitnami/frameworks/laravel
$ sudo php artisan key:generate

These commands will generate a new key and print it in the terminal. Copy the 32-character key and then edit the /opt/bitnami/frameworks/laravel/config/app.php file. You should see a line like this:

'key' => env('APP_KEY', 'PasteYourKeyHere')

Just paste your generated key and save the file.

Upgrading to Laravel 5.1

Follow the steps below to upgrade to Laravel 5.1:

  • Remove the composer.lock file in the /opt/bitnami/frameworks/laravel directory:

    $ rm /opt/bitnami/frameworks/laravel/composer.lock
  • Update composer.json with the latest version:

    "laravel/framework": "5.1.*"
  • Create a cache/ directory under /opt/bitnami/frameworks/laravel/bootstrap/:

    $ mkdir -p /opt/bitnami/frameworks/laravel/bootstrap/cache/
  • Edit the $compiledPath variable in the /opt/bitnami/frameworks/laravel/bootstrap/autoload.php file as below:

    $compiledPath = __DIR__.'/cache/compiled.php';
  • Create the file /opt/bitnami/frameworks/laravel/bootstrap/cache/.gitignore with this content:

  • Set bitnami as the owner and give writable permission to /opt/bitnami/frameworks/laravel/bootstrap/cache:

    $ sudo chmod 775 /opt/bitnami/frameworks/laravel/bootstrap/cache
    $ sudo chown bitnami:root /opt/bitnami/frameworks/laravel/bootstrap/cache
  • Add Illuminate\Broadcasting\BroadcastServiceProvider to the providers array in the /opt/bitnami/frameworks/laravel/config/app.php file:


    Note the comma (,) at the end of the line.

  • Modify the /opt/bitnami/frameworks/laravel/app/Http/Controllers/Auth/AuthController.php header from

    use App\Http\Controllers\Controller;
    use Illuminate\Contracts\Auth\Guard;
    use Illuminate\Contracts\Auth\Registrar;
    use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;


    use App\User;
    use Validator;
    use App\Http\Controllers\Controller;
    use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
  • Modify /opt/bitnami/frameworks/laravel/app/Http/Controllers/Auth/AuthController.php constructor from

    * Create a new authentication controller instance. *
    * @param \Illuminate\Contracts\Auth\Guard $auth
    * @param \Illuminate\Contracts\Auth\Registrar $registrar
    * @return void */
    public function __construct(Guard $auth, Registrar $registrar) { $this->auth = $auth; $this->registrar = $registrar;
            $this->middleware('guest', ['except' => 'getLogout']);


    * Create a new authentication controller instance. *
    * @return void */
    public function __construct() {
    $this->middleware('guest', ['except' => 'getLogout']);
  • Add in the same file just after the method above:

    * Get a validator for an incoming registration request. *
    * @param array $data
    * @return \Illuminate\Contracts\Validation\Validator
    protected function validator(array $data) {
    return Validator::make($data, [ 'name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|confirmed|min:6', ]);
    * Create a new user instance after a valid registration. *
    * @param array $data
    * @return User
    protected function create(array $data) {
    return User::create([ 'name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password']), ]);
  • Remove the /opt/bitnami/frameworks/laravel/app/Services directory.

    $ rm -rf /opt/bitnami/frameworks/laravel/app/Services
  • Modify the /opt/bitnami/frameworks/laravel/app/Http/Controllers/Auth/PasswordController.php file from

    * Create a new password controller instance.
    public function __construct(Guard $auth, PasswordBroker $passwords) { $this->auth = $auth; $this->passwords = $passwords;


    * Create a new password controller instance.
    * @return void
    public function __construct()
  • Modify the /opt/bitnami/frameworks/laravel/app/Http/routes.php file from

    Route::get('/', 'WelcomeController@index');
    Route::get('home', 'HomeController@index');
        'auth' => 'Auth\AuthController',
        'password' => 'Auth\PasswordController',


    Route::get('/', function () {
    return view('welcome');
  • Remove the /opt/bitnami/frameworks/laravel/vendor directory:

    $ rm -rf /opt/bitnami/frameworks/laravel/vendor
  • Include the baseUrl class variable in the /opt/bitnami/frameworks/laravel/tests/TestCase.php file:

    class TestCase extends Illuminate\Foundation\Testing\TestCase {
    * The base URL to use while testing the application.
    * @var string
    protected $baseUrl = 'http://localhost';
  • Delete the /opt/bitnami/frameworks/laravel/storage/framework/compiled.php file:

    $ sudo rm /opt/bitnami/frameworks/laravel/storage/framework/compiled.php
  • Run composer update in the /opt/bitnami/framework/laravel directory:

    $ composer update
  • Check the version of Laravel:

    $ php artisan --version

You can also make these optional changes if you wish.

More Information

Learn more about developing applications with Laravel at

Last modification April 8, 2020