# FusionForge Installation Guide

&reinhard_spisser;&tom_copeland;&ognyan_kulev;&guillaume_smet;

## Hardware Requirements

Hardware requirements are dependent on the number of users that will use the system and how active those users are.

For instance, an installation of FusionForge hosts over 450 users and over 140 projects on a single CPU Pentium 2.4GHz machine with 512 MB of RAM.

You can find additionnal information about hardware used by several installations of GForge in the old GForge sites list that used to be maintained by Tom Copeland.

## Software Requirements

FusionForge should work correctly on any system configured like this:

1. GNU/Linux Operating System

2. PostgreSQL 8.3 or later

3. Apache 2.2 or later

4. openssl 0.9.4 or later

5. mod_ssl 2.4.10 or later (included in Apache 2.0 and later)

6. PHP 5.2 or later (php5.1 should work)

7. php-pgsql (enable it with `--with-pgsql` when building PHP, or install it as package)

8. php-mbstring (enable it with `--with-mbstring` when building PHP, or install it as package)

9. htmlpurifier 4.0 or later

Optional software:

1. Turck MMCache or PHP Accelerator or any other PHP accelerator (highly recommended)

2. GNU Mailman and Python (Mailing list support)

3. JPGraph (Gantt Charting and Graphing Support)

4. Perl, DBI module and associated `DBD::Pg`.

Successful installations and operations have been done using the following systems:

- Debian GNU/Linux 5.0 (Lenny)

- CentOS 5

- RedHat Enterprise Linux 5

## Installation

### Overview

The `INSTALL` file in FusionForge package and `README` files in plugin directories are the authoritative sources for installation instructions and they should have more precedence over this guide.

This installation guide is for FusionForge 5.0.

FusionForge has a lot of different pieces touching a lot of different components in the system. Cronjobs are required to maintain the system, touching lots of files on a daily and hourly basis, including `/etc/*` system files.

The plugins that now manage the CVS and SVN functionality have made installation slightly harder because even more files have to be moved into place during installation.

The manual installation of FusionForge is documented below. Be sure to follow each step carefully, check the forums for frequently asked questions, and ask your Apache, Mailman, and PostgreSQL installation questions in the corresponding mailing lists rather than on the FusionForge forums where little help is available.

### Installing FusionForge on Debian

You can simply add lines found at to `/etc/apt/sources.list` and type `apt-get install fusionforge` to install a working FusionForge system, thanks to Christian Bayle and Roland Mas.

Note that FusionForge will soon be part of official Debian, and so you will find it in all debian mirrors all other the planet. Package versions of FusionForge may lag behind upstream versions. From scratch install snapshot are also available for a guided installation.

### Installing FusionForge on RPM-based systems

RPM should be available soon, see website for availability.

### Installing FusionForge oneself on a linux distribution

To install FusionForge, follow these steps (as root):

#### Directory Layout

Instructions below assume that gforge is unpacked into `/opt/gforge` . There are some other directories where FusionForge stores files. In this installation guide, they are put in `/var/www` too.

If you want to be FHS-compliant, FusionForge should be unpacked into `/usr/local/share/gforge`, and directories for storing files should be in `/var/lib/gforge` or `/var/local/gforge`. You may use symbolic links to physically place files in FHS-compliant places and still use directory paths that are presented in this manual.

#### Getting the source

There is two ways to get the sources from FusionForge :

     # tar -xjvf fusionforge-5.0.tar.bz2
     # cd fusionforge-5.0
     # mkdir -p /opt/gforge
     # cp -r */opt/gforge

#### Checking out from the SVN repository with tag v5_0

Alternative way to get FusionForge 5.0 is to check out with tag v5_0 from SVN. This gets latest fixes as well.

     $ svn checkout --username anonsvn svn://scm.fusionforge.org/svnroot/fusionforge/tags/v5_0 fusionforge-5.0

     $ cd fusionforge
     $ cd gforge/www/plugins
    $ ln -s ../../plugins/scmcvs/www scmcvs
    $ ln -s ../../plugins/scmsvn/www scmsvn
    $ ln -s ../../plugins/cvstracker/www cvstracker

##### Fixing access rights

You may want to make sure that permissions are correct (replace apache-group with the system group used by Apache server):

    # cd /opt/gforge
    # chown -R root:apache-group .
    # chmod -R 644 .
    # find -type d | xargs chmod 755
    # chmod -R 755 cronjobs

