Admin/MirrorHowto
From OpenZaurus
This page describes how to set up a read-only mirror of the OpenZaurus wiki. Here is a list of Wiki Mirrors. Questions? Contact Bronson.
Contents |
Installation
Requirements
Your webserver needs:
- Apache 1.3 or higher
- PHP 4.1 or higher
- MySql 3.23 or higher
- Subversion (the executable is called 'svn')
You will also need the php command-line executable if you want to support full-text searches on your mirror. Run 'which php', 'locate bin/php', or 'php --version' to find out if it's installed on your system.
Nightly update are usually a few hundred kilobytes of network traffic. After each update, the mirror reloads all tables and regenerates the fulltext indexes. With our current 3MB database, this should take a matter of seconds. Even modest webservers will have no trouble mirroring this wiki.
Initial Install
- Set up your virtual host (i.e., ozwiki.u32.net). The wiki will go in the root directory (see Q&A if this is a problem).
- Create the the MySQL database for the application. Again, see Q&A below for what permissions are required.
- Grab the application using Subversion. Name the directory ozdocs anything you want. Point Apache's DocumentRoot to it.
svn co http://svn.berlios.de/svnroot/repos/openzaurus/htdocs ozdocs
- Ensure that PHP works by navigating to info.php in the topmost directory. http://ozwiki.u32.net/info.php
- Grab the database. Again, name the directory ozsql anything you want.
svn co http://svn.berlios.de/svnroot/repos/openzaurus/ozsql ozdump
- Load the data into your MySQL database.
mysql -h example.com -u user --password=bogus databse < ozdump/dump.sql
- Tell MediaWiki how to access the database.
cd ozdocs/wiki cp SitePath.php.example SitePath.php vi SitePath.php cp SiteSettings.php.example SiteSettings.php vi SiteSettings.php # fill in your own info
- Try it! Navigate to the index page. Your mirror should work just like the original.
Incremental Updates
Getting the site up wasn't too hard. Now we will set up the update-site script so that it can be updated at any time. Here's how:
- Configure update-site. It's a similar configuration to SiteSettings.php above.
cd ozsql cp config.example config vi config
- Ensure the data can be loaded.
./load-database
- Now try doing a full update. If you don't specify FORCE=1, the script will notice that the master site has not changed and wisely do nothing.
FORCE=1 ./update-site
Any time you want to update your site, just run the update-site script.
Automatic Updates
Now we need to set the incremental updates to run each night. If your system uses something like vixiecron, you can do this:
$ crontab -e
And enter the following:
SHELL=/bin/sh
MAILTO=user
MM NN * * * $HOME/ozdump/update-site
Where MM is a random minute, 00-59 and NN is a random hour between 1 and 4 (that's GMT, adjust to 18 and 21 if youre in the pacific time zone).
The master dumps its database during the wiki's time of least traffic, starting a little after midnight GMT (5:00 PM PST). Please set your crontab to pull updates at some random moment between 1:00 GMT (18:00 PST) and 4:00 GMT (21:00 PST).
Your site should now automatically pull all the changes from the master wiki and install them in its own database each night and (if you set MAILTO) email you the report.
Now add a link to your mirror on Wiki Mirrors. Thanks for helping to preserve this data.
Q&A
- What's the difference between "config" file and "SiteSettings.php"?
- There are two pieces of code at work on a mirror, the always-running MediaWiki application and the once-nightly database load scripts. SiteSettings.php is used by the application, config is used by the shell scripts.
- What permissions do I need to give my database users?
- The application requires SELECT, INSERT, UPDATE and DELETE. The load scripts require CREATE, DROP and INSERT. Most people just use a single user who has all these permissions to do both tasks.
- I can't create a new virtual server! I need to put the mirror in a subdirectory of my existing site.
- You can make this work by modifying LocalSettings.php and the .htaccess file. I haven't tried this yet; contact me for help.
- What if I already have tables that use the mw_ prefix?
- You can change the table prefix using sed as you load the dumpfile into the database. You will also have to specify the new prefix by putting $wgDBprefix='mypfx_'; in SiteSettings.php. I haven't tried this yet; contact me for help.
- I'm having trouble getting the cron reports sent by mail.
- First, make sure the job is installed correctly.
$ crontab -l
If it is, you may be using an older version of cron. Try one of these:- $HOME/ozdump/update-site 2>&1 | /usr/bin/mail user@example.com -s 'cron: wiki mirror updated'
- $HOME/ozdump/update-site 2>&1 | /usr/lib/sendmail user@example.com
- How about some more info on how this works?
- Admin/MirrorNotes contans some rough notes I jotted down while setting this up.

