Manual:Installing MediaWiki on SourceForge.net

&lt; Running MediaWiki

This page will give you information about installing MediaWiki on a SourceForge.net webserver.

An automatic procedure for installing MediaWiki on a SourceForge.net webserver is described in MediaWiki Installation on SourceForge and provided by a free tool called mediawiki-sf. How ever there are some problems with it and in some cases following the procedure described here may be easier

For the sake of simplicity, we will assume that :
 * your SF.net username is johndoe
 * your project is called apollo

Hence, the paths will be :
 * your personal folder on SF.net is /home/users/j/jo/johndoe,
 * your project web root is /home/groups/a/ap/apollo/htdocs,
 * the web site is at  http://apollo.sourceforge.net/ .

Security and privacy
'''By default, SourceForge's project web servers use an insecure configuration which allows any other registered developer of any registered project to read your configuration files (including database password) and session data, and to write data into any file or directory you've made writable by the web server. Consider the security and privacy implications before installing a web application such as MediaWiki into your project space.'''

Prerequisites

 * 1) You must have group shell access for your project (granted by a project administrator),
 * 2) The MySQL database must have already been created on SF.net by a project administrator,
 * 3) You must have the password to the MySQL database.
 * 4) The dbname and username are set to your project's name with any hyphens removed.

The MySQL database is not created by default. A project administrator must request it in the 'Admin' section of your project, and it can take up to 4 hours for SF to process the creation request.

Updates on database creation procedures on SF.net (as of 12/23/2005).
 * A project admin can automatically set up the MySQL accounts through the Admin>Shell/DB/Web interface on SF.net page. The three accounts (read, read/write, and admin) will be created within minutes.
 * Once accounts are active, you can use PHPMyAdmin web interface to create the database for your MediaWiki installation. When creating the database make sure not to use UTF8 collation [encoding], because that will prevent MediaWiki from properly installing (as of version 1.5.4) Choose latin1 encoding instead. (You can see more detailed description of this problem at Manual:Newcomers guide to installing on Windows .)

Installation

 * Download MediaWiki 1.6.10 (1.7+ requires PHP 5 and SourceForge uses PHP 4). You cannot do this from the SourceForge shell.
 * Extract the package.
 * Edit the file mediawiki-1.6.10/config/index.php
 * Comment out the following section as below (just add the /* and */):
 * Upload the mediawiki directory content to your project's htdocs or a subfolder (for instance /home/groups/a/ap/apollo/htdocs/wiki</tt>), via FTP or scp
 * Go to http://apollo.sourceforge.net/wiki/config/index.php</tt> and configure mediawiki.
 * If you're successfull, it should say the configuration can't be written and will display it. Copy and paste it into /home/groups/a/ap/apollo/htdocs/wiki/LocalSettings.php</tt> and then delete the config</tt> directory
 * Follow the instructions below on Sessions
 * You should follow the instructions on Changing the Logo

Database Infomation

 * SourceForge specifics the database setup : see the Guide to MySQL Database Services on SF.net support pages
 * Database host: mysql4-a.sourceforge.net (the 'a' should be replaced with the first letter of your project)
 * Database name: a123456_mediawiki (or any other name you used to create the database. 123456 should be replaced with the project group-id)
 * Database user: a123456admin
 * Database password: specified when the database creation was requested

Problems
Due to the way sourceforge is run there will be some problems with you wiki run on to find out what they are and how to fix them.

Sessions
PHP sessions needs special cares on SF.net servers as SF.net hosts a server farm and not a single server. The required actions are the following (replace PROJECT_UNIX_NAME</tt> with your project's UNIX name, as displayed on your project admin page).
 * 1) create a folder to store the sessions in /tmp/persistent. for instance, /tmp/persistent/PROJECT_UNIX_NAME/sessions</tt> (do not store this folder under the project directory, it's not writable by the web server)
 * 2) make sure this folder is writable (by typing chmod a+w /tmp/persistent/PROJECT_UNIX_NAME/sessions</tt> from a shell)
 * 3) tell MediaWiki to use this folder to store the sessions, by adding session_save_path("/tmp/persistent/PROJECT_UNIX_NAME/sessions/");</tt> at the beginning of LocalSettings.php</tt>.

Make sure that session_save_path is added right after: Also make sure that the set path has the begining and ending dir slashes present! Ex: /home/groups/s/sy/symofros/sessions/ and NOT home/groups/s/sy/symofros/sessions

Sending mail from MediaWiki
MediaWiki can send mail - users can allow other users to send them mail through a web form in the wiki, or MW can send users a new password, or a message to confirm that the email address they entered in their preferences is really theirs.

