Create a virtual host for a custom application
Understand virtual host configuration files
Recent versions of Bitnami apps ship three configuration files in the installdir/apps/myapp/conf/ directory: httpd-app.conf, httpd-prefix.conf and httpd-vhosts.conf.
The httpd-app.conf file is the main configuration file for the application. It could have different content depending on the application:
<Directory "installdir/apps/myapp/htdocs"> Options +MultiViews AllowOverride None <IfVersion < 2.3 > Order allow,deny Allow from all </IfVersion> <IfVersion >= 2.3> Require all granted </IfVersion> </Directory> Include installdir/apps/myapp/conf/htaccess.conf
For security and performance reasons, it is advisable to not set AllowOverride All to anything other than None (refer to this Apache note for more information). Bitnami applications store this configuration in the installdir/apps/myapp/conf/htaccess.conf file (more information).
The httpd-prefix.conf file ships the default configuration for the applications in “prefix” mode, such that the application can be accessed at (for example) http://example.com/myapp.
Alias /myapp/ "installdir/apps/myapp/htdocs/" Alias /myapp "installdir/apps/myapp/htdocs" Include "installdir/apps/myapp/conf/httpd-app.conf"
The httpd-vhosts.conf file contains the default configuration for virtual hosts, for applications to be accessed at (for example) http://myapp.example.com.
<VirtualHost *:8080> ServerName myapp.example.com DocumentRoot "installdir/apps/myapp/htdocs" Include "installdir/apps/myapp/conf/httpd-app.conf" </VirtualHost> <VirtualHost *:8444> ServerName myapp.example.com DocumentRoot "installdir/apps/myapp/htdocs" SSLEngine on SSLCertificateFile "installdir/apps/myapp/conf/certs/server.crt" SSLCertificateKeyFile "installdir/apps/myapp/conf/certs/server.key" Include "installdir/apps/myapp/conf/httpd-app.conf" </VirtualHost>
Define virtual host configuration
To configure your application to use a virtual host instead of the prefix URL, make these changes:
Delete the following line in the installdir/apache2/conf/bitnami/bitnami-apps-prefix.conf file:
Add a new link in the installdir/apache2/conf/bitnami/bitnami-apps-vhosts.conf file:
- Some applications require further changes in configuration files or the database. Please check the exact changes in the application’s documentation.
NOTE: After modifying the Apache configuration files, restart Apache to apply the changes.