#### FusionForge Config File

In the FusionForge distribution, you will find `etc/local.inc.example`. Copy it to `/etc/gforge/local.inc` and edit all of the settings. In later sections, there is more information about specific configuration settings. Usually, you will want to make it readable only by webserver user (see for apache-user and apache-group):

    # mkdir /etc/gforge
    # chown root: /etc/gforge
    # chmod 755 /etc/gforge
    # cp /opt/gforge/etc/local.inc.example /etc/gforge/local.inc
    # chown apache-user:apache-group /etc/gforge/local.inc
    # chmod 600 /etc/gforge/local.inc

#### Configuring FusionForge

Open `/etc/gforge/local.inc`, configuring the following basic parameters:

1. Database configuration:

       $sys_dbhost="localhost"
       $sys_dbname="gforge"
       $sys_dbuser="gforge"
       $sys_dbpasswd="gforge-password"

2. The directive `$sys_default_domain` should contain the domain of your server, e.g. `gforge.company.com`. You may want to replace all occurences of company.com with company's domain name.

### Configuring the Database (PostgreSQL)

#### PostgreSQL Requirements

You to have installed the following packages for

1. a CentOS or Red Hat 5 or Fedora: postgresql, postgresql-libs, postgresql-server, postgresql-contrib

2. a Debian: postgresql, postgresql-contrib

#### Initialization of PostgreSQL

In some distributions, PostgreSQL database cluster is not initialised. Consult distribution documentation for more information. If database cluster is not created, you can do so by running:

    # su - postgres
    $ initdb

This will wipe out any existing PostgreSQL databases!

#### PostgreSQL Authentication Configuration

The `postgres` PostgreSQL user is used only during installation. Usually, it can connect via UNIX socket without password when invoked by `postgresql` system account. Check by running this:

    # /etc/init.d/postgresql restart
    # su - postgres
    $ psql template1

If connection fails, add the following line to `pg_hba.conf`:

    local all postgres ident sameuser

FusionForge uses `gforge` PostgreSQL user to connect to `gforge` database by using password. (You can change that name by editing `local.inc`.) In order this to work, assure that you have the following line in your `pg_hba.conf` (before other `host` directives):

    host gforge gforge 127.0.0.1 255.255.255.255 md5

This line assumes that FusionForge will always use local PostgreSQL database (`localhost`). If this is not the case, consult PostgreSQL manual for ways to allow connection.

After all these changes to PostgreSQL configuration files are made, PostgreSQL should be restarted. This depends on the distribution. In Debian, it's like this:

    # /etc/init.d/postgresql restart

#### Importing Database

Create FusionForge database user:

    # su - postgres
    $ psql template1
    template1=# CREATE USER gforge NOCREATEUSER NOCREATEDB
    template1-# PASSWORD 'gforge-password';

Create FusionForge database:

    template1=# CREATE DATABASE gforge OWNER gforge ENCODING 'UNICODE';
    template1=# \q

Add PL/pgSQL support using the commands:

    $ createlang plpgsql gforge

Finally, install the database:

    $ cd /opt/gforge/db
    $ psql -a -U gforge -W -h localhost -f gforge.sql gforge &> /tmp/gforge.sql.log

You may experience the following errors. They are harmless and you can safely ignore them:

    ERROR:  permission denied for language c
    ERROR:  must be superuser to create procedural language
    ERROR:  permission denied for schema public

### Configuring DNS Server (BIND)

FusionForge needs its own domain. In example FusionForge configuration file, it's `gforge.company.com`. You should search for company.com in example FusionForge configuration file and replace it with your domain name.

Here some example configuration files for BIND are presented that can help you if you are not familiar with BIND but it's not meant to be complete. Don't ask BIND-related questions in FusionForge forums, consult documentation that come with your distribution and search in Internet. Distributions put files in different places and so there are no file locations here. The example configuration below is only quick start example and doesn't include reverse mapping.

For DNS, you need to have the bind package installed

New subdomain in `gforge.company.com` should be created. In company.com zone file, it may look like that:

    gforge          IN      NS      ns.gforge.company.com.
    ns.gforge       IN      A       1.2.3.4

Do not add the latter resource record (`ns.gforge`) if this DNS server serves both `company.com` and `gforge.company.com` zones.

