Laravel

     

    NOTE: This guide uses /opt/bitnami to refer to the installation directory for the Bitnami Stack. This is the default installation directory for Bitnami Cloud Hosting, Google Cloud Platform and Microsoft Azure servers and for virtual servers. If you're using a native installer and have installed the Bitnami Stack to a different folder, replace /opt/bitnami in the examples below with your actual installation directory.

    Overview

    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/ctlscript.sh restart apache
    

    You can now verify that the example application is working by visiting its URL using your browser. Select your platform below.

    Bitnami Cloud Hosting

    Access the example application via your browser at http://[server-IP-address]/laravel

    Microsoft Azure / Google Cloud Platform

    Access the example application via your browser at http://[server-IP-address]/laravel


    Virtual Machine

    Access the example application via your browser at http://[virtual-server-IP-address]/laravel

    Native Installer

    Access the example application via your browser at http://localhost/laravel(Windows) or http://localhost:8080/laravel (Mac OS X and Linux).

    Tabs end

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

    laravel.png

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

    Configuration

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

    1. 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://[virtual-server-IP-address]/laravel/index.php/my-first-route. If all is working correctly, you will see the output ‘Hello World!’.

    2. 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.

    extension=php_pdo_pgsql
    

    To obtain access credentials for the MySQL database, use user 'root'. For the MySQL password, follow the steps below:

    Bitnami Cloud Hosting

    Google Cloud Platform

    • Browse to the Bitnami Launchpad for Google Cloud Platform dashboard and sign in if required using your Bitnami account.
    • Select the "Virtual Machines" menu item.
    • Select your Bitnami Stack server from the resulting list.
    • Obtain the password by selecting "Show" under "Credentials".


    Microsoft Azure

    To log in, use default password 'bitnami'.

    Virtual Machine

    To log in, use default password 'bitnami'.

    Native Installer

    The password is the one specified by you during the Bitnami Stack installation process.

    Tabs end

    3. To move the Laravel example 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
    • c. Restart the Apache server:
    $ sudo /opt/bitnami/ctlscript.sh restart apache
    

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

    Regenerate key

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

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

    It will generate a new one and print it in the terminal. Just copy your 32 characters application key.

    $ sudo nano /opt/bitnami/framework/laravel/config/app.php 

    You should see a line like this: 'key' => env('APP_KEY', 'PasteYourKeyHere'), just paste your generated key and save the file.

    More Information

    Learn more about developing applications with Laravel at http://laravel.com/docs/.

    Tag page (Edit tags)
    • No tags
    Pages that link here
    Page statistics
    136324 view(s), 16 edit(s) and 8639 character(s)

    Comments

    You must login to post a comment.