Bitnami Custom PHP Application

    In this guide you can find how to add your own PHP application on top of the LAMP/MAMP/WAMP Stack or any Virtual Machine or AMI.

    How to create the basic application structure?

    All PHP application are configured in a similar way in Bitnami. The following folders are into your installation directory or in "/opt/bitnami" if you are using the Virtual Machines or AMIs. 

    This is the basic folder structure:

    - apps/ This is the folder where are all the PHP applications (for example: apps/phpmyadmin, apps/wordpress, etc). In this guide we will use "myapp" name for the folder.

    - apps/myapp
                |- htdocs
                |- conf
                |- data (optional)

    win_platform.png On Windows: You can create the folders manually

    mac_platform.png On OS X: linux_platform.png On Linux: You can run the following commands:

    $ mkdir /installdir/apps/myapp
    $ mkdir /installdir/apps/myapp/htdocs
    $ mkdir /installdir/apps/myapp/conf

    - apps/myapp/htdocs In this folder you can find the PHP application files. This is where you should copy the application files or your PHP files.

    linux_platform.png On Linux: You can uncompress the application code into this folder. You can find below two examples for uncompressing a ".zip" file or a ".tar.gz" file:

    $ tar -xzvf myapp.tar.gz -C /installdir/apps/myapp/htdocs
    $ unzip -d /installdir/apps/myapp/htdocs

    - apps/myapp/conf/httpd-prefix.conf This is the Apache configuration file to configure your application at "".

    Alias /myapp/ "/installdir/apps/myapp/htdocs/"
    Alias /myapp "/installdir/apps/myapp/htdocs"
    Include "/installdir/apps/myapp/conf/httpd-app.conf"

    - apps/myapp/conf/httpd-app.conf. This is the main configuration file for your application. The content could be different depending on your application.

    <Directory /installdir/apps/myapp/htdocs>
        Options +FollowSymLinks
        AllowOverride None
        <IfVersion < 2.3 >
        Order allow,deny
        Allow from all
        <IfVersion >= 2.3>
        Require all granted

    (If you are using the Virtual Machine or the AMI, remember that "installdir" is /opt/bitnami).

    If your application uses .htaccess files, you should change the "AllowOverride None" option with "AllowOverride All". Check this note to move the .htaccess file to the main configuration.

    Once you have these files, you should add the following line at the bottom of the Apache configuration file "/installdir/apache2/conf/bitnami/bitnami-apps-prefix.conf".

    Include "/installdir/apps/myapp/conf/httpd-prefix.conf"

    Then, restart the Apache server and you can access your application at

    sudo /installdir/ restart apache

    How to deploy a demo app?

    PHP development stacks (LAMP/MAMP/WAMP and LAPP/MAPP/WAPP) ships a "docs" folder with a demo app in the installation directory. This demo application ships the configuration files mentioned in the previous section. 

    (If you are using the Virtual Machine or the AMI, remember that "installdir" is /opt/bitnami)

    • Copy the "demo" folder from the "/installdir/docs/demo" to "/installdir/apps". If you are using Linux or OS X you can do that from a Terminal:
    $ cd installdir    
    $ cp -r docs/demo apps
    • Then add the following entry in the "/installdir/apache2/conf/bitnami/bitnami-apps-prefix.conf" file:
    Include "/installdir/apps/demo/conf/httpd-prefix.conf"

    How to enable PHP-FPM in your custom application?

    PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for heavy-loaded sites. The recommended configuration is to configure Apache to serve the static files requests (images, css, javascripts and more) and use PHP_FPM with Apache "mod_proxy" module to handle the PHP requests.

    Take into account that PHP-FPM won't work on Windows systems.

    The first thing you need to do is to enable PHP-FPM in your Apache server. To do it, you can follow the steps in this wiki entry.

    Once it is done, you need to configure your application properly to use PHP-FPM. You have to modify some files


    Insert the following lines at the beginning

    <IfDefine USE_PHP_FPM>
        <Proxy "unix:/installdir/php/var/run/myapp.sock|fcgi://myapp-fpm" timeout=300>

    And then these ones inside the Directory

    <Directory "/installdir/apps/myapp/htdocs">
    <IfDefine USE_PHP_FPM>
           <FilesMatch \.php$>
             SetHandler "proxy:fcgi://myapp-fpm/"


    Now, create the folder php-fpm inside the conf directory, so that the structure is like this

                |- htdocs
                |- conf
                    |- php-fpm
                |- data (optional)


    and create a file called pool.conf inside with the following content




    Now you need to include the following line in the php-fpm.conf conf




    Finally restart Apache

    /installdir/ restart apache


    If are using a virtual machine or cloud image, or in the case that you installed as root a native installer for Mac OS X or Linux, you need to give read permissions to the the apache user or group. In these installations apache is running as the daemon user.

    sudo chgrp daemon /opt/bitnami/apps/demo/htdocs


    NOTE: This guide uses "/opt/bitnami" to refer to the installation directory. This is the default installation directory for Virtual Machines and Cloud Images. If you have installed your Bitnami stack in a different folder, replace "/opt/bitnami" with your installation directory in the examples.
    Tag page (Edit tags)
    • No tags
    Pages that link here
    Page statistics
    60192 view(s), 35 edit(s) and 8034 character(s)


    You must login to post a comment.

    Attach file