New zone file for `gforge.company.com` may look like this:

    $TTL    2d
    @       IN      SOA     gforge.company.com. hostmaster.gforge.company.com. (
                                  1         ; Serial
                             172800         ; Refresh
                                900         ; Update retry
                            2419200         ; Expire
                               3600 )       ; Negative Cache TTL
    ;
    @               IN      NS      ns.gforge.company.com.
    @               IN      A       1.2.3.4
    ns              IN      A       1.2.3.4

    download        IN      A       1.2.3.4
    shell           IN      A       1.2.3.4
    users           IN      A       1.2.3.4
    lists           IN      A       1.2.3.4
    cvs             IN      A       1.2.3.4
    svn             IN      A       1.2.3.4
    scm             IN      A       1.2.3.4
    ldap            IN      A       1.2.3.4

The new zone must be added in main BIND configuration file:

    zone "gforge.company.com" {
            type master;
            file "/dist-specific/path/to/zone-file";
    };

Of course, changes will take effect after reloading BIND.

It is required that the dns service is up on each reboot.

    $ chkconfig named on

### Configuring PHP

Make sure you have installed `pgsql` and `mbstring` modules.

PHP is used in two ways:

1. Serving Web pages. In this case, PHP is usually used as module and its configuration is in virtual host configuration, as shown later in the document. If you prefer to configure `php.ini`, the following directives are required by FusionForge:

       magic_quotes_gpc = Off
       file_uploads = On
       include_path=".:/opt/gforge:/opt/gforge/www/include:/etc/gforge"

2. Cron jobs and some scripts require PHP Command-Line Interface (CLI). Scripts are usually invoked with command like this:

       $ php5 -f cronjobs/mail/mailing_lists_create.php

   The `-f` is optional when using PHP CLI but it's required when PHP CGI executable is used.

   You must set `include_path` in PHP CLI `php.ini`, like already shown above. Increase `memory_limit` configuration parameter to at least 32M. To find where `php.ini` is located, use the following command:

       $ php5 -i | fgrep php.ini

### 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 FusionForge configuration) respectively in /etc/gforge/local.inc.

You should decide where to put FusionForge 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 FusionForge 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>

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"

   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 "/opt/gforge/www"
       <Directory "/opt/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 (this is automaticaly made when you install php with rpm or deb). 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>

   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:

   If the register_globals variable is set to On in your php.ini, add this line in your conf apache :

       php_flag   register_globals Off

   If the files_uploads variable is not set to On in your php.ini, add this line in your conf apache :

       php_flag   files_uploads    On

   If the AddDefaultCharset variable is not set to UTF-8 in your httpd.conf, add this line in your conf apache :

       php_value  default_charset  "UTF-8"

   Add these lines in your conf apache

       php_flag   magic_quotes_gpc Off
       php_value  include_path     ".:/etc/gforge:/opt/gforge:/opt/gforge/www/include"

6. Set up directory index script name (this is automaticaly made when you install php with rpm or deb) :

       DirectoryIndex index.php

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

### Configuring Mail Transport Agent (Any)

Add the following line to `/etc/aliases` and run `newaliases`:

    noreply: /dev/null

Make sure that the following domain names are accepted as local destinations by mail transport agent:

- `gforge.company.com`

- `lists.gforge.company.com`

- `users.gforge.company.com`

You may want to consider adding `MX` (mail exchanger) resource records for the above domain names. This is meaningful only if you want fallback mail routes or if firewall doesn't allow incoming port 25 for the server.

#### Mail gateways to forum and tracker

When forum or tracker is monitored, replying to monitor mails are processed by mail gateways. These gateways use FusionForge configuration file `/etc/gforge/local.inc` so that they can access database but the problem is that they run with different user than that of Apache. So if you want to use these gateways, you'll have to change access mode of `local.inc`.

### File Release System (FRS)

Create a directory (e.g. `/var/lib/gforge/download`) and make it owned by the webserver user. This directory will be referenced in the FusionForge Config File `/etc/gforge/local.inc` as `$sys_upload_dir`.

    # mkdir /var/lib/gforge/download
    # chown -R apache-user/var/lib/gforge/download

For FHS-compliance, use `/var/local/gforge/download`.

### Configuring GNU Mailman

GNU Mailman is used to help manage the FusionForge mailing lists. Mailman is frequently installed in `/usr/lib/mailman` but sometimes it can be found in `/var/mailman`. You should change FusionForge configuration variable `$sys_path_to_mailman` to that Mailman directory.

