Get started with Laravel

The Laravel framework is not installed by default in Bitnami installations. However, it can be easily enabled via the Laravel Installer tool. In this guide, you will learn how to install and configure a Laravel project.

Installation and Testing

NOTE: This section assumes that the application project directory will be located at /opt/bitnami/projects/APPNAME. Remember to replace the APPNAME placeholder with the application name, such as myapp.

  • First, install the Laravel Installer tool and make it available in your PATH. Run the following commands:

      $ composer global require laravel/installer
      $ echo 'PATH=$PATH:$HOME/.config/composer/vendor/bin' | sudo tee -a /etc/profile
      $ export PATH=PATH=$PATH:$HOME/.config/composer/vendor/bin
  • Create a project directory where to store your application. Run the following commands:

      $ sudo mkdir -p /opt/bitnami/projects
      $ sudo chown $USER /opt/bitnami/projects
  • Create the Laravel project:

      $ cd /opt/bitnami/projects
      $ laravel new APPNAME
  • Grant write permissions for the web server to the storage directory. Run the following command:

      $ sudo chown daemon:daemon /opt/bitnami/projects/APPNAME/storage
  • Create the NGINX configuration for your application. Follow these steps:

    • Create the /opt/bitnami/nginx/conf/server_blocks/APPNAME-server-block.conf file containing the application’s HTTP server block configuration with the configuration block shown below:

        server {
            # Port to listen on, can also be set in IP:PORT format
            listen 80 default_server;
            root /opt/bitnami/myapp/public;
            # Catch-all server block
            # See:
            server_name _;
            include  "/opt/bitnami/nginx/conf/bitnami/*.conf";
    • Create the /opt/bitnami/nginx/conf/server_blocks/APPNAME-https-server-block.conf file containing the application HTTPS server block configuration with the configuration block shown below:

        server {
            # Port to listen on, can also be set in IP:PORT format
            listen 443 ssl default_server;
            root /opt/bitnami/myapp/public;
            # Catch-all server block
            # See:
            server_name _;
            ssl_certificate      bitnami/certs/server.crt;
            ssl_certificate_key  bitnami/certs/server.key;
            include  "/opt/bitnami/nginx/conf/bitnami/*.conf";
  • Finally, restart the NGINX server:

      $ sudo /opt/bitnami/ restart nginx

You can now verify that the example application is working by visiting its URL using your browser at http://SERVER-IP/. Here is an example of what you might see (Laravel 7):

Laravel welcome page


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

  • To start a new project, edit the file at routes/web.php:

      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/my-first-route. If all is working correctly, you will see the output “Hello World!”.

  • If your application will use a database, edit the .env file.


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


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/projects/APPNAME
$ php artisan key:generate

These commands will generate a new key and automatically write it to the .env file:


More Information

Learn more about developing applications with Laravel at

Last modification February 9, 2023