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.

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 Newcomers guide to installing on Windows .)

Installation - Method 1: The obvious way
/* if( !is_writable( "." ) ) { 	dieout( " Can't write config file, aborting 	 In order to configure the wiki you have to make the config subdirectory 	writable by the web server. Once configuration is done you'll move the created 	LocalSettings.php to the parent directory, and for added safety you can 	then remove the config subdirectory entirely.  	 To make the directory writable on a Unix/Linux system:  	cd /path/to/wiki 	chmod a+w config 	</ pre>" ); } */
 * Download mediawiki 1.6.8 (1.7.x requires PHP 5 and SourceForge uses PHP 4). You must download it locally, you can't do that from the SourceForge shell.
 * Uncompress the package
 * Edit the file mediawiki-1.6.8/config/index.php</tt>
 * Comment out the following section as below (just add the /*</tt> and */</tt>):
 * 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>
 * Follow the instructions below on Sessions
 * You may also want to follow the instructions on Changing the Logo or Alternative Logo-Change

The rest of the help file

 * 1) SourceForge specifics
 * 2) 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
 * 1) Committing the changes
 * 2) copy the LocalSettings.php</tt> to the web root folder,
 * 3) delete the config</tt> directory.

Installation - Method 2: The tricky version (follow this procedure!)
2005.12.19 MediaWiki-1.5.3: Here is what Earnie did:


 * 1) Perform the following in a Shell.

mkdir -p /tmp/persistent/myproject/wiki ln -s /tmp/persistent/myproject/wiki /home/groups/m/my/myproject/var mkdir /home/groups/m/my/myproject/opt cd /home/groups/m/my/myproject/opt tar -zxf /path/to/MediaWiki-1.5.3.tar.gz cd MediaWiki-1.5.3 mv config config.bak cd /home/groups/m/my/myproject/var/wiki for i in `find /home/groups/m/my/myproject/opt/MediaWiki-1.5.3 -maxdepth 1` do  ln -s $i `basename $i` done mkdir config chmod 777 config cp config.bak/index.php config/ cd /home/groups/m/my/myproject/htdocs ln -s ../var/wiki wiki point the browser to http://myproject.sf.net/wiki answer the GUI questions mv /home/groups/m/my/myproject/var/wiki/config/LocalSettings.php wiki/ cd /home/groups/m/my/myproject/var rm -f * rm -rf config mkdir sessions chmod 777 sessions


 * 1) follow the "Sessions" info below
 * 2) follow the "Logout Problems" info below
 * 3) follow the "Changing the logo" info below

2006.03.11 MediaWiki-1.5.7: There's something strange in the above script: var is linked to /tmp/persistent/myproject/wiki (an empty dir), an after, there's the command cd var/wiki.

You probably need to create the var directory and make a symlink in it named wiki. (NicoV)

2006.03.22: Also, if you are following NicoV's suggestion given above, then mv /home/groups/m/my/myproject/var/wiki/config/LocalSettings.php wiki/ cd /home/groups/m/my/myproject/var rm -f * rm -rf config should actually be mv /home/groups/m/my/myproject/var/wiki/config/LocalSettings.php wiki/ cd /home/groups/m/my/myproject/var/wiki rm -f * rm -rf config as the only file under /home/groups/m/my/myproject/var/ is a symbolic link 'wiki -> /tmp/persistent/myproject/wiki'

However, when I do these 4 steps and remove all the files under /home/groups/m/my/myproject/var/wiki MediaWiki doesn't work. But if I skip the above mentioned steps then everything works fine. Please correct me if I am wrong. Khader

Problems
Got this error:

Fatal error: Call to a member function on a non-object in /home/groups/X/XX/XXXXXX/htdocs/wiki/includes/ObjectCache.php on line 409

Don't know who submitted this problem, but I saw exactly this error message when moving a wiki from one server to another - problem was the MySQL account the wiki used hadn't been given rights to log in.

Try verifying the MySQL connection (e.g. try to log into MySQL with the username and password in LocalSettings.php) if you see this error. Jmi 13:05, 3 May 2006 (UTC)

Check the database server hostname/IP, port, database name, username, and table prefix. Check that the server is online and accepting connections. Check that the GRANTs on the database are correct. -- brion vibber (brion @ pobox.com) i got this at http://mail.wikipedia.org/pipermail/wikitech-l/2005-July/030656.html 65.96.127.125

Could not open "../maintenance/tables.sql"
If you get this error while creating tables, my guess is that it's because SF has also disabled file streams. Whatever they did, there's still a way around this:

The Error
Creating tables... using MySQL 3/4 table defs...

Warning: fopen(../maintenance/tables.sql): failed to open stream: No such file or directory in /home/groups/X/XX/XXXXXXX/htdocs/mediawiki-1.5.7/install-utils.inc on line 95 Could not open "../maintenance/tables.sql".

The Solution
Comment out these lines in config/index.php (around line 615 for me, with mediawiki-sf-0.2 already run on it):

if( $wgDBmysql5 ) { print " using MySQL 5 table defs..."; dbsource( "../maintenance/mysql5/tables.sql", $wgDatabase ); } else { print " using MySQL 3/4 table defs..."; dbsource( "../maintenance/tables.sql", $wgDatabase ); }                       dbsource( "../maintenance/interwiki.sql", $wgDatabase );

Then run this to do the initial DB work manually (remember to replace the pertinent information):