Cronjobs for Mailman are located in `cronjobs/mail/*`. `cronjobs/mail/mailing_lists_create.php` is used obviously to create new mailing lists.

For all problems with Mailman installation and use, contact the Mailman mailing lists for help.

To install it:

1. Install a GNU Mailman package or compile it

2. Don't integrate Mailman with Postfix (or other MTA) by delegating it generation of alias-style file. FusionForge generates such file. But you'll need to put mail aliases in `/etc/aliases` for the required standard `mailman` mailing list. Create it with:

       # /usr/lib/mailman/bin/newlist mailman

3. Configure `mm_cfg.py`:

   - `DEFAULT_HOST_NAME` and `DEFAULT_URL` should point to `lists.gforge.company.com`. These variable names may vary depending on Mailman distribution.

   - Strip ugly `cgi-bin` from URLs in configuration parameters.

4. `su` to `root` and set the Mailman password by using the `mmsitepass` command

5. Create directory `/var/www/mailman/`. It will be document root for `lists.gforge.company.com.`

6. In Web server configuraton, create virtual host for Mailman, adjusting `ScriptAlias` and `Alias` directives:

       <VirtualHost 1.2.3.4>
         ServerName    lists.gforge.company.com
         ServerAdmin   webmaster@gforge.company.com

       # You may want to add these files to logrotate, or just use cronolog as shown below
         CustomLog "/var/log/gforge/lists/access.log" combined
         ErrorLog  "/var/log/gforge/lists/error.log"

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

         DocumentRoot  /var/www/mailman
         DirectoryIndex index.html
         ScriptAlias   /mailman/ /usr/lib/cgi-bin/mailman/
         Alias         /pipermail/ /var/lib/mailman/archives/public/
         Alias         /images/ /usr/share/images/
       </VirtualHost>

   Check that `ScriptAlias` and `Alias` directories are correct. The example values are for Debian 3.1 (Sarge).

#### Mailing list for commits

When repositories are created, mailing list `project-commits@lists.gforge.company.com` is created too. Note that project administrators should manually set Privacy Options... / Sender filters / accept_these_nonmembers to something like `^.*@servername\.company\.com` where servername.company.com is name of the host where Mailman is installed (`lists.gforge.company.com`).

### Source Code Management (SCM)

CVS and Subversion (SVN) are popular SCM systems that may be installed as plugins, as shown later. You'll have to make their needed directories:

    # mkdir /var/www/scmtarballs
    # mkdir /var/www/scmsnapshots

These directories correspond to FusionForge configuration variables `$sys_scm_tarballs_path` and `$sys_scm_snapshots_path`.

For FHS-compliance, use `/var/local/gforge/scmtarballs` and `/var/local/gforge/scmsnapshots`.

### Cron Jobs

Cron jobs are in the `cronjobs/` directory and the `crontab.in` file contains a sample crontab. This gives you the basic cronjobs for updating certain statistics and data on the site.

`cronjobs/cvs-cron/` contains scripts useful for creating blank cvs trees and managing the `/etc/groups`, `/etc/passwd` and `/etc/shadow` files. See `cronjobs/README.root` and CVS plugins section for more info.

`cronjobs/mail/` contains files useful for the creation of new mailing lists in mailman and creating the `/etc/aliases` file.

Prepare for `cronjobs/cvs-cron/usergroup.php` and `cronjobs/mail/mailaliases.php`.

    # adduser anonymous
    # cp /etc/aliases /etc/aliases.org
    # cp /etc/shadow /etc/shadow.org
    # cp /etc/passwd /etc/passwd.org
    # cp /etc/group /etc/group.org

There are two other ways to authenticate FusionForge users: LDAP and NSS with PostgreSQL backend. They are not discussed in this guide.

The `cronjobs/cvs-cron/usergroup.php` cron script will meddle with your `/etc/passwd`, `/etc/group`, and `/etc/shadow` files. By default, this cron will save these files with a `.new` extension. You will have to edit the cron script to remove the `.new` extension, but you must make sure that it is properly generating your files or your server could be unusable.

The following command will blow away any existing root crontab:

    # crontab cronjobs/crontab.in

Now edit the paths to the cron scripts by setting the value of `GFORGE` and `PHP` variables:

    # crontab -e

