Apache

     

    How-To Guides

    Htaccess configuration

    PageSpeed module

     

     

     

    How to start/stop the Apache server?

    Graphical tool

    The Stacks include a graphical tool to manage the servers easily. You can find the "manager-windows.exe", "manager-osx" or "manager-linux" tool in your installation directory. Using this tool, you can Start, Stop or Restart the servers and check the log files. You can click on the icon to start it.

    manager-servers.png

     

    manager-osx.png

     

     

     

     

     

     

     

     

     


    win_platform.png

    On Windows: You can also start the Manager tool from shortcuts: Start -> Program Files -> BitNami Stack -> Manager tool

    Command line tool

    If you prefer, you can use the "ctlscript.sh" utility from the command line. This script is in the installation directory.

    linux_platform.png

    On Virtual Machines and Cloud images:

    $ sudo /opt/bitnami/ctlscript.sh start

    A native installer on Linux:

    $ cd ~/application-version
    $ ./ctlscript.sh start
    

    mac_platform.png

     

    On OS X: You can start the Manager tool from the installation directory or you can use the "ctlscript.sh" utility from a Terminal.

    host:~ user$ cd /Applications/application-version
    host:~ user$ ./ctlscript.sh start

    Why I can't start the Apache server?

    Check the apache error file

    Check the apache error file for information about why the error ocurred. 

    You can find that file in installdir/apache2/logs/error_log on Unix platforms and in  installdir/apache2/logs/error.log on Windows.

    installdir is you installation directory. On Cloud Images and Virtual Machines it is /opt/bitnami.

    Check if another process is listening to that port

    If another process is using that address you'll get:

    (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:port_number
    no listening sockets available, shutting down

    To see which process is already using that port you can run the following from a command prompt:

    On Linux:

    sudo netstat -ltnp | grep :port_number
    

    In the last column you'll see: pid / process_name

    You can use later:

    ps aux | grep process_name
     
    look for pid in the second column and you'll get more info about that process.

    On  OSX:

    sudo netstat -ltnp TCP | grep :port_number
    

    On Windows:

    netstat -b -a -n
     
    In case that other process is using that port you should use another port or stop the that process.
     
    Check permissions and ownership

    Check if you have permissions to bind Apache to the requested port. To bind apache to privileged ports you have to start Apache as root.

    If you don't have permissions to bind Apache to some port you'll see the next error:

    (13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:port_number
    no listening sockets available, shutting down

    If Apache is unable to open the configuration or the log file check that the owner of those files is the same user that installed Apache and have write permissions on logs and read permissions on conf file. In that case you will see some of this errors:

    (13)Permission denied: AH00649: could not open transfer log file installdir/apache2/logs/access_log. 
    AH00015: Unable to open logs
    (13)Permission denied: AH00091: httpd: could not open error log file installdir/apache2/logs/error_log.
    AH00015: Unable to open logs
    
    httpd: Could not open configuration file installdir/apache2/conf/httpd.conf: Permission denied
    apache config test fails, aborting

    How to configure the Apache server?

    The main Apache configuration file is called httpd.conf and it is located at:

    BitNami Installers

    /installdir/apache2/conf/httpd.conf

    BitNami Cloud Hosting and Virtual Machines

    Ubuntu: /opt/bitnami/apache2/conf/httpd.conf

    Amazon Linux / Red Hat Enterprise:  /etc/httpd/conf/httpd.conf

    In recent versions of BitNami apps  the bitnami.conf file defines which configuration for each application should be loaded by the Apache server. This file is located in/installdir/apache2/conf/bitnami/bitnami.conf. Note that for Virtual Machines and Cloud Images installdir is /opt/bitnami.

    By default the BitNami applications are accessible in http://YOUR_IP/appname. The list of applications to load with this configuration is included in /installdir/apache2/conf/bitnami/bitnami-apps-prefix.conf.

    Those applications that need to be served in a different virtual host, should be included in the /installdir/apache2/conf/bitnami/bitnami-apps-vhosts.conf file.

    How to configure your web application?

    Recent versions of BitNami apps ship three configuration files in the "/installdir/apps/myapp/conf/" folder: httpd-app.conf, httpd-prefix.conf and httpd-vhosts.conf.

    - httpd-app.conf. This is the main configuration file for the application. It could be different 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". You can check the Apache note about this. BitNami applications have moved the configuration into the application ".htaccess" files to the "/installdir/apps/myapp/conf/htaccess.conf" file. You can find more info here.

    - httpd-prefix.conf. This file ships the default configuration for the applications in "prefix" mode (http://example.com/myapp).

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

    - httpd-vhosts.conf. This file contains the default configuration for virtual host (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>
    

    It is possible to configure your application to use Virtual Host instead of running in "/myapp" URL. The basic change is the following:

    Delete the following line in the /installdir/apache2/conf/bitnami/bitnami-apps-prefix.conf file:

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

    And add a new link in the /installdir/apache2/conf/bitnami/bitnami-apps-vhosts.conf file:

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

    Some applications require changes in configuration files or in the database. Please check the exact changes in the Application itself page.

    Please note that after modifying the Apache configuration files, you will need to restart  Apache to apply the changes.

     

    Previous versions of BitNami apps use  /installdir/apps/myapp/conf/myapp.conf file. This file usually have the following configuration for PHP-based applications (it could be different depending on the application):

    Alias /myapp/ "/installdir/apps/myapp/htdocs/"
    Alias /myapp "/installdir/apps/myapp/htdocs"
    
    <Directory /installdir/apps/myapp/htdocs>
        Options +FollowSymLinks
        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"
    
    How to redirect www.myapp.example.com (or other domains) to my server?

    It is also possible that you want to add a "ServerAlias" in the VirtualHost configuration. You can add the following in the httpd-vhosts.conf file for your application. This option allows you to add alternate names for a host used when matching requests. For example www.myapp.example.com, myapp.example.org or myapp.example.uk.com. Note that you need to add this in all the

    <VirtualHost *:80>
    ServerName app.example.com
    ServerAlias www.app.example.com app.example.org www.app.example.uk.org
    ...
    
    <VirtualHost *:443>
    ServerName app.example.com
    ServerAlias www.app.example.com app.example.org www.app.example.uk.org
    

    Please note that after modifying the Apache configuration files, you will need to restart  Apache to apply the changes.

    How to redirect www.myapp.example.com to myapp.example.com?

    This redirection is a SEO good practice. You can add the following in the httpd-vhosts.conf file for you application

    <VirtualHost *:80>
    ServerName app.example.com
    ServerAlias www.app.example.com
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ http://%1$1 [R=permanent,L]
    ...
    
    <VirtualHost *:443>
    ServerName app.example.com
    ServerAlias www.app.example.com
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ https://%1$1 [R=permanent,L]
    ...
    

    Please note that after modifying the Apache configuration files, you will need to restart  Apache to apply the changes.

    How to redirect myapp.example.com to www.myapp.example.com?

    You can add the following code in the httpd-vhosts.conf file for your application "/opt/bitnami/apps/your_app/conf/httpd-vhosts.conf". If you want to apply this redirection by default for all applications installed, you can add it in the default VirtualHost in the "/opt/bitnami/apache2/conf/bitnami.conf" file.

    <VirtualHost *:80>
      ServerName app.example.com
      ServerAlias www.app.example.com
      RewriteEngine On
      RewriteCond %{HTTP_HOST} !^www\. [NC]
      RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
     ...
     
    <VirtualHost *:443>
      ServerName app.example.com
      ServerAlias www.app.example.com
      RewriteEngine On
      RewriteCond %{HTTP_HOST} !^www\. [NC]
      RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
     ...
     
    Please note that after modifying the Apache configuration files, you will need to restart  Apache to apply the changes.
    How to access to my application from only one domain?

    The default Bitnami server configuration allows you to access to the server from different methods: using the Amazon EC2 or Azure domain name (f.e. ec2-xx-yy-zz.amazonaws.com or xxxx.cloudapp.net), using the IP address directly or using the Bitnami Cloud Hosting domain (f.e. xxxx.bitnamiapp.com).

    If you want to redirect all these domains to your own domain, you can configure Apache server to redirect all these requests to the same domain.

    You can add the following configuration into the /opt/bitnami/apache2/conf/bitnami/bitnami.conf file. Note that you have to replace "example.com" with your own domain.

    <VirtualHost _default_:80>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^example.com$
    RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1)
    RewriteRule ^(.*)$ http://example.com$1 [R=permanent,L]
    ...
    
    <VirtualHost _default_:443>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^example.com$
    RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1)
    RewriteRule ^(.*)$ https://example.com$1 [R=permanent,L]
    ...
    

    Then restart the Apache server.

    How to force HTTPS redirection for my application?
    If you want to force redirection for all the requests in your whole server (all your applications) check our documentation for the Apache component.

    Add the following in the httpd-vhost.conf (your_installation_directory/apps/your_application/conf/httpd-vhosts.conf) file inside the first <VirtualHost> directive (in the example below using port 80):

    <VirtualHost *:80>
    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]
    ...
    </VirtualHost>
    <VirtualHost *:443>
    ...
    </VirtualHost>
    

    Please note that after modifying the Apache configuration files, you will need to restart  Apache to apply the changes.

    How to change the apache port?

    With the default configuration, Apache will wait for requests in the port 8080. You can change that by editing the httpd.conf file and modifiying the value specified in the Port directive. On Linux and OS X platforms you should install the Stack as root user to select a port number under 1024.

    Listen 8080
    

    Then it is necessary to restart the Apache server.

    How to publish my web page?

    If you already have a web page and you want to serve its content with Apache, you can do so simply by copying your files to the default document root directory: /installdir/apache2/htdocs/.

    How to create a password to protect access to apache?

    To request a username and a password when accessing your application, follow these steps:

    linux_platform.png

    mac_platform.png

    On Linux and OS X: Open the console that you can find in the installation directory and type the following.

     

    $ cd your_installation_directory
    $ apache2/bin/htpasswd -cb apache2/yourapplicationname_users username password
    

    win_platform.png On Windows: Open a console from the Start Menu shortcuts and type the following commands:

     

    > cd your_installation_directory
    > apache2\bin\htpasswd -cb apache2\yourapplicationname_users username password
    


    Then it is necessary to add the following in the Apache configuration file. BitNami applications have their own configuration file that you can find at "installdir/apps/app_name/conf/httpd-app.conf". Don't forget to comment the "Require all granted" line.

    <Directory "/installdir/apps/my_application/htdocs">
    ...
      AuthType Basic
      AuthName MyAuthName
      AuthUserFile "/installdir/apache2/yourapplicationname_users"
      Require valid-user
    ...  
    
    <IfVersion >= 2.3>
    # Require all granted
    </IfVersion>
    ...
    </Directory>
    

     

     

    Restart the Apache server:

    $ sudo /installdir/ctlscript.sh restart apache
    
     
    If you want to change the password, run the htpasswd utility without the -c switch. Like this:
    $ sudo /installdir/apache2/bin/htpasswd /installdir/apache2/yourapplicationname_users username
    

    How to enable SSL to access through https?

    First, you need to have the SSL certificate and the SSL certificate key already in place. You can generate them on your own as explained in the next section, get them from one of many commercial cetrtificate authorities or use the dummy one that is set by default.

    Cloud Image/BitNami Hosting

    SSL is enabled by default with a dummy certificate. You can upload your own certificate and key files to the default locations:

    /opt/bitnami/apache2/conf/server.crt
    /opt/bitnami/apache2/conf/server.key

    Note that the server key may be already in the server if you followed the steps to create a certificate.

    If you use different file names, you should reconfigure the options SSLCertificateFile and SSLCertificateKeyFile in  /opt/bitnami/apache2/conf/bitnami/bitnami.conf.

    It may happen, that your certificate authority will provide you with the file of PEM-encoded Server CA Certificates. If it is the case, you will need to place this file in "/opt/bitnami/apache2/conf/server-ca.crt", and then edit the file "/opt/bitnami/apache2/conf/bitnami/bitnami.conf" to include the following line below the SSLCertificateKeyFile:

    SSLCertificateChainFile "/opt/bitnami/apache2/conf/server-ca.crt"
    

    Then restart the Apache server and try to access at "https://xyz.bitnamiapp.com".

    $ sudo /opt/bitnami/ctlscript.sh restart apache
    

    Note: You can find more info about how to upload and edit files in this page.

    Once you have copied all the server certificate files, you may make them readable by root user only with the following commands:

    $ sudo chown root:root /opt/bitnami/apache2/conf/server*
    $ sudo chmod 600 /opt/bitnami/apache2/conf/server*

    Native Installer

    SSL is enabled by default with a dummy certificate. You can upload your own certificate and key files to the default locations:

    /installdir/apache2/conf/server.crt
    /installdir/apache2/conf/server.key
    

    If you use different file names, you should reconfigure the options SSLCertificateFile and SSLCertificateKeyFile in  /installdir/apache2/conf/bitnami/bitnami.conf.

    It may happen, that your certificate authority will provide you with the file of PEM-encoded Server CA Certificates. If it is the case, you will need to place this file in /installdir/apache2/conf/server-ca.crt, and then edit the file /installdir/apache2/conf/bitnami/bitnami.conf to include the following line below the SSLCertificateKeyFile:

    SSLCertificateChainFile "/installdir/apache2/conf/server-ca.crt"
    

    Then restart the Apache server and try to access at "https://yourdomain.com".

    $ sudo /installdir/ctlscript.sh restart apache
    

    The path to the default configuration file is

    /installdir/apache2/conf/bitnami/bitnami.conf
    

    Virtual Machine

    SSL is enabled by default with a dummy certificate. You can upload your own certificate and key files to the default locations:

    /installdir/apache2/conf/server.crt
    /installdir/apache2/conf/server.key
    

    If you use different file names, you should reconfigure the options SSLCertificateFile and SSLCertificateKeyFile in  /installdir/apache2/conf/bitnami/bitnami.conf (or  /installdir/apache2/conf/extra/httpd-ssl.conf it doesn't exist).

    It may happen, that your certificate authority will provide you with the file of PEM-encoded Server CA Certificates. If it is the case, you will need to place this file in /installdir/apache2/conf/server-ca.crt, and then edit the file /installdir/apache2/conf/bitnami/bitnami.conf to include the following line below the SSLCertificateKeyFile:

    SSLCertificateChainFile "/installdir/apache2/conf/server-ca.crt"
    

    Then restart the Apache server and try to access at "https://yourdomain.com".

    $ sudo /installdir/ctlscript.sh restart apache
    

    The path to the default configuration file is

    /installdir/apache2/conf/bitnami/bitnami.conf
    

    Amazon Linux / RHEL

    Upload your certificate to the "/opt/bitnami/apache2/conf/server.crt" location and the certificate key file to "/opt/bitnami/apache2/conf/server.key". Server key may be already in the server if you followed the steps to create a certificate.

    Edit the options "SSLCertificateFile" and "SSLCertificateKeyFile" in /etc/httpd/conf.d/ssl.conf so they point to your certificate files:

    SSLCertificateFile /opt/bitnami/apache2/conf/server.crt
    
    SSLCertificateKeyFile /opt/bitnami/apache2/conf/server.key

    It may happen, that your certificate authority will provide you with the file of PEM-encoded Server CA Certificates. If it is the case, you will need to place this file in /opt/bitnami/apache2/conf/server-ca.crt, and then uncomment and configure the option SSLCertificateChainFile in /etc/httpd/conf.d/ssl.conf:

    SSLCertificateChainFile "/opt/bitnami/apache2/conf/server-ca.crt"

    Then restart the Apache server and try to access at "https://xyz.bitnamiapp.com".

    $ sudo /opt/bitnami/ctlscript.sh restart apache
    

    Note: You can find more info about how to upload and edit files in this page.

    Once you have copied all the server certificate files, you may make them readable by root user only with the following commands:

    $ sudo chown root:root /opt/bitnami/apache2/conf/server*
    $ sudo chmod 600 /opt/bitnami/apache2/conf/server*

    Tabs end

    For Amazon instances you'll need to add the port 443 to your security groups, see the following link:

    http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html#adding-security-group-rule

     

    Note: If you use a custom domain for your server or you application URL location was changed from /myapp to the root  /, you should make sure that the ServerName option is set to "your domain" and DocumentRoot points to the application htdocs directory for the default VirtualHost in the file apache2/conf/bitnami/bitnami.conf (or apache2/conf/extra/httpd-ssl.conf if it doesn't exist). For example, if you have a Wordpress application configured in the root URL with the www.example.com domain, it will look as below: 
    <VirtualHost _default_:443>
    #   General setup for the virtual host
    DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
    ServerName www.example.com:443
    

     

    Note2: You can configure per application certificates if you use Virtual Host configutarion. To enable Virtual Host in your application, follow the steps here http://wiki.bitnami.com/Components/Apache#How_to_create_a_Virtual_Host.3f

    After that, you have to add the following lines in the 443 Virtual Host (or the one you want to be accessed through HTTPS). Change the path if necessary

    SSLEngine on
    SSLCertificateFile "/opt/bitnami/apps/wordpress/conf/certs/server.crt"
    SSLCertificateKeyFile "/opt/bitnami/apps/wordpress/conf/certs/server.key"
    

    How to create a SSL certificate?

    You can create your own SSL certificate with the OpenSSL binary. A certificate request can then be sent to a certificate authority to get it signed into a certificate, or if you have your own certificate authority, you may sign it yourself, or if you need a self-signed certificate (because you just want a test certificate or because you are setting up your own CA).

    Native Installer

    First create your private key (if you haven't created it already):

    $ /installdir/common/bin/openssl genrsa -out /installdir/apache2/conf/server.key 2048 
    

    The certificate request is created like this:

    $ /installdir/common/bin/openssl req -new -key /installdir/apache2/conf/server.key -out /installdir/apache2/conf/cert.csr
    

    Important: You should enter the server domain when the above command asks for the "Common Name"

    Now, cert.csr can be sent to the certificate authority. When the certificate authority has then done the checks they need to do (and probably gotten payment from you), they will hand over your new certificate to you.

    In the meantime, until you get your certificate, you will need to create a temporary self-signed certificate:

    $ /installdir/common/bin/openssl x509 -in /installdir/apache2/conf/cert.csr -out /installdir/apache2/conf/server.crt -req -signkey /installdir/apache2/conf/server.key -days 365
    
     
    If you want to back up your private key in a safe location, you may generate a password protected version as follows: (Note that if you use this encrypted key in the Apache onfiguration you will need to enter the password manually on every Apache startup)
    $ /installdir/common/bin/openssl rsa -des3 -in /installdir/apache2/conf/server.key -out privkey.pem
     

    VMware and Cloud

    First create your private key  (if you haven't created it already):

    $ sudo /opt/bitnami/common/bin/openssl genrsa -out /opt/bitnami/apache2/conf/server.key 2048
    

    The certificate request is created like this:

    $ sudo /opt/bitnami/common/bin/openssl req -new -key /opt/bitnami/apache2/conf/server.key -out /opt/bitnami/apache2/conf/cert.csr

    Important: You should enter the server domain when the above command asks for the "Common Name"

    Now, cert.csr can be sent to the certificate authority. When the certificate authority has then done the checks they need to do (and probably gotten payment from you), they will hand over your new certificate to you.

    In the meantime, until you get your certificate, you will need to create a temporary self-signed certificate:

    $ sudo /opt/bitnami/common/bin/openssl x509 -in /opt/bitnami/apache2/conf/cert.csr -out /opt/bitnami/apache2/conf/server.crt -req -signkey /opt/bitnami/apache2/conf/server.key -days 365
    
     
    If you want to back up your private key in a safe location, you may generate a password protected version as follows:
    $ sudo /opt/bitnami/common/bin/openssl rsa -des3 -in /opt/bitnami/apache2/conf/server.key -out privkey.pem
    

    Note that if you use this encrypted key in the Apache configuration you will need to enter the password manually on every Apache startup. You can regenerate the key without password protection from this file as follows:

    $ sudo /opt/bitnami/common/bin/openssl rsa -in privkey.pem -out /opt/bitnami/apache2/conf/server.key
    

     

    Note:  If you are using Amazon Linux or RedHat Enterprise you should replace "/opt/bitnami/common/bin/openssl" with "openssl" in the commands above.

    Tabs end
     

     

    You can find more info about certificates at http://www.openssl.org.
     

    How to check your certificate and key?

    If you get a similar error like this in your Apache error log file, it seems you are not using the correct certificate or key.

    [Mon May 12 15:37:46.891294 201X] [ssl:emerg] [pid 15450] AH02565: Certificate and private key example.com:443:0 from /opt/bitnami/apps/your_app/conf/certs/server.crt and /opt/bitnami/apps/your_app/conf/certs/server.key do not match

    You can verify that the current key matches the cert file with the following commands. The "Modulus" portion in the key and cert should must match:

    openssl x509 -noout -text -in server.crt -modulus | grep Modulus
    Modulus=D6E23C2E6140707EA63F3250...

    Then check your key:

    openssl rsa -noout -text -in server.key -modulus | grep Modulus
    Modulus=D6E23C2E6140707EA63F3250...

    If they are not the same, you are using a wrong key for the certificate so Apache could not be started until you fixed this issue.

    How to force HTTPS access?

    If you only want to force this redirection for one of your applications (such as Wordpress) then you will need to add this in the application configuration file for Apache.

    It depends on your current Apache configuration but in most cases it should be enough to add the following lines in the default Apache virtual host configuration file. Edit the"/opt/bitnami/apache2/conf/bitnami/bitnami.conf" file and add the following recode into the <VirtualHost _default_:80> section:

    <VirtualHost _default_:80>
      DocumentRoot "/opt/bitnami/apache2/htdocs"
      RewriteEngine On
      RewriteCond %{HTTPS} !=on
      RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]
      ...
    

    Then restart the Apache web server.

    How to configure multiple SSL domains on the same IP address?

    There is an extension to the SSL protocol called "Server Name Indication". It allows you to use only one IP address for several SSL-protected sites. The only drawback is that some older web browsers do not support it. The example Apache configuration is shown below:

    NameVirtualHost *:80
    
    <VirtualHost *:80>
    ServerName my-wordpress.example.com
    DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
    </VirtualHost>
    <VirtualHost *:80>
    ServerName my-sugarcrm.example.com
    DocumentRoot "/opt/bitnami/apps/sugarcrm/htdocs"
    </VirtualHost>
    
    Listen 443
    NameVirtualHost *:443
    
    <VirtualHost *:443>
    SSLEngine on
    DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
    ServerName my-wordpress.example.com
    SSLCertificateFile "/opt/bitnami/apache2/conf/my-wordpress.crt"
    SSLCertificateKeyFile "/opt/bitnami/apache2/conf/my-wordpress.key"
    </VIrtualHost>
    
    <VirtualHost *:443>
    SSLEngine on
    DocumentRoot "/opt/bitnami/apps/sugarcrm/htdocs"
    ServerName my-sugarcrm.example.com
    SSLCertificateFile "/opt/bitnami/apache2/conf/my-sugarcrm.crt"
    SSLCertificateKeyFile "/opt/bitnami/apache2/conf/my-sugarcrm.key"
    </VIrtualHost>
    

    You can learn more at the following pages:

    How to change the URL?

    This approach describes how to configure your application to run in the root URL directly. The details are described below.

    Native Installer

    If you want to change the default URL from http://your_domain/your_application to http://your_domain, you should add a "DocumentRoot" entry in your application conf file. Edit the /installdir/apps/your_application/conf/httpd-prefix.conf file to add this line and commenting the "Alias" entries. Modify the

    httpd_prefix.conf file content:

    DocumentRoot "/installdir/apps/your_application/htdocs"
    # Alias /your_application/ "/installdir/apps/your_application/htdocs/"
    # Alias /your_application "/installdir/apps/your_application/htdocs"
    
    (...)
    

    Some applications also require changes in their configuration files or in the database.

    Virtual Machine

    If you want to change the default URL from http://your_domain/your_application to http://your_domain, you should add a "DocumentRoot" entry in your application conf file. Edit the /opt/bitnami/apps/your_application/conf/httpd-prefix.conf file (your_application.conf in previous versions) to add this line and commenting the "Alias" entries. You can use the "nano" editor:

    $ sudo nano /opt/bitnami/apps/your_application/conf/httpd-prefix.conf
    

    httpd-prefix.conf file content:

    DocumentRoot "/opt/bitnami/apps/your_application/htdocs"
    # Alias /your_application/ "/opt/bitnami/apps/your_application/htdocs/"
    # Alias /your_application "/opt/bitnami/apps/your_application/htdocs"
    
    (...)
    

    Some applications also require changes in their configuration files or in the database.

    Cloud Image/BitNami Hosting

    If you want to change the default URL from http://your_domain/your_application to http://your_domain, you should add a "DocumentRoot" entry in your application conf file. Edit the /opt/bitnami/apps/your_application/conf/httpd-prefix.conf file (your_application.conf in previous versions) to add this line and commenting the "Alias" entries. You can use the "nano" command line editor or you can also edit this file from your favorite FTP program.

    $ sudo nano /opt/bitnami/apps/your_application/conf/httpd-prefix.conf
    

    httpd-prefix.conf file content:

    DocumentRoot "/opt/bitnami/apps/your_application/htdocs"
    # Alias /your_application/ "/opt/bitnami/apps/your_application/htdocs/"
    # Alias /your_application "/opt/bitnami/apps/your_application/htdocs"
    
    (...)
    

    Some applications also require changes in their configuration files or in the database.

    Tabs end

     

    How to create a Virtual Host?

    You can configure the URL for the applications using Virtual Hosts. They would allow you to access the applications at "http://example.com/" or "http://prefix.example.com"  instead of "http://example.com/application". In this example we are going to configure Wordpress to be accessible from "example.com" and SugarCRM from "crm.example.com"

    1. Comment the line that includes the prefix configuration file in the /installdir/apache2/conf/bitnami/bitnami-apps-prefix.conf file:

    #Include "/installdir/apps/wordpress/conf/httpd-prefix.conf"
    Include "/installdir/apps/sugarcrm/conf/httpd-prefix.conf"
    

    2. Write the following file "/installdir/apps/httpd-vhosts.conf"

    NameVirtualHost *:80
    
    <VirtualHost *:80>
        ServerAdmin xx
        DocumentRoot "/installdir/apps/wordpress/htdocs"
        ServerName example.com
        ServerAlias www.example.com
    </VirtualHost>
    <VirtualHost *:80>
        ServerAdmin xx
        Redirect permanent / http://example.com/sugarcrm
        ServerName crm.example.com
        ServerAlias www.crm.example.com
    </VirtualHost>
    

    3. Include the vhost configuration file for your application in the /installdir/apache2/conf/bitnami/bitnami-apps-vhosts.conf

    Include "/installdir/apps/wordpress/conf/httpd-vhost.conf"
    

    4. Update the URL if it is necessary. In the Wordpress case is necessary to run the following command to update the Wordpress database:

    $ sudo /installdir/mysql/bin/mysql -u root -p -e "use bitnami_wordpress; update wp_options set option_value='http://example.com' where option_name='siteurl' or option_name='home'"
    

    5. Restart the Apache server:

    $ sudo /installdir/ctlscript.sh restart apache
    

    How to debug errors?

    Once Apache starts, it will create two log files, the access_log and the error_log /installdir/apache2/logs directory or in /var/log/httpd if you are using Amazon Linux or Red Hat Enterprise cloud images.

    In Virtual Machines, Cloud Images and Ubuntu based Bitnami Cloud Hosting images installdir is /opt/bitnami.

    The access_log file is used to track client requests. When a client requests a document from the server, Apache records several parameters associated with the request in this file, such as: the IP address of the client, the document requested, the HTTP status code, and the current time.

    The error_log file is used to record important events. This file includes error messages, startup messages, and any other significant events in the life cycle of the server. This is the first place to look when you run into a problem when using Apache.

    If no error is found, you will see a message similar to:

    Syntax OK
    /installdir/ctlscript.sh : httpd started
    

    How to enable mod_security in Apache?

    Bitnami stacks already ship the mod_security2 module installed in Apache but it is not enabled by default. To enable this module you have to run the following commands in your server.

    • Enable the "mod_security2" and "mod_unique_id" modules in Apache. Edit the main Apache configuration file and uncomment the "unique_id_module" and add the mod_security2 line at the end of the LoadModule section:
    ...
    LoadModule unique_id_module modules/mod_unique_id.so
    ...
    LoadModule security2_module modules/mod_security2.so
    • Add the default configuration file for mod_security at the end of the Apache configuration file:
    Include "/opt/bitnami/apache2/conf/modsecurity.conf"
    
    • Restart Apache server and check it is already enabled:
    $ sudo /opt/bitnami/ctlscript.sh restart apache
    $ tail /opt/bitnami/apache2/logs/error_log
    
    ...
     [Thu Jan 30 18:42:14.004246 2014] [:notice] [pid 1127] ModSecurity for Apache/2.6.7 (http://www.modsecurity.org/) configured.
     ...
    
     

    How to add mod_xsendfile module in Apache?

    Since BitNami LAMP/MAMP/WAMP version 5.4.13-2, the mod_xsendfile module is already installed. To enable this module you only have to add the following line in the Apache httpd.conf file:

    LoadModule xsendfile_module modules/mod_xsendfile.so
    


    If you are using a previous version, it is easy to install this module on top of your existing Apache. It is necessary to have already installed the compilation tools. If you are using a BitNami Virtual Machine or Cloud Image you already have all the required components.

     

    • Download latest version:
    wget https://tn123.org/mod_xsendfile/mod_xsendfile-0.12.tar.gz
    
    • Extract the content and install the module
    $ tar -xzvf mod_xsendfile-0.12.tar.gz
    $ cd mod_xsendfile-0.12
    $ sudo /opt/bitnami/apache2/bin/apxs -aci mod_xsendfile.c
    

    If everything goes well, you can see the module at "/opt/bitnami/apache2/modules/mod_xsendfile.so". Check the mod_xsenfile configuration page to know how to configure this module for your application.

    Tag page (Edit tags)
    Pages that link here
    Page statistics
    397220 view(s), 239 edit(s) and 47481 character(s)

    Comments

    You must login to post a comment.

    Attach file

    Attachments

    FileSizeDateAttached by 
     manager-osx.png
    manager tool icon
    31.61 kB17:58, 26 Sep 2012AdminActions
     winSCP-sudo.png
    winSCP sudo
    17.28 kB16:54, 3 Nov 2011AdminActions