Wednesday, August 31, 2011

Migrating MediaWiki from one server to another

I had a frustrating time migrating an old MediaWiki from one server to another. The old MediaWiki was quite old (1.6.3) and it was working fine, so I had never got around updating it. In the meantime, the world had changed: hurricanes came and went, comets flew over and MediaWiki software also got upgraded. But I was blissfully unaware of all that; till I had to finally shut down the server (couldn't afford it anymore ... possibly the comet had something to do with it) but I also needed to keep the Wiki alive.

I finally decided to shift it to a Dreamhost server that I had. And therein the problems started. I then tried it on another server, and the problems were the same. I could see the title of pages, but not the contents. It kept saying that "There is currently no text in this page, you can search for this page in other pages or edit this page"

Though, at the same time, I could see the titles... Hmmm

Finally I got the solution and here it is:

Firstly, export all the contents of the old website by running the maintenance/dumpBackup.php script from the shell of the old server. Give the --full command line parameter too ... thus

php maintenance/dumpBackup.php --full >wikiexportedcontents.xml

Note that this exports only the mediawiki contents and not users. You will have to re-create your users later separately. Sorry about that. But that may be not much of a problem.

FTP that XML file to your new site.

Use a favorite MySQL tool (PhpMyAdmin is available in most servers) and dump the SQL of two specific tables in your old Wiki. One is called "wiki_images" and the other is called "wiki_image_links" (This is assuming that the prefix that you had used for the tables was "wiki_" If not, substitute whatever else you may have used) FTP these SQL dumps also into your new server.

Now FTP all the files of the old site to the new site and place it in the correct web-path you plan to use. Make sure the "config" folder is R/W. Rename "LocalSettings.php" to something else (you may need some details from it later)

Create an empty database and a database user to work on that database. Your favorite CPanel (or whatever else poison you use to manage your website) should have PhPMyAdmin (or some other such tool) to make the database, and the user and set privileges for the user.

Now, point the DNS to the new site.

Go to your browser and ask it to load your new site. Since MediaWiki does not have the LocalSettings.php file (remember you renamed it), it will assume that you need to create a new Wiki and will ask you to do the initial setup. Follow all the steps and create a brand new Wiki with empty contents, excepting for the default front page. If the "config" folder was not made writable, the setup would fail.

Now login into the new, squeaky clean Mediawiki website in the new site as the SysOp ... and promptly delete the old front default page (Main_page) that was created. Now you truly have no pages whatsoever in your new wiki at the new site.

Go to the shell of the new server. Go to the maintenance section of the new MediaWiki site. Give the following command:

php importDump.php wikiexportedcontents.xml

(The above command assumes that you had placed the xml file "wikiexportedcontents.xml" into the same folder)

Viola, the old contents would now appear in the new site... but the images would not be seen because those tables are not recreated (at least in Mediawiki version 1.6.3 that was the problem. Not sure whether the later XML versions did a better job) Now load the MySQL manager (PhpMyAdmin usually) of your new site, and empty the contents of the "wiki_images" and "wiki_image_links" tables. Into those tables, import the two SQL dumps that you had FTP'd to your new site

Play around with your new MediaWiki. Edit a page or two , and somewhere (when the cache gets cleaned up, possibly) you would find that the images also turn up on your new site

Now painfully recreate your users (!) But wait a minute... possibly you could export an SQL dump of the users table and use that in your new site. Haven't tried that

All the best



Sunday, April 26, 2009

Ubuntu 9.04

Ubuntu 9.04 has just been released and I upgraded. But there were several hitches. I am noting those down in this post along with their workarounds:

1. IPV6 problem In the past IP addresses were 4 numbers separated by dots like this 123.123.123.123 Each of those numbers have to be below 255, with some numbers reserved for LAN addresses, etc. (E.g. 127.0.0.0 is a shortcut for a loop-back i.e. to the same device where the IP packets originate. So 127.0.0.0 for each computer is the same computer itself)

Because the population of Internet users are growing these IP addresses are not sufficient. So they invented IPV6 -- a new way of specifying the addresses. Don't ask me the details because I don't know...but I do know that they can handle a lot more addresses than IPV4 Most modern browsers support them. Operating systems support them. Routers support them, and most nodes along the way (E.g. DNS servers) on the Internet support them. But many website servers still do not support them. Also you will find certain DNS servers and some ancient routers not supporting them.

That leads to problems. So for the time being the best way out is to do two things:

a) Switch off IPV6 in Ubuntu. A hard thing to do if you are using Kernel 2.6.28-11-generic. I found out after several hours. In Kernel 2.6.28-11-generic everything is burnt in, so you need to recompile the Kernel keeping the support of IPV6 outside of it ... something that I did not want to do. Luckily for me, Kernel 2.6.27-11-generic was also available on my machine, so I commented out the reference to Kernel 2.6.28-11-generic in the Grub boot file
Then I wrote the following line in a file called bad_list (which in my case was non-existing, so it was a new file that I created) The location of that file is /etc/modprobe.d/ This is a system protected folder so you need to use sudo

