Create a custom PHP application

Before running the commands shown on this page, you should load the Bitnami stack environment by executing the installdir/use_APPNAME script (Linux and MacOS) or by clicking the shortcut in the Start Menu under “Start -> Bitnami APPNAME Stack -> Application console” (Windows). On OS X VMs, the installation directory is /opt/bitnami and OS X VM users can click the “Open Terminal” button to run commands. Learn more about the Bitnami stack environment and about OS X VMs.

Many users run a Bitnami stack as a development environment for their own PHP projects (as opposed to running third-party applications such as Joomla! or WordPress). To deploy your PHP application in this environment, you have two options:

To make a single PHP application accessible at the root URL of the Web server (for example, http://localhost), simply copy the PHP files into the installdir/apache2/htdocs folder. For an example, take a look at the phpinfo example.

To have several applications running, create the same structure used by Bitnami when installing Bitnami PHP applications. Recent versions of Bitnami stacks ship a demo application with this structure to help you get started. To use this, follow the steps below:

Copy the installdir/docs/demo folder into the installdir/apps directory.

$ sudo cp -r installdir/docs/demo installdir/apps

Add the following line to the end of the installdir/apache2/conf/bitnami/bitnami-apps-prefix.conf file:

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

Restart the Apache server using the command-line tool.

$ sudo installdir/ctlscript.sh restart apache

You should now be able to access the demo application at http://localhost/demo. You should see a “Hello world” message in your browser.

If your stack does not include a demo application, or if you prefer to create a custom PHP application from scratch, follow the steps below. These steps assume that your application will live in the installdir/apps/myapp/ directory:

Create and edit the installdir/apps/myapp/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.

Once you have created the files and directories above, add the following line to the end of the main Apache configuration file at installdir/apache2/conf/bitnami/bitnami-apps-prefix.conf, as shown below:

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

Restart the Apache server:

$ sudo installdir/ctlscript.sh restart apache

You should now be able to access the application at http://localhost/myapp.