Talk:Sven/MediaWiki Installation on OS X - biodev3

From Organic Design wiki

Template:Merge


Backup of custom configuration <bash> tar -zcvf MWconfig.tar.gz AdminSettings.php LocalSettings.php extensions/ skins/common/images/biodev3.png skins/monobook/main.css images/ </bash>

Details

This script interactively fetches MediaWiki using wget and installs it into the appropriate ${htdocs} path. It then prompts you to configure MediaWiki at; <bash> http://127.0.0.1/${wikidir} </bash> When you have finished type y and it will alter the configuration file to enable image uploading and move it to the appropriate location. If a database already exists it will not create the tables, leaving the old database intact. The schema from MediaWiki 1.4.3 changed for newer releases 1.5.x. All that is required post installation is to copy any old images tree to the new wiki path. <bash> cp -R images /Library/Webserver/Documents/wiki/ </bash>

MediaWiki Installations

Multiple instances of MediaWiki can be run by installing the wiki into different directories under /Library/Webserver/Documents/, e.g.

  • wiki19
  • wiki16 (previous release)
  • wiki14 (older database release)

Then create a sybolic link to link to the wiki you want to access <bash> ln -s /Library/WebServer/Documents/wiki19/ wiki </bash> These wiki installations can have their own databases.

See also

As MediaWiki evolves so does the database schema. Generally addional tables are created as the versions increase.

An easy method of upgrading MediaWiki is to install a new fress version with a new database, then alter the LocalSettings.php file to point to an already existing database. Then from the shell command line execute the script update.php in the maintenance directory. <bash> php update.php </bash>

MYSQL:Backup

Mysql 4.x.x

<mysql>

mysqldump -u root -p --single-transaction -B wikidb > wikidb.sql # Backup
mysql -u root -p wikidb < wikidb.sql # Restore

</mysql>

  • Note: No syntax errors are allowed in the pipe redirect.

Mysql 5.x.x

If the database being restored already exists then the create table statements will fail unless there is a --add-drop-table switch in the mysqldump. Ideally we would like CREATE TABLE IF NOT EXISTS...

MediaWiki 1 .4

INSERT IGNORE INTO db VALUES ('%','wikidb-1.4','wikiuser','Y','Y','Y','Y','N','N','N','N','N','N','N','N');
INSERT IGNORE INTO db VALUES ('localhost','wikidb-1.4','wikiuser','Y','Y','Y','Y','N','N','N','N','N','N','N','N');
INSERT IGNORE INTO db VALUES ('localhost.localdomain','wikidb-1.4','wikiuser','Y','Y','Y','Y','N','N','N','N','N','N','N','N');

Caveat

When using restore on INSERT statements only where tables already exist, there are two ways to restore

  • mysql> source backup.sql #(interactively inside mysql itself)
  • mysql -u root -D wikidb < backup.sql #(bash call using a redirect)

If an error occurs in a redirect then nothing is inserted after the statement that causes the error (e.g. primary keys already exist), whereas interactively from the command line invalid INSERT's provide a warning only and valid statements are still restored. This is because the bash redirect is being used to stream the file line by line, exiting at the point of failure. Introduced into mysqldump in version 5.0.15 is --insert-ignore which allows dumps of INSERT IGNORE statements. In this case a command line redirect whould work if the dump was;

  • mysqldump -u root -p --single-transaction --no-create-info --insert-ignore wikidb > /tmp/backup.sql

Here, I want to move the wikidb directory in mysql to a temporary location (say /tmp directory) so the information is not perminantly lost then use mysql to reconstruct wikidb.

  • mysqldump -u root -p --single-transaction wikidb > /tmp/backup.sql creates tables which already exist
  • mysqldump -u root -p --single-transaction --no-create-info wikidb > /tmp/backup.sql
  • wikipath=`locate wikidb | grep wikidb$`
  • sudo mv $wikipath ${wikipath}-bak
  • cd /tmp
  • [Time to recreate MediWiki which will make the wikidb database]
  • mysql -u root -p -D wikidb < /tmp/backup.sql
  • # Check the directory sizes match between wikidb and wikidb-bak
  • sudo du $wikipath
  • sudo du $wikipath-bak
  • # Refresh the links using maintenance script
  • php refreshLinks.php