United Nations – World Food Programme OMIA - Development and Business Relations Branch

WIKI ENVIRONMENT SANDBOX & WIKIS Technical documentation – Installation & setup guide

REFERENCE AUTHOR FILE VERSION DATE Djibril Diallo, 0cccdda2dec01f4bee0d9ace31d5dba A 14 April 2009 Alessandro Bianchi 7.doc

CONTACTS NAME JOB TITLE / POSITION PHONE E-MAIL Djibril Diallo, IT Software Engineer +221 77.644.01.88 [email protected] Alessandro Bianchi [email protected] D O C U M E N T H I S T O R Y

VER. DATE AUTHOR REVIEWER DESCRIPTION 1 14 April 2009 Djibril Diallo n/a Document Creation 2 21 April 2009 Alessandro Bianchi How To: Copy a Wiki on a local computer 3 23 April 2009 Alessandro Bianchi How To: Create Wikis environment on Production Server

A P P R O V A L S

Author Approver Project Manager Djibril Diallo n/a Stefania Corsi

Alessandro Bianchi

OMIA – Development and Business Relation Branch 2 Wfp Wiki – Sandbox environment – Wikis Infrastructure TABLE OF CONTENTS

Introduction...... 4 1. Sandbox environment...... 5 1.1. Operating system and installed software...... 5 1.2. WfpWiki core code...... 6 1.3. Apache: virtual directory...... 7 1.4. MySql databases...... 8 2. Setting up new wiki...... 9 2.1. MySql database creation...... 9 2.2. Apache configuration...... 10 2.3. MediaWiki settings...... 10 3. How To: Copy a Media Wiki from the SandBox to Another Server...... 14 4. How To: Create the Wikis Environment on the Production Server...... 16 5. How To: Add a New Wiki to the Production Wikis Environment (the travel manual).....23 6. How To: Move the M & E Wiki to the new Wikis Infrastructure...... 26 7. How To: Move the Glossary Wiki to the new Wikis Infrastructure...... 28 8. How To: Backup a Wiki Database...... 31 9. How To: Create a dynamic backup procedure – TO DO...... 33

This document contains 38 pages.

OMIA – Development and Business Relation Branch 3 Wfp Wiki – Sandbox environment – Wikis Infrastructure Introduction

The purpose of the present document is to make a technical presentation of the WfpWiki’s Platform on the sandbox, and also the give clear guidelines and step-by-step on how to configure a new WfpWiki using already defined standards.

As decided during requirements and business analysis process, all future WfpWikis will use:

 Same core code: php scripts  Differents base configuration file (settings file): LocalSettings.php  Different MySql databases on the same server  Virtual directory configuration: prefixed on http://wiki.wfp.org/ web server

This is known as the project to have a consolidated wiki environment platform.

We currently have 3 WfpWikis deployed:

 PGM Wiki  Glossary Wiki  M&E Wiki

The PGM is configured as a virtual server and is not part of that consolidated envrionment.

The Glossary Wiki and the M&E Wiki are already consolidated on that environment; the same should be for all future WfpWikis.

The core code of all wikis is configured with one extension: the FCKeditor.

OMIA – Development and Business Relation Branch 4 Wfp Wiki – Sandbox environment – Wikis Infrastructure 1. Sandbox environment 1.1. Operating system and installed software

The sandbox is running on a PC with the following hardware configuration:

 Hardware: o CPU: Pentium 4 @ 3.00 GHz o RAM: 1024 Mbits  OS o Windows XP – Professional Edition (32 Bits) o Login info: hquser/test (/)  Network settings o Host Name: M51BuelincVM o IP Address: 10.11.33.246 o Subnet Mask: 255.255.248.0 o Default Gateway: 10.11.32.14 o DNS Servers 1: 10.11.32.7 o DNS Servers 2: 10.11.32.8