Uncomment entries for `cronjobs/cvs-cron/usergroup.php`, `cronjobs/mail/mailing_lists_create.php`, and `cronjobs/mail/mailaliases.php` but not before understanding the consequences.

### Verifying the Installation

To verify if everything was installed correctly, use the browser and connect to FusionForge. You should see the FusionForge homepage. You will need to either disable CVS and SVN plugins in some way, or configure them before making the first test.

If you get an `Error: Could Not Connect to Database`, check if you have followed all installation instructions for the database. Also, you can experiment with making the settings in `pg_hba.conf` a bit more trusting - for example, change the last work of the second line from `md5` to `trust`.

### Creating the Admin User

Site admins are anyone who is an admin of `group_id`=1.

1. Connect to FusionForge and register a new account.

2. Insert a valid email address; this will be used for the account confirmation.

3. Open your e-mail client, wait for the email from FusionForge site and follow the link that appears on the message.

4. Verify in Account Maintenance the user id of the user registered.

   Usually this is 102, but you can verify this by running the following SQL query via the PostgreSQL `psql` utility:

       $ psql -U gforge -W -h localhost gforge
       gforge=> SELECT user_id FROM users WHERE user_name='YOUR USER NAME';

5. Now set up the newly added user to be a FusionForge administrator:

       gforge=> INSERT INTO user_group (user_id,group_id,admin_flags)
       gforge-> VALUES (102,1,'A');

One of the first string as FusionForge administrator is to initialize once the reporting tables from Reporting tab.

Once you have set up this user as an administrator, you can use FusionForge web interface to add more administrators.

### Customizing Front Page

If you want to customize front page, you'll have to provide new `index_std.php`:

1. Create `/etc/gforge/custom` directory.

2. Set `$sys_custom_path` configuration variable to `/etc/gforge/custom`.

3. Copy `/usr/share/gforge/www/index_std.php` to `/etc/gforge/custom/index_std.php` and edit it as you like.

### Optional Features

#### Project webs

Each project can have its own virtual host `projectname.projects.gforge.company.com`. Location of project files is configured with `$groupdir_prefix` variable in FusionForge configuration file. Each project has directory with project's name and contains `htdocs` subdirectory where Web files are placed. Project directories are created by `cronjobs/cvs-cron/usergroup.php`.

##### DNS Server Configuration (BIND)

Project virtual hosts require new DNS zone. Making this new zone is similar to making DNS zone for FusionForge itself.

1. Declare new zone in `gforge.company.com` zone:

       projects        IN      NS      ns.projects.gforge.company.com

   If DNS server doesn't serve the new `projects.gforge.company.com` zone, add the following line too:

       ns.projects     IN      A       1.2.3.4

   Don't forget to change serial number of `gforge.company.com` zone!

2. Create new zone file with following content:

       $TTL    2d
       @       IN      SOA     projects.gforge.company.com. hostmaster.gforge.company.com. (
                                     1         ; Serial
                                172800         ; Refresh
                                   900         ; Update retry
                               2419200         ; Expire
                                  3600 )       ; Negative Cache TTL
       ;
       @               IN      NS      ns.projects.gforge.company.com.
       @               IN      A       1.2.3.4
       ns              IN      A       1.2.3.4

       *               IN      A       1.2.3.4

3. The new zone must be added in main BIND configuration file:

       zone "projects.gforge.company.com" {
               type master;
               file "/dist-specific/path/to/zone-file";
       };

4. Reload BIND and test if all works:

       $ host test.projects.gforge.company.com
       test.projects.gforge.company.com has address 1.2.3.4

##### Web Server Configuration (Apache)

Module `vhost_alias` should be enabled and the following directives should be added to `httpd.conf` (if `/var/www/homedirs/groups` is what you have chosen in `$groupdir_prefix`):

