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

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

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 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 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):

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";</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!

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

Way #1
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>.

Way #2
After trying way #1, i found it to not work. so, instead, try using /home/users/y/yo/yourusername/sessions-mediawiki</tt> to store the sessions instead. it's also more secure. Works for me.. try it out. after this, sessions worked perfectly. with the same session_save_path("home/users/y/yo/yourusername/sessions-mediawiki");</tt> line ontop of the LocalSettings file.

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.

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: 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</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.

Changing the logo &mdash; an alternative
You can replace the rights section with the SourceForge logo without making any change to the code. 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.

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