The main software installed on it is the WAMP Server that is a Windows package coming with Apache, MySql and Php.

 WAMP Server o Version: 2.0 o Install directory: C:\wamp\  Apache o Version: Apache/2.2.8 (Win32) o Configuration files: C:\wamp\bin\apache\apache2.2.8\conf\httpd.conf ; C:\wamp\alias\*.conf ; C:\wamp\vhosts\*.conf  MySql o Version: 5.0.51b-community-nt o Configuration file: C:\wamp\bin\mysql\mysql5.0.51b\my.ini o Data directory: C:\wamp\bin\mysql\mysql5.0.51b\data  Php o Version: PHP/5.2.6 o Configuration files: C:\wamp\bin\apache\apache2.2.8\bin\php.ini o Extension directory: C:/wamp/bin/php/php5.2.6/ext/

OMIA – Development and Business Relation Branch 5 Wfp Wiki – Sandbox environment – Wikis Infrastructure 1.2. WfpWiki core code

The sandbox is using MediaWiki version 1.13.3 as common code for WfpWikis. It has the extension FCKeditor installed for WYSIWYG editing purpose.

FCKeditor: Version fckeditor/mw-extension $Rev$ 2008

The core code reside in the following folder: C:\djib\wikis\

Other minor tweaks have been done:

 Disable the default create account ability  Readjust some group access rights for security reason

Code listing: Default permissions on core code for WfpWikis

$wgGroupPermissions['*']['read'] = true; $wgGroupPermissions['*']['edit'] = false; $wgGroupPermissions['*']['createaccount'] = false;

The Glossary Wiki and the M&E Wiki are already using that common code, each of them with its own configuration file, located in C:\djib\ :

 Glossary Wiki  LocalSettings_GWiki.php  M&E Wiki  LocalSettings_ME.php

A MediaWiki Configuration file (LocalSettings.php) is used as a wrapper to know which specifc configuration file to load according to the virtual directory requested.

The code of that settings file (LocalSettings.php) acting as a wrapper is the following:

OMIA – Development and Business Relation Branch 6 Wfp Wiki – Sandbox environment – Wikis Infrastructure Code listing: Settings for LocalSettings.php as a wrapper

// The requesting url $callingURL = strtolower($_SERVER['REQUEST_URI']);

/////////////////////////////////////////////////////////////// // // All WfpWiki configurations will go below this block // ///////////////////////////////////////////////////////////////

// M&E Toolkit Wiki if ( strpos( $callingURL, 'm_and_e') ) { require_once('LocalSettings_ME.php'); }

// Glossary Wiki else if ( strpos( $callingURL, 'glossarywiki') ) { require_once('LocalSettings_GWiki.php' ); }

/////////////////////////////////////////////////////////////// // // All WfpWiki configurations will go above this block // ///////////////////////////////////////////////////////////////

$wgGroupPermissions['*']['read'] = true; $wgGroupPermissions['*']['edit'] = false; $wgGroupPermissions['*']['createaccount'] = false;

else { header( "Location: http://10.11.33.246/wiki/" ); } ?>

NB:

Make sure that the name defined in specific configuration files (LocalSettings_GWiki.php, LocalSettings_ME.php, etc.), for the $wgSitename variable is the SAME as the one tested in the LocalSettings.php file against the variable $callingURL.

1.3. Apache: virtual directory

WfpWikis are configured as virtual directories and are self-explanatory:

OMIA – Development and Business Relation Branch 7 Wfp Wiki – Sandbox environment – Wikis Infrastructure Code listing: Example of virtual directory configuration for M&E Wiki (M_and_E.conf)

# file C:\wamp\alias\M_and_E.conf

Alias /M_and_E "C:/djib/wikis/"

Options Indexes FollowSymLinks MultiViews AllowOverride all Order Allow,Deny Allow from all

NB:

Make sure that the name of the virtual directory defined in the alias configuration file, located in C:\wamp\alias\, is the same as the ones defined in:

o LocalSettings_GWiki.php: Variable name $wgSitename o LocalSettings.php: Variable name $callingURL

