Manual:Running MediaWiki on Sourceforge.net
From MediaWiki.org
| Installation guides |
|---|
| on FreeBSD |
| on GNU/Linux |
| - ALT Linux |
| - Damnsmalllinux |
| - Debian |
| - Fedora Core |
| - Gentoo |
| - Mandrake |
| - Red Hat Enterprise Linux |
| - Slackware |
| - SuSE 9.3 |
| - Ubuntu |
| on Mac OS X |
| on NetWare |
| on Solaris |
| - on Solaris 10 |
| - on Solaris 9 |
| on Windows |
| - Windows XP |
| - Windows Vista |
| - Windows Server 2000 |
| - Windows Server 2003 |
| - Newcomers guide |
| - Streamlined Guide |
| - Simple Windows/Apache Guide |
| - on a stick |
| - on WOS Portable |
| - on Uniform Server |
| - on Sourceforge.net |
This page will give you information about installing MediaWiki on a SourceForge.net webserver.
Sourceforge made many changes in the context of their datacenter migration to Chicago.
See
So most of this page content is outdated and should be updated. It is now easier to install mediawiki on sourceforge. See the following page to see how to install a recent version of mediawiki : http://winhp.sourceforge.net/wiki/index.php/Running_MediaWiki_on_Sourceforge.net
The content of this link could be used as a start to update this installation guide.
Contents |
[edit] Introduction
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/.
[edit] 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.
[edit] Prerequisites
- You must have group shell access for your project (granted by a project administrator),
- The MySQL database must have already been created on SF.net by a project administrator,
- You must have the password to the MySQL database.
- 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 #MySQL setup.)
[edit] 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 */):
/*
if( !is_writable( "." ) ) {
dieout( "<h2>Can't write config file, aborting</h2>
<p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
writable by the web server. Once configuration is done you'll move the created
<tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
then remove the <tt>config</tt> subdirectory entirely.</p>
<p>To make the directory writable on a Unix/Linux system:</p>
<pre>
cd <i>/path/to/wiki</i>
chmod a+w config
</ pre>" );
}
*/
- Upload the mediawiki directory content to your project's htdocs or a subfolder (for instance /home/groups/a/ap/apollo/htdocs/wiki), via FTP or scp
- Go to http://apollo.sourceforge.net/wiki/config/index.php 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 and then delete the config directory
- Follow the instructions below on Sessions
- You should follow the instructions on Changing the Logo
[edit] 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
[edit] 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.
[edit] 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 with your project's UNIX name, as displayed on your project admin page).
- create a folder to store the sessions in /tmp/persistent. for instance, /tmp/persistent/PROJECT_UNIX_NAME/sessions (do not store this folder under the project directory, it's not writable by the web server)
- make sure this folder is writable (by typing chmod a+w /tmp/persistent/PROJECT_UNIX_NAME/sessions from a shell)
- tell MediaWiki to use this folder to store the sessions, by adding session_save_path("/tmp/persistent/PROJECT_UNIX_NAME/sessions/"); at the beginning of LocalSettings.php.
Make sure that session_save_path is added right after:
ini_set( "include_path", ".:$IP:$IP/includes:$IP/languages" );
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
[edit] Sending mail from MediaWiki
- The following instructions worked for me on this day. --67.172.156.234 21:15, 16 May 2008 (UTC)
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):
- Write the email to a database table
- 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 apollo. now, create a new table in this database. i'll assume you named it mailer. 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:
CREATE TABLE `mailer` ( `id` INT( 9 ) NOT NULL , `recipient` TINYTEXT NOT NULL , `subject` TINYTEXT NOT NULL , `message` TEXT NOT NULL , `headers` TEXT NOT NULL , `processor` TEXT NOT NULL , PRIMARY KEY ( `id` ) ) ENGINE = MYISAM ;
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 mailer.php somewhere above your htdocs folder, say /home/groups/a/ap/apollo/scripts/sfmailer (we'll have another script here, hence the sfmailer folder):
<?php function sf_mail($to = "" , $subject = "", $message = "", $headers = "") { $mail_link = mysql_connect('mysql4-a.sourceforge.net', 'aXXXXXrw', 'YYYYYY') or die('Could not connect: ' . mysql_error()); $to = addslashes($to); $subject = addslashes($subject); $message = addslashes($message); $headers = addslashes($headers); $query = "INSERT INTO hXXXXX_apollo.mailer(recipient, subject, message, headers) VALUES('$to', '$subject', '$message', '$headers')"; /* $result = */mysql_query($query, $mail_link) or die('Query failed: ' . mysql_error()); return true; } //EXAMPLE: sf_mail("johndoe@users.sf.net", "TEST FROM SFMAILER", "THIS IS A TEST", "CC: johndoe@myrealbox.com"); ?>
Make sure the "<?php" is the first thing in the file, with no spaces or empty lines before it.
you should replace:
mysql4-a.sourceforge.netwith your MySQL server. usually theais replaced with the first letter of your project unix name.- XXXXX with your project number.
aXXXXXrwwill be your read/write user for the MySQL. - YYYYY with the password for user
aXXXXXrw.
Now, we have to modify MediaWiki to use the script. using a plain text editor (such as Notepad++ or WordPad):
- open /includes/UserMailer.php of your wiki installation
- find
mail( $dest, wfQuotedPrintable( $subject ), $body, $headers );in function userMailer (line 133 in version 1.6.8) - replace with (or comment out and add after it)
include_once("/home/groups/a/ap/apollo/scripts/sfmailer/mailer.php"); sf_mail($dest, wfQuotedPrintable( $subject ), $body, $headers);
In addition, there's a problem in the file User.php, also in the /includes folder:
- open /includes/User.php
- find
require_once( 'UserMailer.php' );in function sendMail (line 1731 in version 1.6.8) - replace with
require_once( "UserMailer.php" );(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:
#!/usr/bin/php -q <?php $link = mysql_connect('mysql4-a', 'aXXXXXrw', 'YYYYY') or die('Could not connect: ' . mysql_error()); mysql_select_db('aXXXXX_apollo') or die('Could not select database'); $query = 'SELECT ID, recipient, subject, message, headers FROM mailer WHERE processor&1=0 limit 20'; $result = mysql_query($query) or die('Query failed: ' . mysql_error()); $total = 0; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { $line['ID'] = breakapart ($line['ID']); $line['subject'] = breakapart ($line['subject']); $line['recipient'] = breakapart ($line['recipient']); $line['headers'] = breakapart ($line['headers']); $line['headers'] .= "Message-DBID: ". $line['ID'] ."\n"; echo ("Processing item ". $line['ID'] ." to '". $line['recipient'] ."', Subject '". $line['subject'] ."'\n"); @mail($line['recipient'], $line['subject'], $line['message'], $line['headers']); $total++; } if ($total) { echo ("$total item(s) processed.\n"); $query = 'UPDATE mailer SET processor=processor|1 WHERE processor&1=0 limit 20'; $result = mysql_query($query) or die('Query failed: ' . mysql_error()); } function breakapart (&$string) { $string = str_replace ('\\\"', '"', $string); $string = str_replace ('\\\`', '`', $string); return $string; } ?>
Again, replace XXXXX with your project number, and YYYYY with the password for user aXXXXXrw, 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.
[edit] Enabling Image Uploads
To enable image uploads, the first step is to ensure that the images directory is writable. As with the sessions directory, this is done by creating a writeable directory in the /tmp/persistent/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.
$wgEnableUploads = true;
If you still have difficulty, try checking the general article on Manual:Configuring file uploads.
[edit] 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. Around line number 973, there is function getPoweredBy(). 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!)
function getPoweredBy() { global $wgStylePath; $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" ); $sf = '<a href="http://sourceforge.net"> <img src="http://sflogo.sourceforge.net/sflogo.php?group_id=XXXXX&type=1" width="88" height="31" border="0" alt="SourceForge.net Logo" /></a>'; $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>'.$sf; return $img; }
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.

