HOW TO SET UP A WIKI FARM ON OS X
Update
I've worked through the Wyss Institute to replace this homebuilt system with something that 1) can be set up and administered through a web interface using OpenID logins and 2) is open source and can be hosted in the cloud (e.g. through Amazon AWS) so it can be easily cloned and modified by others. The result of this effort can be found here: Open-Source Cloud-friendly Wikifarm
This page serves to document the setup and maintenance of a wiki farm server. Back in 2005, I used a mac mini to host about 50 wikis, and thought it might be useful to others to document what I did. If you have any questions or comments, feel free to let me know.
You might also like to check out my Copy & Paste Excel-to-Wiki Converter.
You might also like to check out my Copy & Paste Excel-to-Wiki Converter.
Starting Materials
- Mac running OS X
- Admin account on the server (sudo privileges)
- MySQL - http://dev.mysql.com/downloads/
- Mediawiki - http://www.mediawiki.org/wiki/Download
Initial Setup
Configure Apache
# LoadModule php4_module libexec/httpd/libphp4.so
# AddModule mod_php4.c
Enable web sharing
Configuring SSL
Install MySQL
Install MediaWiki
tar -xzvf mediawiki-1.5.7.tar.gz
mv mediawiki-1.5.7 /Library/WebServer/Documents
Link a new directory to install
cd /Library/WebServer/Documents
sudo ln -s mediawiki-1.5.7 mediawiki
% ls -l
lrwxr-xr-x 1 shawn admin 15 Mar 7 13:13 mediawiki -> mediawiki-1.5.7
drwxr-xr-x 31 www wheel 1054 Mar 7 13:04 mediawiki-1.5.7
- enable PHP by editing /etc/httpd/httpd.conf and uncommenting the following lines:
# LoadModule php4_module libexec/httpd/libphp4.so
# AddModule mod_php4.c
Enable web sharing
Configuring SSL
- This optional step allows us to password protect the wikis, and ensure that no passwords are sent as clear text when individuals log in.
- See http://developer.apple.com/internet/serverside/modssl.html
Install MySQL
- download MySQL e.g. from http://dev.mysql.com/downloads/mysql/5.0.html
- run installer
- also install included preference pane and startup item so the wiki server will come back up after a reboot (or power failure)
Install MediaWiki
- download from http://www.mediawiki.org/wiki/Download
tar -xzvf mediawiki-1.5.7.tar.gz
mv mediawiki-1.5.7 /Library/WebServer/Documents
Link a new directory to install
- We are going to make "mediawiki" a symlink to "mediawiki-1.5.7".
- All wikis we create will have their own directory, which will contain symlinks to the mediawiki symlink.
- The purpose of the extra layer of symlinks is to simplify the process of upgrading the mediawiki software across all wikis.
- When we need to upgrade, we simply extract a new mediawiki-x.y.z direectory, and replace the old symlink with one that links to the new directory, and then run a custom perl script to perform the maintenance/update.php and maintenance/rebuildall.php scripts for every LocalSettings.php.
cd /Library/WebServer/Documents
sudo ln -s mediawiki-1.5.7 mediawiki
- If things are set up properly, the document root directory should look like this:
% ls -l
lrwxr-xr-x 1 shawn admin 15 Mar 7 13:13 mediawiki -> mediawiki-1.5.7
drwxr-xr-x 31 www wheel 1054 Mar 7 13:04 mediawiki-1.5.7
Upgrading MediAWiki
- Download latest version of mediawiki. Visit mediawiki's download page to get the url of a mirror.
wget http://prdownloads.sourceforge.net/wikipedia/mediawiki-1.5.7.tar.gz?use_mirror=superb
tar -xzvf mediawiki-1.5.7.tar.gz
mv mediawiki-1.5.7 /Library/WebServer/Documents
- Remove old symlink to previous version and then add symlink to new directory
cd /Library/WebServer/Documents
rm mediawiki; ln -s mediawiki-1.5.7 mediawiki
- Fix any customization that was performed on the old version. In my case, I want a "View Source" page to show up when a non-logged-in user tries to edit a page. This hack was done by editing near line 158 of includes/EditPage.php.
Creation of a Blank Template Wiki
Create Directory and Symlinks
cd /Library/WebServer/Documents
mkdir 00
cd 00
ln -s ../mediawiki/COPYING
ln -s ../mediawiki/FAQ
ln -s ../mediawiki/HISTORY
ln -s ../mediawiki/INSTALL
ln -s ../mediawiki/README
ln -s ../mediawiki/RELEASE-NOTES
ln -s ../mediawiki/UPGRADE
ln -s ../mediawiki/docs
ln -s ../mediawiki/extensions
ln -s ../mediawiki/img_auth.php
ln -s ../mediawiki/includes
ln -s ../mediawiki/index.php
ln -s ../mediawiki/install-utils.inc
ln -s ../mediawiki/languages
ln -s ../mediawiki/maintenance
ln -s ../mediawiki/math
ln -s ../mediawiki/profileinfo.php
ln -s ../mediawiki/redirect.php
ln -s ../mediawiki/redirect.phtml
ln -s ../mediawiki/skins
ln -s ../mediawiki/tests
ln -s ../mediawiki/thumb.php
ln -s ../mediawiki/trackback.php
ln -s ../mediawiki/wiki.phtml
mkdir images
sudo chown www:wheel images
cp -R ../mediawiki-1.5.7/config .
chmod a+w config/
Run Wiki Configuration Script
Delete config directory
cd /Library/WebServer/Documents/00
rm -rf config/
Set up LocalSettings.php
cp LocalSettings.php LocalSettings.php.backup
pico LocalSettings.php
$IP = "/Library/WebServer/Documents/00";
$wgScriptPath = "/00";
# Clean URLs
$wgArticlePath = "/foo/$1";
#$wgArticlePath = "$wgScript?title=$1";
$wgEnableUploads = true;
$wgFileExtensions = array('tar', 'gz', 'png', 'gif', 'jpg');
# Disable Anonymous editing
$wgGroupPermissions['*']['edit'] = false;
# Hide IP from header for anonymous users
$wgShowIPinHeader = false;
# Disable new accounts -- uncomment this later if necessary
# $wgGroupPermissions['*']['createaccount'] = false;
[foo:/Library/WebServer/Documents] shawn% ls -l
total 232
drwxr-xr-x 29 shawn admin 986 Mar 5 13:56 00
lrwxr-xr-x 1 shawn admin 15 Mar 7 13:13 mediawiki -> mediawiki-1.5.7
drwxr-xr-x 31 www wheel 1054 Mar 7 13:04 mediawiki-1.5.7
[foo:WebServer/Documents/00] shawn% ls -l
total 272
lrwxr-xr-x 1 shawn admin 20 Mar 1 11:48 COPYING -> ../mediawiki/COPYING
lrwxr-xr-x 1 shawn admin 16 Mar 1 11:48 FAQ -> ../mediawiki/FAQ
lrwxr-xr-x 1 shawn admin 20 Mar 1 11:48 HISTORY -> ../mediawiki/HISTORY
lrwxr-xr-x 1 shawn admin 20 Mar 1 11:48 INSTALL -> ../mediawiki/INSTALL
-rwxrwxr-x 1 shawn admin 4210 Mar 5 13:59 LocalSettings.php
lrwxr-xr-x 1 shawn admin 19 Mar 1 11:48 README -> ../mediawiki/README
lrwxr-xr-x 1 shawn admin 26 Mar 1 11:48 RELEASE-NOTES -> ../mediawiki/RELEASE-NOTES
lrwxr-xr-x 1 shawn admin 20 Mar 1 11:48 UPGRADE -> ../mediawiki/UPGRADE
lrwxr-xr-x 1 shawn admin 19 Mar 1 11:48 config -> ../mediawiki/config
lrwxr-xr-x 1 shawn admin 17 Mar 1 11:48 docs -> ../mediawiki/docs
lrwxr-xr-x 1 shawn admin 23 Mar 1 11:48 extensions -> ../mediawiki/extensions
drwxrwx--- 25 www wheel 850 Jan 5 18:47 images
lrwxr-xr-x 1 shawn admin 25 Mar 1 11:48 img_auth.php -> ../mediawiki/img_auth.php
lrwxr-xr-x 1 shawn admin 21 Mar 1 11:48 includes -> ../mediawiki/includes
lrwxr-xr-x 1 shawn admin 22 Mar 1 11:48 index.php -> ../mediawiki/index.php
lrwxr-xr-x 1 shawn admin 30 Mar 1 11:48 install-utils.inc -> ../mediawiki/install-utils.inc
lrwxr-xr-x 1 shawn admin 22 Mar 1 11:48 languages -> ../mediawiki/languages
lrwxr-xr-x 1 shawn admin 24 Mar 1 11:48 maintenance -> ../mediawiki/maintenance
lrwxr-xr-x 1 shawn admin 17 Mar 1 11:48 math -> ../mediawiki/math
lrwxr-xr-x 1 shawn admin 28 Mar 1 11:48 profileinfo.php -> ../mediawiki/profileinfo.php
lrwxr-xr-x 1 shawn admin 25 Mar 1 11:48 redirect.php -> ../mediawiki/redirect.php
lrwxr-xr-x 1 shawn admin 27 Mar 1 11:48 redirect.phtml -> ../mediawiki/redirect.phtml
lrwxr-xr-x 1 shawn admin 18 Mar 1 11:48 skins -> ../mediawiki/skins
lrwxr-xr-x 1 shawn admin 18 Mar 1 11:48 tests -> ../mediawiki/tests
lrwxr-xr-x 1 shawn admin 22 Mar 1 11:48 thumb.php -> ../mediawiki/thumb.php
lrwxr-xr-x 1 shawn admin 26 Mar 1 11:48 trackback.php -> ../mediawiki/trackback.php
lrwxr-xr-x 1 shawn admin 23 Mar 1 11:48 wiki.phtml -> ../mediawiki/wiki.phtml
- In this example we're using directory 00.
cd /Library/WebServer/Documents
mkdir 00
cd 00
ln -s ../mediawiki/COPYING
ln -s ../mediawiki/FAQ
ln -s ../mediawiki/HISTORY
ln -s ../mediawiki/INSTALL
ln -s ../mediawiki/README
ln -s ../mediawiki/RELEASE-NOTES
ln -s ../mediawiki/UPGRADE
ln -s ../mediawiki/docs
ln -s ../mediawiki/extensions
ln -s ../mediawiki/img_auth.php
ln -s ../mediawiki/includes
ln -s ../mediawiki/index.php
ln -s ../mediawiki/install-utils.inc
ln -s ../mediawiki/languages
ln -s ../mediawiki/maintenance
ln -s ../mediawiki/math
ln -s ../mediawiki/profileinfo.php
ln -s ../mediawiki/redirect.php
ln -s ../mediawiki/redirect.phtml
ln -s ../mediawiki/skins
ln -s ../mediawiki/tests
ln -s ../mediawiki/thumb.php
ln -s ../mediawiki/trackback.php
ln -s ../mediawiki/wiki.phtml
mkdir images
sudo chown www:wheel images
cp -R ../mediawiki-1.5.7/config .
chmod a+w config/
Run Wiki Configuration Script
- Visit https://example.com/00/config/index.php and enter following
- Site name: Blank
- contact email: name@example.com
- WikiSysop: ********
- database name: wikidb00
- db password: ********
- superuser: root
- password: ************
- Submit
Delete config directory
cd /Library/WebServer/Documents/00
rm -rf config/
Set up LocalSettings.php
cp LocalSettings.php LocalSettings.php.backup
pico LocalSettings.php
- LocalSettings.php should have the following changes
$IP = "/Library/WebServer/Documents/00";
$wgScriptPath = "/00";
# Clean URLs
$wgArticlePath = "/foo/$1";
#$wgArticlePath = "$wgScript?title=$1";
$wgEnableUploads = true;
$wgFileExtensions = array('tar', 'gz', 'png', 'gif', 'jpg');
# Disable Anonymous editing
$wgGroupPermissions['*']['edit'] = false;
# Hide IP from header for anonymous users
$wgShowIPinHeader = false;
# Disable new accounts -- uncomment this later if necessary
# $wgGroupPermissions['*']['createaccount'] = false;
- If things are set up properly, the document root directory should include the following (in addition to other things):
[foo:/Library/WebServer/Documents] shawn% ls -l
total 232
drwxr-xr-x 29 shawn admin 986 Mar 5 13:56 00
lrwxr-xr-x 1 shawn admin 15 Mar 7 13:13 mediawiki -> mediawiki-1.5.7
drwxr-xr-x 31 www wheel 1054 Mar 7 13:04 mediawiki-1.5.7
- An individual wiki directory should look like the listing below.
- Note: LocalSettings.php is not a symlink, but an actual file since it contains settings unique to this wiki.
[foo:WebServer/Documents/00] shawn% ls -l
total 272
lrwxr-xr-x 1 shawn admin 20 Mar 1 11:48 COPYING -> ../mediawiki/COPYING
lrwxr-xr-x 1 shawn admin 16 Mar 1 11:48 FAQ -> ../mediawiki/FAQ
lrwxr-xr-x 1 shawn admin 20 Mar 1 11:48 HISTORY -> ../mediawiki/HISTORY
lrwxr-xr-x 1 shawn admin 20 Mar 1 11:48 INSTALL -> ../mediawiki/INSTALL
-rwxrwxr-x 1 shawn admin 4210 Mar 5 13:59 LocalSettings.php
lrwxr-xr-x 1 shawn admin 19 Mar 1 11:48 README -> ../mediawiki/README
lrwxr-xr-x 1 shawn admin 26 Mar 1 11:48 RELEASE-NOTES -> ../mediawiki/RELEASE-NOTES
lrwxr-xr-x 1 shawn admin 20 Mar 1 11:48 UPGRADE -> ../mediawiki/UPGRADE
lrwxr-xr-x 1 shawn admin 19 Mar 1 11:48 config -> ../mediawiki/config
lrwxr-xr-x 1 shawn admin 17 Mar 1 11:48 docs -> ../mediawiki/docs
lrwxr-xr-x 1 shawn admin 23 Mar 1 11:48 extensions -> ../mediawiki/extensions
drwxrwx--- 25 www wheel 850 Jan 5 18:47 images
lrwxr-xr-x 1 shawn admin 25 Mar 1 11:48 img_auth.php -> ../mediawiki/img_auth.php
lrwxr-xr-x 1 shawn admin 21 Mar 1 11:48 includes -> ../mediawiki/includes
lrwxr-xr-x 1 shawn admin 22 Mar 1 11:48 index.php -> ../mediawiki/index.php
lrwxr-xr-x 1 shawn admin 30 Mar 1 11:48 install-utils.inc -> ../mediawiki/install-utils.inc
lrwxr-xr-x 1 shawn admin 22 Mar 1 11:48 languages -> ../mediawiki/languages
lrwxr-xr-x 1 shawn admin 24 Mar 1 11:48 maintenance -> ../mediawiki/maintenance
lrwxr-xr-x 1 shawn admin 17 Mar 1 11:48 math -> ../mediawiki/math
lrwxr-xr-x 1 shawn admin 28 Mar 1 11:48 profileinfo.php -> ../mediawiki/profileinfo.php
lrwxr-xr-x 1 shawn admin 25 Mar 1 11:48 redirect.php -> ../mediawiki/redirect.php
lrwxr-xr-x 1 shawn admin 27 Mar 1 11:48 redirect.phtml -> ../mediawiki/redirect.phtml
lrwxr-xr-x 1 shawn admin 18 Mar 1 11:48 skins -> ../mediawiki/skins
lrwxr-xr-x 1 shawn admin 18 Mar 1 11:48 tests -> ../mediawiki/tests
lrwxr-xr-x 1 shawn admin 22 Mar 1 11:48 thumb.php -> ../mediawiki/thumb.php
lrwxr-xr-x 1 shawn admin 26 Mar 1 11:48 trackback.php -> ../mediawiki/trackback.php
lrwxr-xr-x 1 shawn admin 23 Mar 1 11:48 wiki.phtml -> ../mediawiki/wiki.phtml
Creating the Nth Wiki
- Once the template wiki is created and properly configured, we can create any number of cloned wikis
- I've written a shell script makewikis.sh to make new wikis
- before using this script, you need to run mysqldump on an new un-touched wiki database to create a template that we will clone
- the script handles all the directory & symlink modification, and outputs a sql file that you call from MySQL to populate the database of a new wiki
Password Protecting A Wiki
Create / Update .htgroup
pico /Library/WebServer/.htgroup
members: username
Create / Update .htpasswd
cd /Library/WebServer
sudo htpasswd .htpasswd username
Password:
New Password:
Re-type Password:
Update /etc/httpd/httpd.conf
<Directory "/Library/WebServer/Documents">
RewriteEngine on
RewriteRule ^foo/?(.*)$ /01/index.php?title=$1 [L,QSA]
AuthType Basic
AuthUserFile /Library/WebServer/.htpasswd
AuthGroupFile /Library/WebServer/.htgroup
</Directory>
<Directory "/Library/WebServer/Documents/00">
AuthName "Wiki Farm"
require group members
</Directory>
- .htgroup should be in a directory visible to the web server, but not in a directory that is served by the web server. I use /Library/WebServer.
- add new username to htgroup.
pico /Library/WebServer/.htgroup
members: username
Create / Update .htpasswd
- .htpasswd should be in a directory visible to the web server, but not in a directory that is served by the web server. I use /Library/WebServer.
cd /Library/WebServer
sudo htpasswd .htpasswd username
Password:
New Password:
Re-type Password:
Update /etc/httpd/httpd.conf
- Here we add the rewrite rule for nice URL formatting, as well as password protection
- In this example, "foo" is going to be in the nice url, while 01 is the directory of the wiki we created. These should obviously be changed according to the specific wiki you create.
<Directory "/Library/WebServer/Documents">
RewriteEngine on
RewriteRule ^foo/?(.*)$ /01/index.php?title=$1 [L,QSA]
AuthType Basic
AuthUserFile /Library/WebServer/.htpasswd
AuthGroupFile /Library/WebServer/.htgroup
</Directory>
<Directory "/Library/WebServer/Documents/00">
AuthName "Wiki Farm"
require group members
</Directory>