To do all that, it can use the PHP send function. But Sourceforge has had the ability to mail directly from the webserver disabled for a long time, due to abuse. This means that the "Mail me a new password" button won't actually send an email as the code stands.

The semi-supported form for sending emails is (from sourceforge docs):


 * 1) Write the email to a database table
 * 2) Create a user cronjob to get the mails from the database table and send them.

First, make sure you have a database in your MySQL for email handling, separate from the one used by MediaWiki. you may have a general utility database you will use for email and other stuff, but in any case, it's better to have it seperate from the one used by MediaWiki. i will assume the database' name is. now, create a new table in this database. i'll assume you named it. create the columns ID (as table key), recipient, subject, message, headers and processor. all of this can be done from the phpMyAdmin installation sourceforge provides every project. more on managing your database is available at the sourceforge documentation.

You can also run this SQL query on your database:

''COMMENT: When using SourceForge's PHP database manager, make sure that the 'id' field has AUTO_INCREMENT enabled, otherwise only the first email works, and next time you get an error message that something went wrong. I achieved this by clicking the EDIT link on the field, going to the EXTRA column, and selecting AUTO_INCREMENT.''

Next, you need a script to "send" the mail to the database. it is useful to have this as a seperate script, in case you have other web applications that need to send email. copy this code to a file named  somewhere above your htdocs folder, say /home/groups/a/ap/apollo/scripts/sfmailer (we'll have another script here, hence the sfmailer folder): Make sure the "<?php" is the first thing in the file, with no spaces or empty lines before it.

you should replace:
 * with your MySQL server. usually the  is replaced with the first letter of your project unix name.
 * XXXXX with your project number.  will be your read/write user for the MySQL.
 * YYYYY with the password for user.

Now, we have to modify MediaWiki to use the script. using a plain text editor (such as Notepad++ or WordPad): In addition, there's a problem in the file User.php, also in the /includes folder:
 * 1) open /includes/UserMailer.php of your wiki installation
 * 2) find   in function userMailer (line 133 in version 1.6.8)
 * 3) replace with (or comment out and add after it)
 * 1) open /includes/User.php</tt>
 * 2) find   in function sendMail (line 1731 in version 1.6.8)
 * 3) replace with   (i.e. change the single quote to double quote).

Now you have MediaWiki sending mail to your database instead of to the email network. to have the mail retrieved and sent to people, copy this to a new file. i'll assume the file db2mail.php, also in /home/groups/a/ap/apollo/scripts/sfmailer: Again, replace XXXXX with your project number, and YYYYY with the password for user, and the MySQL server name and database name.

This script will send 20 messages each time it's invoked, which should be enough for anything hosted on sourceforge. it's a good measure against spam bots and email autoreply loops.

edit your crontab file to run this script every hour (because sourceforge don't allow more frequent timings. see there), by adding this line to it: 5 * * * * php /home/groups/a/ap/apollo/scripts/sfmailer/db2mail.php (and replace /a/ap/apollo with your project's details)

This will send any email stored in the database every hour, 5 minutes after the hour. you are encoureged to replace the 5 with any random minute between 0 and 59, to spread the load on the sourceforge.net mail servers across the hour.

Each user is limited to 1000 sent emails per day. If you have multiple developers that have shell access, you can provide them a copy of the same script, adding 1000 sendable emails per day, as long as you stagger the cronjobs appropriately.

Enabling Image Uploads
To enable image uploads, the first step is to ensure that the  directory is writable. As with the  directory, this is done by creating a writeable directory in the  projectname directory, using something like: mkdir -p /tmp/persistent/apollo/images chmod o+rwx /tmp/persistent/apollo/images and then soft-linking it to images: cd /home/groups/a/ap/apollo/htdocs/wiki mv images images.old ln -s /tmp/persistent/apollo/images.

You then need to change a setting in LocalSettings.php to enable them.

If you still have difficulty, try checking the general article on Manual:Configuring file uploads.

Adding the SF.NET logo
Sourceforge.net requires that an SF.NET logo (pointing back to their homepage) is placed on every page. The easiest way to do this, maintaining it on every skin, is to modify includes/Skin.php</tt>. Around line number 973, there is. What you need to do is modify this function a bit, to look kind of like the following: (don't forget to change XXXXX to your group ID number!)

What this will do is place the two logos ("Powered by MediaWiki" and "Sourceforge.net") side-by-side whenever something calls $this->html('poweredby'), which will reflect on all of your skins, not just default monobook.