nativeInstallerlamp

Get started with Laminas

NOTE: We are in the process of modifying the file structure and configuration for many Bitnami stacks. On account of these changes, the file paths stated in this guide may change depending on whether your Bitnami stack uses native Linux system packages (Approach A), or if it is a self-contained installation (Approach B). To identify your Bitnami installation type and what approach to follow, run the command below:

 $ test ! -f "installdir/common/bin/openssl" && echo "Approach A: Using system packages." || echo "Approach B: Self-contained installation."

The output of the command indicates which approach (A or B) is used by the installation, and will allow you to identify the paths, configuration and commands to use in this guide. Refer to the FAQ for more information on these changes.

Approach A: Bitnami installations using system packages

The Laminas Project was previously known as Zend Framework, and is not included by default in Bitnami installations. However, it can be easily enabled using Composer. In this guide, you will learn how to install and configure a Laminas project.

Installation and Testing

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

  • First, create a project directory where to store your application. Run the following commands:

    $ sudo mkdir -p installdir/projects/APPNAME
    $ sudo chown $USER installdir/projects/APPNAME
    
  • Create the Laminas project. Run the following command:

    $ composer --no-interaction create-project -s dev laminas/laminas-mvc-skeleton installdir/projects/APPNAME
    
  • Grant write permissions for the web server to the data directory. Run the following command:

    $ sudo chown daemon:daemon installdir/projects/APPNAME/data
    
  • Create the Apache configuration for your application. Follow these steps:

    • Create the installdir/apache2/conf/vhosts/APPNAME-vhost.conf file containing the application’s HTTP virtual host configuration with the configuration block shown below:

      <VirtualHost 127.0.0.1:80 _default_:80>
        ServerAlias *
        DocumentRoot /opt/bitnami/projects/APPNAME/public
        <Directory "/opt/bitnami/projects/APPNAME/public">
          Options -Indexes +FollowSymLinks -MultiViews
          AllowOverride All
          Require all granted
        </Directory>
      </VirtualHost>
      
    • Create the installdir/apache2/conf/vhosts/APPNAME-https-vhost.conf file containing the application HTTPS virtual host configuration with the configuration block shown below:

      <VirtualHost 127.0.0.1:443 _default_:443>
        ServerAlias *
        DocumentRoot installdir/projects/APPNAME/public
        SSLEngine on
        SSLCertificateFile "installdir/apache2/conf/bitnami/certs/server.crt"
        SSLCertificateKeyFile "installdir/apache2/conf/bitnami/certs/server.key"
        <Directory "installdir/projects/APPNAME/public">
          Options -Indexes +FollowSymLinks -MultiViews
          AllowOverride All
          Require all granted
        </Directory>
      </VirtualHost>
      
  • Finally, restart the Apache server:

    $ sudo installdir/ctlscript.sh restart apache
    

You can now verify that the example application is working by visiting its URL using your browser at http://localhost/. Here is an example of what you might see:

Laminas welcome page

Configuration

If your application will use a database, MySQL support is already available by default. If you plan to use PostgreSQL, enable the pdo_pgsql extension in the installdir/php/etc/php.ini file.

extension=pdo_pgsql

Approach B: Self-contained Bitnami installations

The Laminas Project was previously known as Zend Framework, and is not included by default in Bitnami installations. However, it can be easily enabled using Composer. In this guide, you will learn how to install and configure a Laminas project.

Installation and Testing

NOTE: This section assumes that the application project directory will be located at installdir/frameworks/laminas/htdocs. Remember to replace the APPNAME placeholder with the application name, such as myapp.

  • First, create a project directory where to store your application. Run the following commands:

    $ sudo mkdir -p installdir/frameworks/laminas/htdocs
    $ sudo chown $USER installdir/frameworks/laminas/htdocs
    
  • Create the Laminas project. Run the following command:

    $ composer --no-interaction create-project -s dev laminas/laminas-mvc-skeleton installdir/frameworks/laminas/htdocs
    
  • Grant write permissions for the web server to the data directory. Run the following command:

    $ sudo chown daemon:daemon installdir/frameworks/laminas/htdocs/data
    
  • Create the Apache configuration for your application. Follow these steps:

    • Create the Apache configuration directory for the sample application:

      $ sudo mkdir -p installdir/frameworks/laminas/conf
      
    • Create and edit the installdir/frameworks/laminas/conf/httpd-app.conf file and add the content below to it. This is the main configuration file for your application, so modify it further depending on your application’s requirements.

      <Directory installdir/frameworks/laminas/htdocs/public>
          Options -Indexes +FollowSymLinks -MultiViews
          AllowOverride All
          Require all granted
      </Directory>
      
    • Create and edit the installdir/frameworks/myapp/conf/httpd-prefix.conf file and add the following configuration block:

      Alias /laminas/ "installdir/frameworks/laminas/htdocs/public"
      Alias /laminas "installdir/frameworks/laminas/htdocs/public"
      Include "installdir/frameworks/laminas/conf/httpd-app.conf"
      
    • Edit the Apache configuration file at installdir/apache2/conf/bitnami/bitnami-apps-prefix.conf and add the following line

      Include "installdir/frameworks/laminas/conf/httpd-prefix.conf"
      
  • Finally, restart the Apache server:

    $ sudo installdir/ctlscript.sh restart apache
    

You can now verify that the example application is working by visiting its URL using your browser at http://localhost/. Here is an example of what you might see:

Laminas welcome page

Configuration

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

  • If your application will use a database, MySQL support is already available by default. If you plan to use PostgreSQL, enable the php_pdo_pgsql extension in the installdir/php/etc/php.ini file.

    extension=php_pdo_pgsql
    
  • To move the Laminas application such that it is available at the root URL of the server (without the /laminas URL suffix), follow these steps:

    • Edit the installdir/frameworks/laminas/conf/httpd-prefix.conf file so that it looks like this:

      DocumentRoot "installdir/frameworks/laminas/htdocs/public"
      #Alias /laminas/ "installdir/frameworks/laminas/htdocs/public"
      #Alias /laminas "installdir/frameworks/laminas/htdocs/public"
      Include "installdir/frameworks/laminas/conf/httpd-app.conf"
      
    • Restart the Apache server:

      $ sudo installdir/ctlscript.sh restart apache
      

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

More Information

Learn more about developing applications with the Laminas Project at https://docs.laminas.dev/.

Last modification July 29, 2020