sudo nano /etc/modprobe.d/bad_list

Inside that file, I wrote one line:

alias net-pf-10 off

On some sites, they recommend that you can also write these two lines in /etc/modprobe.d/blacklist.conf

blacklist net-pf-10
blacklist ipv6


b) Switch to the DNS servers provided by openDNS (www.opendns.org)

Without doing the above two, you will find that Opera 9.26 will not work

2. Intermittent hanging of Gnome
Gnome hangs every now and then, especially when the new Firefox (3.0x) quits. There are also several other points at which Gnome hangs. For e.g. changing the wireless settings (the points may differ for you) I don't know why this is happening. Possibly a display manager problem. Possibly a hardware. I'll keep you posted. The whole screen gets mangled and nothing works ...only the mouse moves around. I can't even quit the blessed system gracefully; and I have to power off the computer manually. Not a good thing to do because I can possibly fry the hard-disk that way. I later on learnt that there could be a key-board short cut : CTRL-ALT-BACKSPACE which I could use to restart the desktop manager. Unfortunately, they've disabled that shortcut key in this version of Ubuntu for some vague usability reason. This is what you are supposed to do if you want the hotkey back:

1. Open a terminal window
2. Give the following command
sudo apt-get install dontzap
3. The above will install a utility called dontzap (It is not installed by default)
4. Give the following command
dontzap --disable
5. Restart

Now for some reason the computer hangs, you can try CTRL-ALT-BACKSPACE and you will be able to start again (All work in that session will immediately lost... but still it is better than a fouled up hard-disk)


Saturday, April 11, 2009

Wink and language settings