If you want to be FHS-compliant, you may use `/var/local/gforge/log` and `/var/local/gforge/homedirs`.

    #
    # WARNING - security is degraded by having this
    # on the same machine as the primary FusionForge
    #
    NameVirtualHost 1.2.3.4
    <VirtualHost 1.2.3.4>
      ServerName        projects.gforge.company.com
      ServerAlias       *.projects.gforge.company.com
      ServerAdmin       webmaster@gforge.company.com
      UseCanonicalName  Off

    # You may want to add these files to logrotate, or just use cronolog as shown below
      CustomLog "/var/log/gforge/projects/access.log" combined
      ErrorLog  "/var/log/gforge/projects/error.log"

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

      DocumentRoot        /var/www/homedirs/groups
      VirtualDocumentRoot /var/www/homedirs/groups/%1/htdocs
      <Directory /var/www/homedirs/groups>
        Options Indexes
    #
    # WARNING - turning on php will allow any user
    # to upload a php file to your server, and include
    # the gforge local.inc file and get your password to
    # connect to the database and have total control.
    #
        php_flag engine off
        AllowOverride None
        Order allow,deny
        Allow from all
      </Directory>
      DirectoryIndex index.html index.htm
    </VirtualHost>

`cronjobs/cvs-cron/usergroup.php` copies from `cronjobs/cvs-cron/default_page.php` to `/var/www/homedirs/groups/projectname/htdocs/index.php` but the above configuration disables PHP.

#### Full Text Indexing

If you want to enable full text indexing, follow these steps:

- Find `tsearch2.sql` in your distribution of PostgreSQL and run it:

      # su - postgres
      $ psql -f /path/to/tsearch2.sql gforge

  Since `gforge` PostgreSQL user is not superuser, access to some Tsearch2 tables should be additionally granted:

      # su - postgres
      $ psql gforge
      gforge=# GRANT SELECT ON pg_ts_dict TO gforge;
      gforge=# GRANT SELECT ON pg_ts_parser TO gforge;
      gforge=# GRANT SELECT ON pg_ts_cfg TO gforge;
      gforge=# GRANT SELECT ON pg_ts_cfgmap TO gforge;

- Import data definitions:

      $ cd /var/www/gforge/db
      $ psql -U gforge -W -h localhost -f FTI.sql gforge
      $ psql -U gforge -W -h localhost -f FTI-20050315.sql gforge
      $ psql -U gforge -W -h localhost -f FTI-20050401.sql gforge
      $ psql -U gforge -W -h localhost -f FTI-20050530.sql gforge

- Enable Full Text Indexing by setting `$sys_use_fti` in FusionForge Configuration File `local.inc`.

#### JPGraph (Gantt Charting and Graphing Support)

PHP must be compiled with `--with-gd`, or appropriate package must be installed. Extra fonts for JPGraph are not necessary. Be sure your `/etc/gforge/local.inc` file contains the proper path to the `jpgraph/src/` directory.

Manual installation can be done like this:

    # tar -xzf jpgraph-1.19.tar.gz
    # mkdir /var/www/jpgraph
    # cp -R jpgraph-1.19/src/* /var/www/jpgraph

If you want FHS-compliance, `/usr/local/share/jpgraph`

When you get your preferred version of JPGraph installed, you will have to edit one setting in `jpgraph.php` (or `jpg-config.php`, depending on JPGraph version):

    DEFINE("USE_CACHE", false);

Be careful with JPGraph license: versions > 1.5.2 are not free (as in free speech). You must check license before use.

#### Perl

If you want to use some of the Perl scripts that access the database, you'll need the `DBI` and `DBD::Pg` Perl modules. On Red Hat systems (and variants), you can get them by installing the `libdbi` and `libdbd-pgsql` packages. On Debian systems (and variants), the packages are called `libdbi-perl` and `libdbd-pg-perl`.

You'll also need to install `utils/include.pl` to `/usr/share/gforge/lib/`.

#### Peer Ratings

Add yourself, and any others you wish, to the Peer Ratings project, which should be at `/projects/peerrating/` on the website. Make yourself an admininistrator of the project, and then proceed to rate other users on the website.

Members of the Peer Ratings project, who are administrator of the project, become the first trusted users. This is the only way to prime the pump for the peer ratings system.

## Plugins

Since GForge 4.0, plugins are necessary as source code management is now provided by plugins (SCM* plugins).

For each plugin, you can find an `INSTALL` file in the plugin tarball.

### CVS

#### Overview

CVS is now managed via the scmcvs plugin which is included in the `plugins/` directory in the tarball downloaded from gforge.org. Most of the files in scmcvs are intended for auto-installation on Debian systems and do not apply to the majority of users. The scmcvs plugin is activated by default in the `gforge.sql` database and all that you have to do is copy the `plugins/scmcvs/etc/*` directories to `/etc/gforge` directory and possibly modify the files slightly.

#### Cronjobs

