< Running MediaWiki Template:Cleanup 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
- 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.)
Installation - Method 1: The obvious way
- 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 */):
<source lang="php">
/*
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 <i>/path/to/wiki</i>
chmod a+w config
</ pre>" );
}
*/
</source>
* Upload the mediawiki directory content to your project's htdocs or a subfolder (for instance <tt>/home/groups/a/ap/apollo/htdocs/wiki</tt>), via FTP or scp
* Go to <tt>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 <tt>/home/groups/a/ap/apollo/htdocs/wiki/LocalSettings.php</tt>
* Follow the instructions below on [[#Sessions|Sessions]]
* You may also want to follow the instructions on [[#Changing the logo|Changing the Logo]] or [[#Alternative Logo-Change|Alternative Logo-Change]]
===The rest of the help file===
#SourceForge specifics
## the database setup : see the [http://sourceforge.net/docman/display_doc.php?docid=4297&group_id=1#mysql 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
#Committing the changes
## copy the <tt>LocalSettings.php</tt> to the web root folder,
## delete the <tt>config</tt> directory.
== Installation - Method 2: The tricky version (follow this procedure!) ==
2005.12.19 MediaWiki-1.5.3: Here is what Earnie did:
# 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
# follow the "Sessions" info below
# follow the "Logout Problems" info below
# 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.<br />
You probably need to create the var directory and make a symlink in it named wiki.
2006.03.22: Also, if you are following [[m:User:NicoV|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 if this is wrong.
=== 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.
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 [[User:65.96.127.125|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, with mediawiki-sf-0.2 already run on it):
<source lang="php">
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 );
</source>
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 ( such as 1and1 )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) [function.fopen]: failed to open stream: No such file or directory in /homepages/xx/xxxx/htdocs/yourwiki/includes/Database.php on line 1959 Could not open "../maintenance/tables.sql" ". Just substitute ../ for "homepages/xx/xxxx/htdocs/yourwiki/"
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)
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"; at the beginning of LocalSettings.php. (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!
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:
- 122:
require_once( "includes/Defines.php" );
=>require_once( "../includes/Defines.php" ); - 123:
require_once( "includes/DefaultSettings.php" );
=>require_once( "../includes/DefaultSettings.php" ); - 124:
require_once( "includes/MagicWord.php" );
=>require_once( "../includes/MagicWord.php" ); - 125:
require_once( "includes/Namespace.php" );
=>require_once( "../includes/Namespace.php" ); - 166:
require_once( "install-utils.inc" );
=>require_once( "../install-utils.inc" ); - 167:
require_once( "maintenance/updaters.inc" );
=>require_once( "../maintenance/updaters.inc" ); - 465:
require_once( "maintenance/InitialiseMessages.inc" );
=>require_once( "../maintenance/InitialiseMessages.inc" ); - 1284:
require_once( "languages/Names.php" );
=>require_once( "../languages/Names.php" );
In the file includes/DefaultSettings.php:
- 27:
require_once( 'includes/SiteConfiguration.php' );
=>require_once( '../includes/SiteConfiguration.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:
- 8:
ini_set( "include_path", ".:$IP:$IP/includes:$IP/languages" );
=>#ini_set( "include_path", ".:$IP:$IP/includes:$IP/languages" ); - 12:
ini_set( 'memory_limit', '20M' );
=>#ini_set( 'memory_limit', '20M' );
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).
- 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.
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):
- 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:
<source lang="sql">
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 ;
</source> 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):
<source lang="php">
<?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"); ?> </source> 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)
<source lang="php"> include_once("/home/groups/a/ap/apollo/scripts/sfmailer/mailer.php"); sf_mail($dest, wfQuotedPrintable( $subject ), $body, $headers); </source> 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.
Logout Problems
User request:
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...
The blank page problem popped up after I enabled sessions as sugessted above. But did not solve the logout problem at all.
Problem update:'
Hey I found the solution to my problem.
Make sure that session_save_path is added right after:
<source lang="php">ini_set( "include_path", ".:$IP:$IP/includes:$IP/languages" );</source>
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
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. 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!)
<source lang="php"> 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;
} </source>
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 — an alternative
You can replace the rights section with the SourceForge logo without making any change to the code. <source lang="php"> $wgRightsUrl="http://sourceforge.net"; $wgRightsIcon="http://sf.net/sflogo.php?group_id=000000&type=1"; </source> 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://sourceforge.net/ 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 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. <source lang="php"> $wgEnableUploads = true; </source>
If you still have difficulty, try checking the general article on Uploading files.











![[Main Page]](/modules/mediawiki/images/mediawiki.png)


