3.8. Configuring the Web Server (Apache)

Find what system user and group are used by Apache server and change $sys_apache_user and $sys_apache_group (in GForge configuration) respectively.

You should decide where to put GForge configuration of Apache. It's best if own configuration file that is included by main Apache configuration is used. Consult documentation of your distribution on recommended ways for doing this.

You may use etc/gforge-httpd.conf.example as template for your configuration. The rest of the section is guide to making GForge virtual host configuration for Apache from scratch. All is inside the following template:

NameVirtualHost 1.2.3.4
<VirtualHost 1.2.3.4>

# Put the rest of the directives here.

</VirtualHost>

Note

Configuring for SSL is not discussed in this guide.

  1. Set basic virtual host settings:

    ServerName  gforge.company.com
    ServerAdmin webmaster@gforge.company.com
    
  2. Define log files:

    CustomLog "/var/log/gforge/gforge/access.log" combined
    ErrorLog  "/var/log/gforge/gforge/error.log"
    

    Usual practice is to use logrotate on these files. Alternative is to pipe logs to cronolog which will automatically make directory with access.log and error.log for each day:

    CustomLog "|/usr/bin/cronolog /var/log/gforge/gforge/%Y/%m/%d/access.log" combined
    ErrorLog  "|/usr/bin/cronolog /var/log/gforge/gforge/%Y/%m/%d/error.log"
    

    Note

    In FHS-compliant install, you may want to use /var/local/gforge/log instead of /var/log/gforge. In any cases, the relevant directories should be created with appropriate permissions.

  3. Set up document root:

    DocumentRoot "/var/www/gforge/www"
    <Directory "/var/www/gforge/www">
        Options        FollowSymLinks
        AllowOverride  None
        Order          allow,deny
        Allow from all
        ErrorDocument  404 /404.php
    </Directory>
    
  4. Configuring PHP for Apache

    Ensure that PHP module is loaded. You may need to consult your distribution manual. Typical lines that load and configure PHP module are like this:

    LoadModule php_module	modules/libphp.so
    AddModule mod_php.c
    
    AddType application/x-httpd-php .php
    

    Insert the following instructions after the DocumentRoot directive:

    <Location /projects>
      ForceType application/x-httpd-php
    </Location>
    <Location /users>
      ForceType application/x-httpd-php
    </Location>
    

    Note

    If you use Apache 2, you may need to use a different configuration. Usually, this is not needed. If you receive a Page Not Found summary pages, you better try this different style of configuring.

    Change the existing Files directive to:

    <Files *.php>
        SetOutputFilter PHP
        SetInputFilter PHP
        AcceptPathInfo On
        LimitRequestBody 2097152
    </Files>
    

    The LimitRequestBody directive allows you to limit the maximum number of bytes of a request (including uploads). The default is 524288 (512Kb). This means that you cannot upload files with a size greater than 512Kb. With this directive, we set it to 2MB. If you wish to set this value higher than 2MB, you must also edit the upload_max_filesize directive in PHP configuration file.

    Add the following lines:

    <Files projects>
    SetOutputFilter PHP
    SetInputFilter PHP
    AcceptPathInfo on
    </Files>
    
    <Files users>
    SetOutputFilter PHP
    SetInputFilter PHP
    AcceptPathInfo on
    </Files>
    
  5. Set up PHP module:

    php_flag   register_globals On
    php_flag   magic_quotes_gpc On
    php_flag   files_uploads    On
    php_value  include_path     ".:/etc/gforge:/var/www/gforge:/var/www/gforge/www/include"
    php_value  default_charset  "UTF-8"
    
  6. Set up directory index script name:

    DirectoryIndex index.php
    

Of course, all changes will take effect only after reloading or restarting Apache.