1.4. MySql databases

Each WfpWiki is using its own database which is accessed with the parameters defined the specific setting files (i.e. LocalSettings_GWiki.php).

Code listing: Database configuration in specific setting file (LocalSettings_GWiki.php)

# File location: C:\djib\wikis\LocalSettings_GWiki.php

. . . ## Database settings $wgDBtype = "mysql"; $wgDBserver = "localhost"; $wgDBname = "glossarywiki"; $wgDBuser = "glossarywiki"; $wgDBpassword = "glossarywiki"; . . .

The database is created and initialized while setting up the new wiki. A detailed procedure is covered in the next chapter of this document.

OMIA – Development and Business Relation Branch 8 Wfp Wiki – Sandbox environment – Wikis Infrastructure 2. Setting up new wiki

This step-by-step will be done with the following assumption: the WfpWiki to be installed is called OneWiki.

2.1. MySql database creation

To create the database for the new WfpWiki named use the script template WfpWiki_DB.sql.

Put the right values for:

o the BD name: OneWiki, o the user name: OneWiki, o the password: OneWikiPasswd

Code listing: Script for creating empty MySql DB (WfpWiki_DB.sql)

-- File location: C:\djib\setup_OneWiki\OneWiki_DB.sql

-- DROP DATABASE IF EXISTS `OneWiki` ; CREATE USER 'OneWiki'@'localhost' IDENTIFIED BY 'OneWikiPasswd'; GRANT USAGE ON * . * TO 'OneWiki'@'localhost' IDENTIFIED BY 'OneWikiPasswd' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ; CREATE DATABASE IF NOT EXISTS `OneWiki` ; GRANT ALL PRIVILEGES ON `OneWiki` . * TO 'OneWiki'@'localhost';

To use the script, log on the sandbox server, then:

1. Launch a command prompt console 2. Run the following command:

Code listing: Creation of the OneWiki MySql database

C:\> mysql -u root < OneWiki_DB.sql

OMIA – Development and Business Relation Branch 9 Wfp Wiki – Sandbox environment – Wikis Infrastructure 2.2. Apache configuration

A new virtual directory on Apache Web server should be created to “host” the new WfpWiki.

To do so, create a flat file (plain-text) containing the Apache configuration for the new WfpWiki ‘OneWiki’. See the below code listing.

Code listing: Apache configuration for OneWiki

# file C:\wamp\alias\OneWiki.conf

Alias /OneWiki "C:/djib/wikis/"

Options Indexes FollowSymLinks MultiViews AllowOverride all Order Allow,Deny Allow from all

2.3. MediaWiki settings

The configuration at the MediaWiki software level is done thru the creation and setup of a new specific settings file: LocalSettings_OneWiki.php.

To do so, proceed with the following:

1. Add the WfpWiki ‘OneWiki’ settings in the wrapper settings file: LocalSettings.php.

Add it after the last configured WfpWiki, i.e.:

// Glossary Wiki else if ( strpos( $callingURL, 'glossarywiki') ) { require_once('LocalSettings_GWiki.php' ); }

Add it before:

OMIA – Development and Business Relation Branch 10 Wfp Wiki – Sandbox environment – Wikis Infrastructure /////////////////////////////////////////////////////////////// // // All WfpWiki configurations will go above this block // ///////////////////////////////////////////////////////////////

The code listing below shows the lines of code that should be added.

Code listing: Lines of code to add OneWiki settings in the wrapper configuration file

// OneWiki Wiki else if ( strpos( $callingURL, 'onewiki') ) { require_once('LocalSettings_OneWiki.php' ); }

2. Launch the script MoveLS.bat to move all existing specific setting files for WfpWikis and also the wrapper settings file.

Code listing: Content of MoveLS.bat

@REM File location: C:\djib\wikis\MoveLS.bat

move /y LocalSettings*.php LocalSettings\

3. Restart Apache Web Server by lauching the script ApacheRestart.bat

Code listing: Content of ApacheRestart.bat