Cronjobs for CVS are included in `cronjobs/crontab.in`, but are commented out by default for your security. The CVS cronjobs are in `/var/www/gforge/cronjobs/cvs-cron` and consist of:

- `usergroup.php` creates user and groups in `/etc/passwd`, `/etc/shadow`, and `/etc/group`.

- `cvs.php` creates repositories.

- `ssh_create.php` copies SSH keys to user directories.

- `history_parse.php` collects statistics.

There are other cronjobs that can be activated too:

- `plugins/scmcvs/cronjobs/tarballs.php` creates tarballs

- `plugins/scmcvs/bin/snapshots.sh` creates tarballs. `CVSROOT` and `SCMSNAPSHOTSDIR` variables are hard-coded in the script, so you'll have to edit the script if necessary.

Make sure these files are executed as root, and have proper execution bits set. Each of these cronjobs has configuration parameters which you may have to edit manually for your specific system. Here is a list of CVS cronjobs:

If you are using CVS 1.12, replace `syncmail` with updated version.

    # cd /var/www/gforge
    # cp plugins/scmcvs/bin/syncmail-cvs-1.12 cronjobs/cvs-cron/syncmail

Replace `%1{sVv}` in `/var/www/gforge/cronjobs/cvs-cron/cvs.php` with `%p %{sVv}`. Search for `LockDir=` in `cronjobs/cvs-cron/cvscreate.sh` and add the following line after it:

    echo "UseNewInfoFmtStrings=yes" >> $repositorypath/CVSROOT/config

#### Installation

This guide doesn't cover chrooted CVS repositories which are always recommended.

1. Create default location for CVS repositories (`$cvsdir_prefix` in FusionForge configuration file):

       # mkdir /cvsroot

2. Optional: Set up basic index.php file for CVS virtual host if desired. This guide has not further instructions on enabling CVS virtual host.

       # mkdir /var/www/cvs
       # cp /var/www/gforge/cronjobs/cvs-cron/www/* /var/www/cvs

3. Copy the scmcvs plugin config to `/etc/gforge`:

       # cp -R /var/www/gforge/plugins/scmcvs/etc/* /etc/gforge

4. Make sure the cvs crons are executable:

       # cd /var/www/gforge/cronjobs/cvs-cron/
       # chmod 755 *.php *.sh

5. Copy CVS restricted shell:

       # cp /var/www/gforge/cronjobs/cvs-cron/cvssh.pl /bin

6. Edit FusionForge Config File `/etc/gforge/local.inc` and change `$sys_path_to_scmweb` to be `/var/www/gforge/plugins/scmcvs/cgi-bin`.

7. You may have to edit `/etc/gforge/plugins/scmcvs/cvsweb.conf` to change the cvsroot location:

       'gforge'  => ['FusionForge-CVS', '/cvsroot/'],

8. Install the following non-core Perl modules:

   - IPC::Run

   - URI::Escape

9. You may want to user CVS pserver. First, assure that cvspserver service is defined in `/etc/services`. It will look like this:

       cvspserver      2401/tcp
       cvspserver      2401/udp

   Add entry for pserver in `/etc/inetd.conf`:

   `cvspserver stream tcp nowait root /var/www/gforge/plugins/scmcvs/bin/cvs-pserver cvs-pserver`

   Make sure that the wrapper script is executable:

       # chmod +x /var/www/gforge/plugins/scmcvs/bin/cvs-pserver

   The used wrapper script `/var/www/gforge/plugins/scmcvs/bin/cvs-pserver` assumes that CVS repositories are in chroot environment and you may want to edit the script and change `CHROOTDIR` and `CVSROOT` variables.

   CVS pserver has long history of vulnerabilities and its use is highly discouraged.

### CVSTracker

#### Overview

The cvstracker plugin allows for some integration between CVS commits and the bug tracker and task manager. So, for example, when you commit, you can reference bug and task IDs in your commit message and have the commit linked to the corresponding bug and task.

See the `plugins/cvstracker/README` file for details. This plugin is enabled by default in the `gforge.sql` database file. As with the other plugins, you may manually place the config files in `/etc/gforge/plugins/cvstracker/` and uncomment the cronjob in `crontab.in`.

You will also have to copy the `newcommit.php` file to your gforge `www/plugins/cvstracker/` dir

#### Installation

    # cd /var/www/gforge/plugins/cvstracker/
    # cp -R etc/plugins/cvstracker/ /etc/gforge/plugins/

