SourceForge Installation Guide - Web services Configuration

[Résumé] [Copyright]

# SourceForge Installation Guide - Chapitre 2
Web services Configuration

## 2.1 Required software

In order to run all the web services, you will need the following software :

- Apache (1.3.9 or later) with SuEXEC enabled (it need to run on port 80 for http and 443 for https)

- PHP4 with MySQL support

- mod_ssl

- MySQL (3.23.x or later)

We assume that you've setup /root/.my.cnf to simplify our work :) (see the MySQL documentation for more details).

FYI, I run Apache 1.3.9, PHP4 4.0.2, mod_ssl 2.4.10 on a Debian GNU/Linux.

## 2.2 Configuring Apache

### 2.2.1 Access configuration

These modifications should be applied on your httpd.conf. Add a directory directive for SourceForge (all those directives are in `misc/apache.conf`)

    			<Directory SF_ROOT/www>
    			Options Indexes FollowSymlinks
    			AllowOverride All
    			order allow,deny
    			allow from all
    			php_admin_value include_path "SF_ROOT/www/include:."
    			</Directory>

For security reasons, we prevent people to read the htaccess files

    			<Files .htaccess>
    			order allow,deny
    			deny from all
    			</Files>

### 2.2.2 Host configuration

Note that depending of your distribution you might have to change the paths. If you cut and paste the following, verify that the DocumentRoot is NOT used anywhere in the Apache configuration files. For Debian 2.2, you must comment out the DocumentRoot Directive in /etc/apache/srm.conf

    		<IfModule mod_ssl.c>
    			Listen 80
    			Listen 443
    		</IfModule>

    		<IfModule mod_ssl.c>
    		AddType application/x-x509-ca-cert .crt
    		AddType application/x-pkcs7-crl    .crl
    		</IfModule>

    		<IfModule mod_ssl.c>
    		SSLPassPhraseDialog  builtin
    		SSLSessionCache         dbm:/var/run/ssl_scache
    		SSLSessionCacheTimeout  300
    		SSLMutex  file:/var/run/ssl_mutex
    		SSLRandomSeed startup builtin
    		SSLRandomSeed connect builtin
    		</IfModule>

    		# this directive is very important
    		DocumentRoot SF_ROOT/www
    		DirectoryIndex index.php index.html
    		NameVirtualHost 10.16.110.29

    		<VirtualHost DOMAIN_NAME>
    		ServerAdmin your_email_address
    		DocumentRoot SF_ROOT/www
    		</VirtualHost>

    		<VirtualHost cvs.DOMAIN_NAME>
    		DocumentRoot SF_ROOT/cvs
    		AddHandler cgi-script .cgi
    		# this may vary with your distribution
    		ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    		</VirtualHost>

    		# this is only interesting if you want Mailing Lists support
    		<VirtualHost lists.DOMAIN_NAME>
    		AddHandler cgi-script .cgi
    		#this may vary with your Linux distribution
    		ScriptAlias /mailman/ /usr/lib/mailman/cgi-bin/
    		</VirtualHost>

    		<VirtualHost DOMAIN_NAME:443>
    		DocumentRoot SF_ROOT/www

    		<IfModule mod_ssl.c>

    		SSLEngine on
    		SSLCertificateFile    /etc/apache/ssl.crt/server.crt
    		SSLCertificateKeyFile /etc/apache/ssl.key/server.key

    		<Files ~ "\.(cgi|shtml)$">
    		SSLOptions +StdEnvVars
    		</Files>

    		<Directory "/usr/lib/cgi-bin">
    		SSLOptions +StdEnvVars
    		</Directory>

    		SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown

    		</IfModule>
    		</VirtualHost>

## 2.3 MySQL Configuration

### 2.3.1 Create the database

As root, run in a shell

    		mysql -e "create database sourceforge"

### 2.3.2 Access Configuration

Pick a random password for the sourceforge user. The makepasswd tool is useful for that.

Run mysql on the mysql database.

    		# mysql mysql

    		mysql> GRANT ALL PRIVILEGES
          on sourceforge.*
          to sourceforge@localhost
          identified by 'password';

    		mysql> Flush Privileges;
    		mysql> quit

### 2.3.3 Fill the database

Run in a shell :

    		# cd SF_ROOT
    		# guide/fill_db.sh

## 2.4 Configure Sourceforge

### 2.4.1 Change the config file location

We need to change the location of local.inc from /etc/local.inc to SF_ROOT/etc/local.inc. In a shell run

    		# cd SF_ROOT
    		# guide/chlocal.pl SF_ROOT

All original files are saved with the .bak extension.

### 2.4.2 Changing the config file

Edit SF_ROOT/etc/local.inc:

- Set all $*_host variables EXCEPT for sys_download_host that you point to correct_hostname:81. You may add a dot at the end of the dns variables.

- $sys_default_domain = "domain_name"

- $sys_dbpasswd = "the password you chose before"

- $sf_root = SF_ROOT;

- $sys_name = "system_name"

"system_name" stands for the string returned by hostname -f. You will need to create a group which will moderate the news for the front page after the installation. You will have to set $sys_news_groupid to the number of this group.

## 2.5 Create the sourceforge admin user

### 2.5.1 Create the user

`Note: at this point, a basic mail server must be setup on your system.`

Point a browser to http://the_server_name/. Follow the link "New User via SSL", fill in the form (login could be 'admin'), validate. Wait for the confirmation email. Use the URL in it. Re-type login and password. You should be logged in.

### 2.5.2 Give him super-admin-root privileges

    	# mysql sourceforge
    	mysql> select user_id from user where user_name='admin';
    	[Should return 101 - Replace 'admin' by your login]
    	mysql> insert into user_group (user_id, group_id, admin_flags)
    						values (101, 1, 'A');
    	[Replace 101 by last result if need be]

You should also modify his unix uid because on most distributions the first 100 accounts are already taken, so I suggest you update it to 1001.

    	mysql> update user set unix_uid=1001 where user_id = 101;

## 2.6 Fileforge

This is a small utility which is called by the Apache server to move files from the incoming ftp directory to the project space.

Go to SF_ROOT/utils. In fileforge.c, modify at line 48 :

      char * src_dir   = "SF_ROOT/ftp/incoming/";
      char * dest_dir  = "SF_ROOT/download/";

The trailing slashes are mandatory. Compile it with gcc -O2 -o fileforge fileforge.c. Then copy fileforge to /usr/local/bin and run:

    	# cd /usr/local/bin
    	# chown root:(the group under which your Apache server runs) fileforge
    	# chmod 4750 fileforge

## 2.7 Improvements

### 2.7.1 Misc.

An example of how to add an administration menu to your SF page is given in the Online forum. Consult the following link:

    	http://sourceforge.net/forum/message.php?msg_id=46285&group_id=1

We suggest that you comment the line 45 in SF_ROOT/www/new/index.php. (you just have to add a // at the beginning of this line).

If you don't want that everybody sees the first survey, we suggest that you modify the where condition of line 116 in SF_ROOT/www/include/vote_function.php into

    	survey_id='$survey_id' and group_id=1

I advise you to create a cronjob that remove all files in cache every hour like

    	0 * * * * rm -f SF_ROOT/sfcache/*

[Résumé] [Copyright]

SourceForge Installation Guide