@REM File location: C:\djib\ApacheRestart.bat @echo off

net stop wampapache net start wampapache

4. Launch your favorite web browser and navigate to: http://localhost/OneWiki

OMIA – Development and Business Relation Branch 11 Wfp Wiki – Sandbox environment – Wikis Infrastructure 5. Click on the link “set up the wiki” and proceed with the OneWiki initialization by filling the form

OMIA – Development and Business Relation Branch 12 Wfp Wiki – Sandbox environment – Wikis Infrastructure Note:

The password for the WikiSysop user on OneWiki is: ‘OneWiki’

6. Once done, you’ll see a message saying:

Installation successful! Move the config/LocalSettings.php file to the parent directory, then follow this link to your wiki.

You should change file permissions for LocalSettings.php as required to prevent other users on the server reading passwords and altering configuration data.

7. Copy the file LocalSettings.php from config folder to the parent folder as LocalSettings_OneWiki.php 8. Launch the Script BringLS.bat

Code listing: Content of BringLS.bat

@REM File location: C:\djib\wikis\BringLS.bat

copy /y LocalSettings\LocalSettings*.php .

9. You can now test your new WfpWiki by launching your web browser and navigating to http://localhost/OneWiki/ 10. If you can see your new wiki... Congratulations!!! Otherwise, please re-check your configurations files.

OMIA – Development and Business Relation Branch 13 Wfp Wiki – Sandbox environment – Wikis Infrastructure 3. How To: Copy a Media Wiki from the SandBox to Another Server

In this How To we will see how to copy (code / data) a Wiki from a server (in this case from the sandbox) to another (in this case on a local machine). We assume that the local machine has WAMP server already installed.

11. Copy the folder called wikis on the local machine (in this example: c:\MyWampfolder\wikis).

This folder will contain all the media wiki.

12. Create a new APACHE alias for the wikis folder.

File Name: wikis.conf

Alias /wikis "C:/MyWampfolder/wikis/"

Options Indexes FollowSymLinks MultiViews AllowOverride all Order Allow,Deny Allow from all

13. Restart Apache.

How To restart Apache

Manually restart Windows Services related to WAMP

or

net stop wampapache net start wampapache

14. Prepare MySQL with a new DB.

We are going to create a new database first, then we will import the production one.

STEP 1: create the following file

File Name: TwoWiki_DB.sql

-- File location: C:\djib\setup_TwoWiki\TwoWiki_DB.sql -- DROP DATABASE IF EXISTS `TwoWiki` ; CREATE USER 'TwoWiki'@'localhost' IDENTIFIED BY 'TwoWikiPasswd';

OMIA – Development and Business Relation Branch 14 Wfp Wiki – Sandbox environment – Wikis Infrastructure GRANT USAGE ON * . * TO 'TwoWiki'@'localhost' IDENTIFIED BY 'TwoWikiPasswd' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ; CREATE DATABASE IF NOT EXISTS `TwoWiki` ;

GRANT ALL PRIVILEGES ON `TwoWiki` . * TO 'TwoWiki'@'localhost';

STEP 2: Execute it

Code listing: Creation of the OneWiki MySql database

C:\> mysql -u root < TwoWiki_DB.sql

Check if the DB has been properly created.

COMPLETEEEEEEEEEEEEEE

OMIA – Development and Business Relation Branch 15 Wfp Wiki – Sandbox environment – Wikis Infrastructure 4. How To: Create the Wikis Environment on the Production Server

In this How To we will see how to create the Wikis environment on the production server.

15. Copy the wikis folder from the sandbox to the production (es: c>\wikis) 16. Create the database.

To do that, create the following file first:

File Name: WikiTraining_DB.sql

-- File location: C:\wikis\wikis\utilities\WikiTraining.sql

-- DROP DATABASE IF EXISTS `wikitraining` ;