Edit `/etc/gforge/plugins/cvstracker/config.php` and change parameters.

Uncomment `update_loginfo.php` in crontab.

CVS Tracker is not enabled by default for project. You'll have to manually enable it.

### SVN

#### Overview

SVN is also managed via plugin. The scmsvn plugin is included and activated by default in FusionForge. As with scmcvs, you have to move the `scmcvs/etc/plugins/*` files to `/etc/gforge/plugins/*` and may have to make minor modifications for your specific setup.

There are two ways to manage SVN. One is to have SVN over DAV and the other is to have SVN over SSH just as you do with CVS. If you choose to use DAV, you will need the `mod_auth_gforge` library compiled and installed in your apache and the appropriate virtual host settings in your `httpd.conf`. `mod_auth_gforge` is available from gforge.org. The cronjobs to manage SVN are in `cronjobs/dav-svn/` and so are sample `httpd.conf` virtual host settings. Each of these cronjobs has configuration parameters which you may have to edit manually for your specific system.

Configuring svnserv for svn-over-ssh:

#### Installation

Instructions here are far from complete.

    #Create default location for SVN repositories
    mkdir /svnroot

    # Optional - Set up some basic files for SVN-over-DAV only
    mkdir /var/www/svn
    cp /var/www/gforge/cronjobs/dav-svn/www/* /var/www/svn/

    #copy the scmsvn config files to /etc/gforge/
    cp -R gforge/plugins/scmsvn/etc/plugins/scmsvn/ /etc/gforge/plugins/

## Upgrading Existing Install

You will upgrade your database from a prior version by applying each database schema change, in order, and applying it only once. Only apply the schema changes in the `db/` folder that are dated after your existing installation.

There may also be migration scripts that have to be run. In the `db/` folder, look for php scripts and run them.

You have to apply database schema changes and to run migration scripts in the right order.

## Most Common Problems

Q: I get a blank page when I visit http://gforge.company.com/

A: Most often you are missing the php-pgsql library that lets PHP talk to the postgres database. Find a php-pgsql RPM or recompile php to have pgql support.

If you're sure you have php-pgsql support, you can edit common/include/database.php and remove the @ symbol from this line:

    $conn = @pg_connect(

So that it looks like:

    $conn = pg_connect(

This will let debug output dump to the screen and may let you find the problem. Search the forums for more solutions.

Q: Error Occurred In the Logger or other database permission problems

A: As stated in the installation instructions, the database must be created, owned, and accessed by the gforge user. This user is the only one who will have total acess to all the tables. Any other user would have to be specifically granted permissions with the GRANT commands in postgres.

Q: Reporting or time tracking doesn't work

A: Go to the reporting tab and scroll down so you can choose Initialize/Rebuild Reporting Tables

You may also be missing GD support or be missing JPGraph or have it installed improperly. The `jpgraph/src/` directory should be specified accurately in your `local.inc` file, and you should include a `/` at the end of the path specified. In addition, you should modify `jpgraph.php` to set `USE_CACHE=false`.

Q: How do I upgrade my database?

A: As stated above, you must apply the changes that are listed in date order in the `db/` directory to your database. Only the changes that are not already in your old `db/` directory should be applied, and they should be applied and checked in order.

Q: When I click on /projects/ or /users/ links, I get the source code instead of the page I expected.

A: As shown in the example `httpd.conf` files above, you may have to switch to using the `<Files>` or `<Location>` directives depending on your server version.

Q: How do I backup FusionForge?

A: The only proper way to backup the gforge database is with `pg_dump`. Any attempt to backup the filesystem while pgsql is running will result in a useless and corrupt backup. You can backup CVS trees using `tar` as long as they are not actively and heavily used during the backup. Mailman and the FRS uploads dir can also be backed up with `tar`.

Q: Any time i enter an apostrophe in a text box, i get a parse error

A: As stated in the instructions above, you should have `magic_quotes_gpc=Off` in your `php.ini` file.

Q: Large uploads into FRS or the doc manager fail.

A: Apache and the `php.ini` file need to have upload limits and possibly memory limits increased.

Q: When I click on `/projects/` or `/users/` links, I get a `Page Not Found` error instead of the page I expected.

A: Switch to/from the <Files projects> from/to the <Location /projects> directives in your `httpd.conf`. (Q&A provided by David Morsberger)