SourceForgeServers

Summary: Install PmWiki in SourceForge.net's project web space.
Version: 1
Prerequisites: PmWiki 2.0beta31 or newer
Status: Outdated
Maintainer: Hagan Fox

This page is obsolete: As of 2011-02, Sourceforge allows write access again

Question

How can I run PmWiki in SourceForge.net's Project Web Environment?
How can I run PmWiki on a server where web content is served from a read-only filesystem?

Answer

The SourceForge project web space is mounted read-only, meaning any directory that may be served directly by the SourceForge.net servers is not writable by a web server application such as PmWiki. Applications that write files may do so, however, in a special area of the filesystem. The documentation says

Place the data in the /tmp/persistent directory, accessible from and shared between the project shell and web servers. Projects should create their own subdirectory in /tmp/persistent and make frequent backups of the data.

If you're willing to accept a small amount of risk (which you can mitigate by making backups), you can run PmWiki on the SourceForge.net servers.

Installation Steps

Here are some steps for configuring PmWiki on the SourceForge.net Servers.

Start by following the first three PmWiki installation steps.

Now open a shell on the SourceForge.net shell server.

If you haven't done so, prepare project's directory in /tmp/persistent/.

mkdir /tmp/persistent/projectname
 cd /tmp/persistent/projectname/
 chmod 755 .

Next, create a directory to hold your wiki directories.

mkdir pmwiki.d
chgrp projectname pmwiki.d
chmod 2777 pmwiki.d

Next, edit the local/config.php file. Create the file if it doesn't exist.

<?php if (!defined('PmWiki')) exit();
##  $WikiTitle is the name that appears in the browser's title bar.
$WikiTitle = 'Test Wiki';

## Writable place for session data
session_save_path('/tmp/persistent/projectname/pmwiki.d/sessions');

## Store wiki pages outside the document tree.
$WorkDir = '/tmp/persistent/projectname/pmwiki.d/wiki.d';
$WikiDir = new PageStore('/tmp/persistent/projectname/pmwiki.d/wiki.d/$FullName');

## Place uploads outside the document tree.
$UploadDir = '/tmp/persistent/projectname/pmwiki.d/uploads';
$EnableDirectDownload = 0;
$EnableUpload = 1;
$DefaultPasswords['upload']='$1$/PPoEleM$R1TrfXrbL.A9DFVxyR36I1';

(Create the $DefaultPasswords line by visiting the wiki with an ?action=crypt query string.)

Next, visit the wiki. PmWiki will create a writable wiki.d directory with the UID, GID, and permissions we need.

Now rename the directory that was created to sessions. This directory will hold session-tracking data.

 mv pmwiki.d/wiki.d pmwiki.d/sessions

If you want uploads in your wiki, visit the site again to create another wiki.d directory and rename this one to uploads.

 mv pmwiki.d/wiki.d pmwiki.d/uploads

Visit the site again to create the wiki.d directory that will hold your wiki pages.

Now that all of the directories are there, change the permissions of the pmwiki.d/ directory so it's no longer writable by the web server or other SF.net users.

 chmod 755 pmwiki.d/

Now you have three directories that are writable by your user and the server, but not other users on the system.

 ls -l pmwiki.d/

 drwxrwsr-x  2 nfsnobody projectname 4096 Mmm dd hh:mm sessions
 drwxrwsr-x  2 nfsnobody projectname 4096 Mmm dd hh:mm uploads
 drwxrwsr-x  2 nfsnobody projectname 4096 Mmm dd hh:mm wiki.d

That's it. Now you should be ready to continue with some Initial Setup Tasks.

Backing Up Your Data

This is a two-pronged approach to backing up.

  1. Create a tarball of your wiki data
  2. Move your wiki pages out of the temp space.

First create a place in your project's space to store the data. You need to create a wikilib2.d directory and put these lines in your config.php file:

## Add a custom page storage location for wiki pages.
$PageStorePath = "wikilib2.d/\$FullName";
$where = count($WikiLibDirs);
if ($where>1) $where--;
array_splice($WikiLibDirs, $where, 0,
  array(new PageStore($PageStorePath)));

Next, create a shell script to do the backup.

#!/bin/bash
# Backs up wiki data.

# Perform the backup
tar zcvf backup-`date +%Y%m%d`.tar.gz \
 /tmp/persistent/projectname/pmwiki.d/ \
 /home/groups/p/pr/projectname/htdocs/{wikilib.d,wikilib2.d}

# Move wiki pages out of the temp space.
mv -f /tmp/persistent/projectname/pmwiki.d/wiki.d/* \
 /home/groups/p/pr/projectname/htdocs/wikilib2.d

Notes

It has also been reported that you can use symlinks to directories you place in the /tmp/persistent/ directory.

Comments

Some elements of this recipe are dated now (January, 2010); SourceForge now provides a writable, automatically backed up directory (symlink) by default, in ..../$project/persistent. PmWiki is an excellent alternative to SourceForge's current "Hosted App" MediaWiki offering and its huge, unmovable banner ad.

Here's the basics from the config.php of my recent setup; just update $persistent and 'password':

<?php if (!defined('PmWiki')) exit();

##  $WikiTitle is the name that appears in the browser's title bar.
$WikiTitle = 'Test Project';

## Writable place for session data
$persistent='/home/groups/y/ya/yawni/persistent/pmwiki.d/';
session_save_path("$persistent/sessions");

## Store wiki pages outside the document tree.
$WorkDir = "$persistent/wiki.d";
$WikiDir = new PageStore("$persistent/wiki.d/\$FullName");

## Place uploads outside the document tree.
$UploadDir = "$persistent/uploads";
$EnableDirectDownload = 0;
$EnableUpload = 1;

# site-wide passwords
$DefaultPasswords['upload'] = crypt('password');

See Also

http://pmichaud.com/pipermail/pmwiki-users/2005-May/013385.html

Contributors

Hagan, using original information from Pm
Martin Krischik July 31, 2005, at 12:01 PM


Category:

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.