CREATE USER 'wikitraining'@'localhost' IDENTIFIED BY 'wikitrainingPasswd'; GRANT USAGE ON * . * TO 'wikitraining'@'localhost' IDENTIFIED BY 'wikitrainingPasswd' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ; CREATE DATABASE IF NOT EXISTS `wikitraining` ; GRANT ALL PRIVILEGES ON `wikitraining` . * TO 'wikitraining'@'localhost';

Then, launch the following command :

Code listing: Creation of the OneWiki MySql database

C:\> mysql -u root < WikiTraining_DB.sql

Then, check if the database was properly created :

Command List:

mysql u -root

> show databases;

17. Create the Apache alias.

To do that, create the following cong file

OMIA – Development and Business Relation Branch 16 Wfp Wiki – Sandbox environment – Wikis Infrastructure File Name: c:\wamp\alias\WikiTraining.conf

# file C:\wamp\alias\WikiTraining.conf

Alias /WikiTraining "C:/wikis/"

Options Indexes FollowSymLinks MultiViews AllowOverride all Order Allow,Deny Allow from all

18. Restart Apache

To do that, restart the proper services.

19. Set up the new Wiki.

Step 1:

Temporary move all the LocalSettings.php to a temporary folder.

Step 2:

Move all the config/LocalSettings.php to a temporary folder

Step 3:

Go to: http://10.11.40.174/WikiTraining and fill up the form.

Forms:

Super Admin Username: WikiSyssop Password: theguru

DB Name: wikitraining DB User: wikitraining DB Password: wikitrainingPasswd

and save.

Step 4:

OMIA – Development and Business Relation Branch 17 Wfp Wiki – Sandbox environment – Wikis Infrastructure Copy the file config/LocalSettings.php to the root of wikis

20. Now, configure the wikis for multiple wikis with multiple database and one code.

Step 1:

Change the name of LocalSettings.php to LocalSettings_WikiTraining.php

Step 2:

Create a file called LocalSettings.php

// the requesting url

$callingURL = strtolower($_SERVER['REQUEST_URI']);

// echo "CallingURL: ". $callingURL . ".";

// exit();

///////////////////////////////////////////////////////////////

//

// All WfpWiki configurations will go below this block

//

///////////////////////////////////////////////////////////////

// M&E Toolkit Wiki if ( strpos( $callingURL, 'm_and_e') ) {

require_once('LocalSettings_ME.php');

}

// Glossary Wiki else if ( strpos( $callingURL, 'glossarywiki') ) {

require_once('LocalSettings_GWiki.php' );

}

OMIA – Development and Business Relation Branch 18 Wfp Wiki – Sandbox environment – Wikis Infrastructure // OneWiki Wiki else if ( strpos( $callingURL, 'onewiki') ) {

require_once('LocalSettings_OneWiki.php' );

}

// TwoWiki Wiki else if ( strpos( $callingURL, 'twowiki') ) {

require_once('LocalSettings_TwoWiki.php' );

} else if ( strpos( $callingURL, 'wikitraining') ) {

require_once('LocalSettings_WikiTraining.php' );

}

///////////////////////////////////////////////////////////////

//

// All WfpWiki configurations will go above this block

//

/////////////////////////////////////////////////////////////// else {

header( "Location: http://10.11.40.174/wfpwiki/" );

}

?>

21. Now you can go to the Wiki http://10.11.40.174/WikiTraining or http://wiki.wfp.org/WikiTraining

OMIA – Development and Business Relation Branch 19 Wfp Wiki – Sandbox environment – Wikis Infrastructure 22. Now add the proper configurations

FCK Editor :

By default, the FCK editor is not installed.

Open the LocalSettings.php and add the require_one code at the bottom of the if statements.

else {

header( "Location: http://10.11.40.174/wfpwiki/" );

} require_once( 'extensions/FCKeditor/FCKeditor.php' );

OMIA – Development and Business Relation Branch 20 Wfp Wiki – Sandbox environment – Wikis Infrastructure Add the following code after the FCK configuration :

require_once( 'extensions/FCKeditor/FCKeditor.php' );