<pre style="overflow: auto;">cd /home/groups/X/XX/XXXXX/htdocs/wiki/maintenance cat tables.sql | mysql -u your_mysql_user -p --host=your_mysql_host --database=your_mysql_database cat interwiki.sql | mysql -u your_mysql_user -p --host=your_mysql_host --database=your_mysql_database

Then go back to the web install, refresh, and finish installation.

This has been tested on mediawiki-1.5.8.

A better Solution
This problem crops up on all my installations with 1and1 as my webhost, but I found the solution in another wiki here: http://osggooey.sourceforge.net/wiki/index.php?title=Tricky_mediawiki_on_SourceForge

The solution to this serious problem is quite simple. Go into the "config" directory under your wiki and then open the index.php with an editor, then replace all instances of "../maintenance", which used to point to the SQL scripts, to "/home/groups/<$PATH_TO_YOUR_PROJECT>/htdocs/mediawiki-1.5.7/maintenance". Please replace the "<$PATH_TO_YOUR_PROJECT>" to your real path.

The reason I found is that you cannot access the real directory by using a relative directory indicator at sourceforge, when you are in a symbol-linked directory.

Keep in mind that this also works with other webhosts as long as you use the proper directory in place of ../maintenance in the config/index.php script. You'll get an indication of the directory you need in the error message when the installation fails with the message: "Warning: fopen(../maintenance/tables.sql) etc etc "

Toastysoul 17:24, 1 May 2007 (UTC)

You don't have permission to access /wiki on this server.
2006.03.11 MediaWiki-1.5.7: If you have a .htaccess file in your htdocs directory, you need to authorize Apache to follow symbolic links (Options FollowSymLinks) (NicoV)

Using Latex Math Equations
2006.07.24 MediaWiki-1.6.8: It is unclear how to install the math support for Sourceforge wikis. I can't run the installation script from my Windoze box, so that doesn't help. When I try to compile texvc, gmake can't find ocaml. Should the math directories be put in /tmp/persistent/....? Should I have installed all the files in /tmp/persistent as some of the other edits suggest?

PHP Paths
For some reasons, you should put $IP = "/home/groups/a/ap/apollo/htdocs";</tt> at the beginning of LocalSettings.php</tt>. (It seems that version 1.4.0 does that by itself).

2005.12.19 MediaWiki-1.5.3: I did not have to add this. (Earnie)

2006.01.12 MediaWiki-1.5.5: confirmed: this is not necessary as MediaWiki already puts that line. (frm)

Disabled ini_set
2005.12.19 MediaWiki-1.5.3: This was not a problem for me. (Earnie)

2006.01.12 MediaWiki-1.5.5: this was not a problem for me, too. (frm)

2006.04.06 MediaWiki-1.5.7: For free.fr hoster, this was very helpful, else the update would have not worked ! (User:Iubito)

If the php-function ini_set has been disabled for security reasons you have to change some paths. The row-numbers are for version 1.5.1. In the file config/index.php: In the file includes/DefaultSettings.php: Then you can run the script index.php again. Don't take notice of the fatal error in includes/DefaultSettings.php. Just reload the page. After moving config/LocalSettings.php to the folder above you have to comment out the ini_set in LocalSettings.php:
 * 122: =>
 * 123: =>
 * 124: =>
 * 125: =>
 * 166: =>
 * 167: =>
 * 465: =>
 * 1284: =>
 * 27: =>
 * 8: =>
 * 12: =>

Update : For 1.5.2 version, and today sourceforge version (07 november 2005), it works better if you don't comment the ini_set lines (I don't know why, it is just an experimental observation).

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).
 * 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>.

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:

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  somewhere above your htdocs folder, say /home/groups/a/ap/apollo/scripts/sfmailer (we'll have another script here, hence the sfmailer folder): <pre style="overflow: auto;"> <?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:
 * 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): include_once("/home/groups/a/ap/apollo/scripts/sfmailer/mailer.php"); sf_mail($dest, wfQuotedPrintable( $subject ), $body, $headers); i don't know if this is a bug or what, but 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
 * 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: <pre style="overflow: auto;"> <?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');
 * 1) !/usr/bin/php -q

$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, 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.

Logout Problems
User request: <BR> ''On sourceforge I am having problems with users being logged out during an edit or viewing pages for that matter. I am also getting blank pages returned randomly. I have tried with different browsers, flushed the cache etc...'' <BR> ''The blank page problem popped up after I enabled sessions as sugessted above. But did not solve the logout problem at all.'' <BR> Problem update:' Hey I found the solution to my problem. Make sure that session_save_path is added right after: <BR> ini_set( "include_path", ".:$IP:$IP/includes:$IP/languages" ); Also make sure that the set path has the begining and ending dir slashes present!<BR> Ex: /home/groups/s/sy/symofros/sessions/ and NOT home/groups/s/sy/symofros/sessions <BR> <BR> Stupid mistake on my part but hope this helps out others.

Changing the 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!)

<pre style="overflow: auto;"> 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&amp;amp;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.

Changing the logo &mdash; an alternative
You can replace the rights section with the SourceForge logo without making any change to the code. $wgRightsUrl="http://sourceforge.net"; $wgRightsIcon="http://sf.net/sflogo.php?group_id=000000&amp;amp;type=1"; Making sure you replace 000000 with your projects ID. The drawback is it will mention "Content is available under. " unless you tell it otherwise.

Logo in wiki page content
http://sflogo.sourceforge.net/sflogo.php?group_id=000000&type=1&.jpg

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. $wgEnableUploads       = true;

If you still have difficulty, try checking the general article on Uploading files.