When I installed Ubuntu, I had set the language to "English, India" Evidently some programs are not designed to accept that gracefully. I installed the nice presentation and tutorial creation software called "Wink" and I found that all the menu items, tool bars, and other messages were replaced by place holders. Being a programmer myself I realized that they are the mnemonics used internally by the program to patch in the message from the appropriate language file as the program loads. As there was no setting for Indian English, it did not know what to do next. Maybe the Wink developer (http://www.debugmode.com ) could consider a graceful default if a particular language setting was not available.

Anyway, I shifted to UK English and the program works fine now.

Prolog on Linux and a few lessons

I code extensively in Prolog and much of my work was done in an esoteric version of that language; Visual Prolog (earlier PDC Prolog, earlier to that... Turbo Prolog, yes from Borland) Visual Prolog is a fantastic language even though strict Prolog afficionados may scoff at it. It truly has some remarkable features and the PDC people are rightfully not so worried about where their language is placed. Unfortunately from version 6.0 onwards, there is no version for Linux, so I went looking for one. Version 5.2 did have a good Linux compiler but it was still a commercial one, and so not suitable for open source apps; an area I am now getting into.

I tried out two Prolog interpreters/compilers: SWI-Prolog and then Gnu Prolog. SWI-Prolog is extremely well supported but it is not as fast as Gnu Prolog. Gnu Prolog has an extensive range on how it can work: It can act as an interpreter, or it can even compile to various forms of compilation: bytecode (similar in nature to Java) and native code.

One can even create a customized Prolog interpreter with one's own extensions -- this was very appealing for some of my projects. I had written my own version of Prolog called "Web Prolog" which has not seen the light of the day by the outside world but was used quite effectively in my own office. Gnu Prolog interpreter creation feature may make Web Prolog even better and usable by many more. Oh I am digressing...

So here I wanted to try out Gnu Prolog's compilation feature. So I wrote this very simple test, and guess what; called it test.pl

go:- write('Hello world').

It compiled all right to create the executable "test" with the following compiler command:

gplc test.pl

but when I gave the following command

test

Nothing! Nothing happened! After several vexing minutes, I realized that Linux was probably not running test from the same folder where it compiled and there is another executable somewhere which is being executed. So I gave this command to find out

which test

And it returned

/usr/bin/test

Now I definitely was not compiling my program at /usr/bin/test (Nobody should, Work always in your own folder or sub-folders underneath it)

Dumb! What was that version of test doing there? No idea. Who created that? I think it came with some installation. I checked the date and it was created last year, so it was not because of some compilation I did.

Important takeaway lesson for Windows users:

In windows, when you run a command in a current folder, Windows will first execute from the current folder and if it is not existing there it will go checking the environment PATH. In Linux, not so. If you want to run from the current folder then you have to specifically state it thus:

./test

It is an excellent security feature, which is better explained elsewhere.

Now the program was not correctly written or compiled. gprolog was jumping directly into the interpreter. I wanted a squeaky little program of my own. So here is the actual code for gnu prolog:

:- initialization(go).

go:- write('Hello there').

And this is how you compile it:

gplc -o mytest --no-top-level test.pl

The above produces an executable called mytest Aha, the satisfaction of seeing someone on my laptop LCD telling me "Hello there" ....hmmmm

Wednesday, April 8, 2009

Sound issues in Ubuntu

If you get some faint crackling sound in the speakers and nothing else, the way I did with the Conextant/NVidia sound card then run this command

alsamixer -Dhw

It is possible that the PCM Mixer volume is muted or set to zero. When you run that command, you will be given a text interface which you can control using the arrow-keys. (I think such interfaces are known as CURSES interface, for some reason) You should navigate to the mixer section, which I believe is the 2nd option and turn it all the way up.

More later

Tuesday, April 7, 2009

Browser and File Manager Tweaks

I did not like the default Ubuntu Nautilius file manager. Nautilius has a nasty refresh problem: Once you click on a folder, it will not show the content unless you force a refresh by slightly resizing the window. What a pain.

So I installed Thunar instead. You can do that using the Add/Remove Applications feature of Ubuntu. I made it the default file manager by following the instructions given here Or you can use the scripts here

I was hoping that it would change the default file manager even inside Firefox. But sadly it did not. After much googling I realized that I was searching for the wrong information. I should have asked for "file picker" and not "file manager"

Well, to make Firefox use Thunar instead of the earlier Nautilius, I had to start a new window in Firefox and go to the special url called about:config That is a shortcut to reveal some quite advanced configuration inside Firefox. You will get a warning that if you do something wrong, things can go terribly wrong indeed. So be warned and proceed. It will display a huge list of configurable items.

I then searched for this ui.allow_platform_file_picker On clicking it, it will change the value from true to false (Clicking it again will turn it back to true) Make sure that you set that value as false

That's it. Close that window and you'll find that Firefox is now using Thunar.

You have a similar option in Opera too: Go to about:config in opera and search for File Selector. The options are usually hidden. Click on "File Selector" and it will display a value: 0 means auto. Try with 1 or 2 for the other file managers available. One of them should work properly for you.

Sunday, April 5, 2009

Programming Re-captcha with Rebol

Captcha is a good system to prevent automated submission of forms by spammers. There is a free web-service from http://www.recaptcha.net that allows anyone to create a recaptcha form and use it for your own forms. It is quite simple actually.

You will definitely need to read this http://recaptcha.net/apidocs/captcha/client.html It explains how to embed the Recaptcha form within your own form on your own site.

If you want to get under the hood then read http://recaptcha.net/apidocs/captcha/ It will explain how to write your own Recaptcha processor. You may skip that if you use the Rebol system I've developed.

I program a lot in Rebol. However, there is no Recaptcha library specifically for Rebol. Turned out that it was quite easy to write one. The following piece of code is what you need in Rebol. I cannot get into the details of how Rebol works. Read docs at http://www.rebol.com for that.

In the following piece of code, it is assumed that the variable 'vars' is a bound object containing the values of the form being processed. If you insert the standard recaptcha into your form, then you should get vars/recpatcha_challenge_field and vars/recaptcha_response_field in that object. If you do not know how to do that, then simply use this script http://www.rebol.org/view-script.r?script=safe-cgi-data-read.r

This also assumes that your site is working on an Apache server. The REMOTE_ADDR environment variable is set on Apache servers. I am not so sure about other servers. Replace {YOURPRIVATEKEY} with whatever they sent you when you registered your site with recaptcha.net The public and private key is specific to your website.


Lastip: get-env "REMOTE_ADDR"

chall: replace/all vars/recaptcha_challenge_field " " "+"

resp: replace/all vars/recaptcha_response_field " " "+"

result: read/custom http://api-verify.recaptcha.net/verify

reduce ['POST rejoin ["privatekey={YOURPRIVATEKEY}&remoteip="
Lastip
"&challenge=" chall "&response=" resp
]


]

lns: load result

either lns/1 = "true" [

print [" Re-Captcha was correct!"]
;;;;at this point you may take the rest of the form
;;;;and proceed using it

] [

print ["Re-Captcha was not corret. Please try again"]

]