$wgDisableAnonTalk = true;

OMIA – Development and Business Relation Branch 21 Wfp Wiki – Sandbox environment – Wikis Infrastructure $wgShowIPinHeader = false;

$wgWhitelistEdit = true;

$wgLogo = 'http://wiki.wfp.org/_img/logo.png';

$wgGroupPermissions['*']['read'] = true;

$wgGroupPermissions['*']['edit'] = false;

$wgGroupPermissions['*']['createaccount'] = false;

23. Last Step – Do the login

Now, try to go to : http://wiki.wfp.org/WikiTraining

Do the login using :

Username : WikiSysop

Password : theguru

Done

You have completed the quest !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

OMIA – Development and Business Relation Branch 22 Wfp Wiki – Sandbox environment – Wikis Infrastructure 5. How To: Add a New Wiki to the Production Wikis Environment (the travel manual)

In this How To we will see how to add a new MediaWiki called travelmanual.

24. Create the database.

To do that, create the following file first:

File Name: travelmanual_DB.sql

-- File location: C:\wikis\wikis\utilities\travelmanual.sql

-- DROP DATABASE IF EXISTS `travelmanual` ;

CREATE USER 'travelmanual'@'localhost' IDENTIFIED BY 'travelmanualPasswd'; GRANT USAGE ON * . * TO 'travelmanual'@'localhost' IDENTIFIED BY 'travelmanualPasswd' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ; CREATE DATABASE IF NOT EXISTS `travelmanual` ; GRANT ALL PRIVILEGES ON `travelmanual` . * TO 'travelmanual'@'localhost';

Then, launch the following command :

Code listing: Creation of the OneWiki MySql database

C:\> mysql -u root < travelmanual.sql

Then, check if the database was properly created :

Command List:

mysql u -root

> show databases;

25. Create the Apache alias.

To do that, create the following cong file

OMIA – Development and Business Relation Branch 23 Wfp Wiki – Sandbox environment – Wikis Infrastructure File Name: c:\wamp\alias\travelmanual.conf

# file C:\wamp\alias\travelmanual.conf

Alias /travelmanual "C:/wikis/wikis/"

Options Indexes FollowSymLinks MultiViews AllowOverride all Order Allow,Deny Allow from all

26. Restart Apache

To do that, restart the proper services.

27. Set up the new Wiki.

Step 1:

Temporary move all the LocalSettings.php to a temporary folder.

Step 2:

Move all the config/LocalSettings.php to a temporary folder

Step 3:

Go to: http://10.11.40.174/travelmanual and fill up the form.

Forms:

Super Admin Username: WikiSyssop Password: theguru

DB Name: travelmanual DB User: travelmanual DB Password: travelmanualPasswd

and save.

OMIA – Development and Business Relation Branch 24 Wfp Wiki – Sandbox environment – Wikis Infrastructure 28. Move the localconfig.

Move the config/LocalSettings.php to the root

Rename it to LocalSettings_travelmanual.php

29. Restore the LocalSettings.php and add the new handler

else if ( strpos( $callingURL, 'travelmanual') ) {

require_once('LocalSettings_travelmanual.php' );

}

30. DONE !!!!!!!!!

OMIA – Development and Business Relation Branch 25 Wfp Wiki – Sandbox environment – Wikis Infrastructure 6. How To: Move the M & E Wiki to the new Wikis Infrastructure

31. Get information about M&E Wiki database.

Command List:

mysql u -root

> show databases;

mysql> show databases; +------+ | Database | +------+ | information_schema | | glossarywiki | | mewiki | | mysql | | pgmwikidb | | travelmanual | | wikitraining | +------+ 7 rows in set (0.02 sec)

The database name is: mewiki

mysql -u root -p

use mewiki;

show tables;

+------+ | Tables_in_mewiki | +------+ | archive | | category | | categorylinks | | externallinks | | filearchive | | hitcounter | | image | | |

OK! The database exists. It contains tables.

Now we need info about username and password.

OMIA – Development and Business Relation Branch 26 Wfp Wiki – Sandbox environment – Wikis Infrastructure To do that, open the current LocalSettings.php in the old infrastructure.

In this file, get the Database configuration:

## Database settings $wgDBtype = "mysql"; $wgDBserver = "localhost"; $wgDBname = "mewiki"; $wgDBuser = "mewiki"; $wgDBpassword = "m3w1KiBl4h";

32. Create the new Apache alias.

File Name: c:\wamp\alias\M_and_E.conf

# file C:\wamp\alias\M_and_E.conf

Alias /M_and_E "C:/wikis/wikis/"

Options Indexes FollowSymLinks MultiViews AllowOverride all Order Allow,Deny Allow from all

33. Restart Apache

To do that, restart the proper services

34. Create the LocalSettings_ME.php

Use one already created.

Replace the database configuration with:

$wgSitename = "M_and_E";

## The URL base path to the directory containing the wiki; ## defaults for all runtime URL paths are based off of this. ## For more information on customizing the URLs please see: ## http://www.mediawiki.org/wiki/Manual:Short_URL $wgScriptPath = "/M_and_E";

OMIA – Development and Business Relation Branch 27 Wfp Wiki – Sandbox environment – Wikis Infrastructure ## Database settings $wgDBtype = "mysql"; $wgDBserver = "localhost"; $wgDBname = "mewiki"; $wgDBuser = "mewiki"; $wgDBpassword = "m3w1KiBl4h";

35. Update the LocalSettings.php

if ( strpos( $callingURL, 'm_and_e') ) { require_once('LocalSettings_ME.php'); }

7. How To: Move the Glossary Wiki to the new Wikis Infrastructure

1. Get information about M&E Wiki database.

Command List:

mysql u -root

> show databases;

mysql> show databases; +------+ | Database | +------+ | information_schema | | glossarywiki | | mewiki | | mysql | | pgmwikidb | | travelmanual | | wikitraining | +------+ 7 rows in set (0.02 sec)

The database name is: glossarywiki

OMIA – Development and Business Relation Branch 28 Wfp Wiki – Sandbox environment – Wikis Infrastructure mysql -u root -p

use glossarywiki;

show tables;

+------+ | Tables_in_mewiki | +------+ | archive | | category | | categorylinks | | externallinks | | filearchive | | hitcounter | | image | | |

OK! The database exists. It contains tables.

Now we need info about username and password.

To do that, open the current LocalSettings.php in the old infrastructure.

In this file, get the Database configuration:

## Database settings $wgDBtype = "mysql"; $wgDBserver = "localhost"; $wgDBname = "glossarywiki"; $wgDBuser = "glossarywiki"; $wgDBpassword = "bl4bl4wiK1";

36. Create the new Apache alias.

File Name: c:\wamp\alias\GlossaryWiki.conf

# file C:\wamp\alias\GlossaryWiki.conf

Alias /GlossaryWiki "C:/wikis/wikis/"

Options Indexes FollowSymLinks MultiViews AllowOverride all Order Allow,Deny Allow from all

37. Restart Apache

To do that, restart the proper services

OMIA – Development and Business Relation Branch 29 Wfp Wiki – Sandbox environment – Wikis Infrastructure $wgSitename = "GlossaryWiki";

## The URL base path to the directory containing the wiki; ## defaults for all runtime URL paths are based off of this. ## For more information on customizing the URLs please see: ## http://www.mediawiki.org/wiki/Manual:Short_URL $wgScriptPath = "/GlossaryWiki";

## Database settings $wgDBtype = "mysql"; $wgDBserver = "localhost"; $wgDBname = "glossarywiki"; $wgDBuser = "glossarywiki"; $wgDBpassword = "bl4bl4wiK1";

38. Update the LocalSettings.php

if ( strpos( $callingURL, 'm_and_e') ) { require_once('LocalSettings_ME.php'); }

OMIA – Development and Business Relation Branch 30 Wfp Wiki – Sandbox environment – Wikis Infrastructure 8. How To: Backup a Wiki Database

Example: Backup the Travel Manual

STEP 1: Use remote desktop and go to 10.11.40.174

Username: PGMAdmin Password: PgmW1ki

STEP 2: Go to the folder C:\wikis\backup\travelmanual

Use the command line.

> mysql u –root

> show databases;

> use travelmanual; mysqldump -u root -p travelmanual > travelmanual_yyyymmdd_hhmm.sql

OMIA – Development and Business Relation Branch 31 Wfp Wiki – Sandbox environment – Wikis Infrastructure OMIA – Development and Business Relation Branch 32 Wfp Wiki – Sandbox environment – Wikis Infrastructure 9. How To: Create a dynamic backup procedure – TO DO

TO DO

OMIA – Development and Business Relation Branch 33 Wfp Wiki – Sandbox environment – Wikis Infrastructure @echo off

rem *************************************************************************** *********** set servername=10.11.40.174 set database=travelmanual

set mysqldir="C:\wamp\bin\mysql\mysql5.0.51b\bin" set utils=C:\Data\utils\bin set workdir=data

OMIA – Development and Business Relation Branch 34 Wfp Wiki – Sandbox environment – Wikis Infrastructure @REM Mail Configuration

SET mailsmtp="10.11.40.164"

SET mail=%utils%\blat.exe rem SET mailto="[email protected], [email protected]"

SET mailto="[email protected]"

SET mailfrom="MySQL Backup Service" rem SET mailsubject="MySQL Backup of %database% on 10.11.40.174"

SET mailsubject="MySQL Backup of Media Wikis on 10.11.40.174 - Date: %date% - Time: %time%"

rem *************************************************************************** ***********

@REM Date Configuration for /f "tokens=1-4 delims=/ " %%a in ('date/t') do (

set dw=%%a

set mm=%%b

set dd=%%c

set yyyy=%%d

)

for /f "tokens=1-4 delims=/ " %%a in ("%date%") do set currentdate=%%d_%%c_%%b

OMIA – Development and Business Relation Branch 35 Wfp Wiki – Sandbox environment – Wikis Infrastructure for /f "tokens=1-4 delims=:." %%d in ("%time%") do set currenttime=%%d_%%e_%%f_%%g

rem *************************************************************************** **********

echo Backup: %database% echo Current Date: %yyyy%/%mm%/%dd% echo Current Time: %currenttime%

set filename=%servername%.%database%.%currentdate%_%currenttime%.sql

echo %filename%

mysqldump -u root travelmanual > %workdir%/%filename%

rem *************************************************************************** ********** rem *** Zip the file rem *************************************************************************** **********

OMIA – Development and Business Relation Branch 36 Wfp Wiki – Sandbox environment – Wikis Infrastructure @REM Zip up database

%utils%\gzip.exe -f %workdir%\%filename%

ECHO .. Backup compression ...... OK!

rem *************************************************************************** ***********

SET message=%date% - %time%: Backup of [%database%] has been completed succesfully!!!

%mail% -q -server %mailsmtp% -f %mailfrom% -to %mailto% -subject %mailsubject% -body "%message%"

rem *************************************************************************** ************************************************* rem Backup a database and send email rem Parameters: rem DatabaseName rem Examples: rem call:myWikisBackup DatabaseName rem *************************************************************************** *************************************************

OMIA – Development and Business Relation Branch 37 Wfp Wiki – Sandbox environment – Wikis Infrastructure :myWikisBackup

SET DBname =%~1

echo %DBname%

rem set bk_filename=%servername%.%~1.%currentdate%_%currenttime%.sql

rem echo. here the myDosFunc function is executing a group of commands

rem echo. it could do %~1 of things %~2. goto:eof

OMIA – Development and Business Relation Branch 38 Wfp Wiki – Sandbox environment – Wikis Infrastructure