User:Huji/Wikimedia clone

Start with a fresh Ubuntu installation for Virtualbox.

Install all the ncessary software:

sudo su apt-get install vim apt-get install git apt-get install apache2 apt-get install mysql-server apt-get install php5 libapache2-mod-php5 service apache2 restart

You will be recommended to set a password for your mysql root account. If you set a password, write it down somewhere!

Transfer your private key to ~/.ssh then make it secure using  and then add it using

Then download the MediaWiki core and store it in /var/www/w using git:

git clone ssh://@gerrit.wikimedia.org:29418/mediawiki/core.git

This will look for some 300,000 objects on the remote side, but eventually you will download some 55,000 files.

Multiple Wikis
Let's say you want to have two sister wikis: English Wiki and Persian Wiki.

First go into mysql ( then type the password) and run the following:

Then install MediaWiki once into the  database. Once completed, store the LocalSettings.php into the w/ directory, but then rename it into LocalSettings_fa.php and then install MediaWiki again, this time into  database, and save this new LocalSettings.php file into w/ directory.

Short URLs
The next step is to set up short URLs. Instructions are here.

In short, you add  to the file named   that you find in   and you also edit your LocalSettings.php file where $wgScriptPath is defined, to look like this:

Now if you restart apache using  you should be able to browse to http://localhost/wiki/ and get to the home page of your second wiki.

Subdomains
The next step is to add subdomain support, both on Apache's side and on MediaWiki's.

First edit  and add references to en.localhost and fa.localhost (use 127.0.0.1 as the IP). Then add  to the file named   that you find in

Now move all these variables to the end of your LocalSettings.php: $wgSiteName, $wgServer, $wgDBname, $wgLanguageCode, $wgSecretKey, and $wgUpgradekey

Find the same varibles in your LocalSettings_fa.php and put them together too. Now we should move all this stuff into our LocalSettings.php file, but help MediaWiki choose which to use based on the subdomain. It is explained here and you should end up with something more like this:

When you are copy-pasting, note that $wgServer needs to be updated in both cases, to include the subdomain.

While you are on it, also create a file named  in the   directory with the following content:

This way, when you update your MediaWiki, updating the DB will be as easy as running  and then

Interwiki
To set up interwikis between these two wikis, go into mysql command line and run the following:

Central Auth
The next step is to install and configure CentralAuth. First download it into the w/extensions directory:

git clone ssh://@gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth.git

Then go into w/extensoins/CentralAuth directory, and find the central-auth.sql file. You need to edit the file, and uncomment the lines that say  and   so that you can run it from shell like this:

mysql -u root -p < central-auth.sql

Revert the changes to the  file. Finally, edit your LocalSettings.php and add this line:

Now you need to setup $wgConf for CentralAuth to work.

wgConf
Define $wgConf in LocalSettings.php with at least these data in it:

Migration
Now you need to run the migration scripts. Start by creating a file in  named   with the following source:

Now you should run these four commands on bash while you are in /var/www/w/extensions/CentralAuth/maintenance:

php migratePass_farm.php fa.localhost 0 php migratePass_farm.php fa.localhost 1

php migratePass_farm.php en.localhost 0 php migratePass_farm.php en.localhost 1

This will update the centralauth tables in the database.

Central cache
Since our wikis use different databases, they need to have a shared cache to let CentralAuth's central login feature work. Start by creating a shared table in centralauth database, by running this command in mysql:

Then add these lines to the end of your LocalSettings.php after the require_once: