Moving MediaWiki to 5.0-Nano
|Moving and upgrading MediaWiki 5.0-Nano|
While testing Uniform Server 5.0-Nano I wanted an application with an already populated database. I fished out a copy of MediaWiki from my original write-up “Moving and upgrading MediaWiki on Uniform Server”.
Like Uniform Server, MediaWiki has moved on hence I wondered if my original write-up was still viable. Being a personal Wiki each page has numerous edits these are redundant and just add clutter to the database. There is a plugin that removes all edits thought I would throw this in while testing.
This step-by-step guide shows how to move an existing copy of MediaWiki to Uniform Server 5.0-Nano and how to upgrade MediaWiki to remove all old edits.
Mirror existing Wiki
Mirror existing Wiki on new server as follows:
- Create a new folder a_test (Can be any name. I have also ssumed C drive)
- Unpack Uniform Server 5.0-Nano to this folder.
- From old installation, copy wiki folder *\www\wiki to new server C:\a_test\UniServer\www\wiki
- From old installation, copy database folder: Uniform Server\udrive\usr\local\mysql\data\wikidb
- To new server folder: C:\a_test\UniServer\usr\local\mysql\data
Copy new MediaWiki files to mirrored server.
- Downloaded new version of MediaWiki and unpacked it.
- Copy all files in folder mediawiki-1.15.0
- To new server, folder C:\a_test\UniServer\www\wiki allow overwrite of any existing files.
For details see Installing MediaWiki on 5.0-Nano for details
Upgrading requires setting MediaWiki Amin privileges in the admin settings file as follows:
Locate the file AdminSettings.sample found in folder C:\a_test\UniServer\www\wiki
make a copy and rename it AdminSettings.php
Edit this new file (AdminSettings.php) locate these two lines:
$wgDBadminuser = 'wikiadmin'; $wgDBadminpassword = 'adminpass';
Change as shown (If you have changed the password use that instead of root)
$wgDBadminuser = 'root'; $wgDBadminpassword = 'root';
The upgrade guide informs you to run update.php from a command prompt.
This will fail because Uniform Server adds nothing to your PC hence the PHP executable is not on any system path.
Solution is to create a batch file and run the command from the PHP root folder.
Create the following batch file name it wiki_update.bat
Save to folder C:\a_test\UniServer\usr\local\php The batch file runs update.php in CLI mode.
php.exe ..\..\..\www\wiki\maintenance\update.php pause
Note: If you have named your wiki folder something else just substitute it in the above.
The update script writes to the MySQL server hence the servers to be running procced as follows:
- Start UniTray, in folder C:\a_test\UniServer double click on Start.exe tray icon created.
- Switch to production, Left click tray icon > Advanced > click php.ini switch to Production.
- Start Uniform Server. Left click tray icon > click Start UniServer
- Navigate to folder: C:\a_test\UniServer\usr\local\php
- Run update double click on file wiki_update.bat
- Be prepared for a long wait however if your Wiki database is small it is fairly quick.
After running the above if you get locked out of the database elevate wikiuser to root as follows.
Edit file: C:\a_test\UniServer\www\wiki\LocalSettings.php change line:
$wgDBuser = "wikiuser";
$wgDBuser = "root";
The above applies to minor version updates for major version upgrades please read any notes supplied with that version.
Plugin to remove all edits
I mentioned in the introduction page edits build up and generally are surplus to requirement. This section looks at installing and using a neat plugin to remove all page edits originaly designed by Marc Noirot and Gunter Schmidt now maintained by Jehy at www.mediawiki.org.
Copy extension to Wiki:
- Create a new folder C:\a_test2 (can be any name just used for reference)
- Download latest version currently 1.4 from Extension:SpecialDeleteOldRevisions2
- Copy the file downloaded (specialdeleteoldrevisions2.zip) to the above folder
- Extract this archive to the current path.
- Copy folder C:\a_test2\specialdeleteoldrevisions2\SpecialDeleteOldRevisions2
- To folder: C:\a_test\UniServer\www\wiki\extensions
Edit file C:\a_test\UniServer\www\wiki\LocalSettings.php
Add the following lines to the end of this file:
// Extension DeleteOldRevisions $wgGroupPermissions['sysop']['DeleteOldRevisions'] = true; require_once( $IP.'/extensions/SpecialDeleteOldRevisions2/SpecialDeleteOldRevisions2.php');
Top How to use:
- Start server and login to Wiki
- From left menu select special pages
- Scroll to bottom of this page.
- A new menu item “Delete old revisions” has been created.
- Click this, a new page opens, default is to delete all revisions.
- Note the two buttons “Delete history” and “Test only”
- Click “Delete history”
That will take some time on completion a conformation message is displayed “The old revisions were successfully deleted.”
In addition to the above line you will see “Remember to shrink your database after deleting many articles.” This is performed using phpMyAdmin as follows:
- Start phpMyAdmin: left click tray icon > click phpMyAdmin
- From phpMyAdmin’s left menu click wikidb
- A page displays all tables in this database, scroll down to end of page.
- To the left click “check all” this selects all tables.
- To the right, click the drop down menu "With selected:" to display it’s items. Select “Optimize table”.
- Apart from wikidb.hitcounter you will see either OK or Table is already up to date confirming operation was successful. For wikidb.hitcounter you will see “The storage engine for the table doesn't support o...” ignore this, it is OK
Is it worth the effort!
Its relatively easy to set up, my original database was 53.1 MB after running the script and optimizing, database reduced to 8.23 MB. That’s a massive saving and well worth the effort.
One of Uniform Server’s unique features is the capability to run more than one complete server on the same PC. When running a server from a USB memory stick you can use this to great advantage and prevent server clashes. You will have noticed UniTray’s icon displays one (meaning standard ports). Moving UniServer increments this digit and so on for each server move. In reality it’s not just a port change but a complete server update, running server status displays the server characteristics.
Move Servers and Wiki:
- Stop all running Uniform Servers
- Start UniTray, in folder UniServer double click on Start.exe tray icon created.
- Move servers, Left click tray icon > Advanced > click Move Servers multi-server operation.
- In the pop-up window at all prompts press enter to accept defaults.
- The tray icon will display 2, if you already use a server with this number repeat steps 3 and 4 each server must have a unique number. I run my Wiki on icon2 (server 2).
I moved the servers to icon 2 hence Apache port = 81 and MySQL port = 3307
- After moving the servers Apache and MySQL automatically use the new ports.
- However before proceeding you need to configure the Wiki to use the new MySQL port.
- To find this: Left click tray icon > Server Status
- Edit file UniServer\www\wiki\LocalSettings.php
- Locate line (61)
Change line: $wgDBserver = "localhost";
To: $wgDBserver = "localhost:3307";
- Save file.
After installation Access your wiki by typing the following into your browser address bar:
- http://localhost:81/wiki/ or
Note 2: Use the port numbers that matches your server.
Minor updates are really that easy note when upgrading an existing server make a backup copy of the server first. In either case the batch file wiki_update.bat and AdminSettings.php need creating.
Space on a USB memory stick is valuable real estate hence removing any dross or redundant files are worth the effort. Added to that the smaller the faster you can copy to it.