BDMV.INFO

 Retrieve Password
 register now
Search
Hot: #
!show!: 264026|Reply: 0

[2014.05.31]Base on Lighttpd to Install Multi-language Mediawik 、Add Short URL 、Save the Backup and Upgrade (Update) [Copy URL]

Rank: 9Rank: 9Rank: 9

Post time 2013-7-21 22:07:38 |Show all posts
Sample
http://en.bdmv.info/snowiki
http://zh.bdmv.info/snowiki

Because of I only install all the server and provide the web service in the dedicated server and using linux os, of cause I have full root access premission, I just can provide the experience to guys are using the same platform as me.
The linux system of my server is ubuntu 12.04 64bit server,  and the database of mediawiki is using mysql. Pepole need to be prepare the enough software and I may descript it in detail in this tutorial.
In fact, you can find all the detail installing steps in mediawike official  website, I just collect a part of mediawiki document in this tutorial and I think that may the key point when people find issue during  mediawiki setup.
If people thinks reading the mediawiki's items is better, please refer the below bottom reference.

Step 1 : Install the Mediawiki File System
Enter the official website, then you can get the download link of the (new version) mediawiki, we download、erxtract tarball and move the file system files to the home directory of web server.
  1. wget http://releases.wikimedia.org/mediawiki/1.22/mediawiki-1.22.3.tar.gz
  2. tar xzvf mediawiki-1.22.3.tar.gz
  3. sudo cp -a mediawiki-1.22.3 /var/www/snowiki
  4. sudo chown -R www-data:www-data /var/www/snowiki
Copy the Code

Step 2 : Create a New Mysql Databae

Install the mysql and create a new database and grain to a user and  let mediawiki to use this database, I ignore all the detail steps, please refer to the google god
Final, The database name set to wiki temporarily and the username/password set bdmv/info

Step 3 : Start to Install the Mediawiki
Base on this document to install mediawiki and people must prepare some softwares before installing the mediawiki - xcache、php5 (and some dodules)、web server (lighttpd).
If you had already read this tutorial to install the rtorrent+rutorrent, you may install most of softwares we need to install.
  1. sudo apt-get update
  2. sudo apt-get install php5-cli php5-dev libgd2-xpm libgd2-xpm-dev php5-gd
  3. wget http://xcache.lighttpd.net/pub/Releases/3.0.4/xcache-3.0.4.tar.gz
  4. tar -xzvf xcache-*.tar.gz && cd xcache*
  5. phpize --clean && phpize && ./configure --enable-xcache --enable-xcache-optimizer
  6. make && sudo make install
Copy the Code
About the xcache, people can downloadthe new version in the official website. the config and install steps is the same.
Because of zen_extension don't support new version xcache any more,  remove the xcache.ini file. If you don't find xcache.ini at  /etc/php5/conf.d/, skip this step.

Using vim to edit the /etc/php5/cgi/php.ini file and refer the below block to add some parameters in this file.
Pay attention, substituting [your user name] and [your passwoed] as appropriate, and the password must transfer to md5, please refer the shell script in lighttpd website.
You can refer the below command to get the md5 code of the word -password.
  1. echo -n 'password'|md5sum|cut -d '' -f1
Copy the Code
The parameters are ...
  1. [xcache-common]
  2. ;; install as zend extension (recommended), normally "$extension_dir/xcache.so"
  3. extension = xcache.so

  4. [xcache.admin]
  5. xcache.admin.enable_auth = On
  6. ; Configure this to use admin pages
  7. xcache.admin.user = "your user name"
  8. ; xcache.admin.pass = md5($your_password)
  9. xcache.admin.pass = "your password"

  10. [xcache]
  11. ; ini only settings, all the values here is default unless explained

  12. ; select low level shm/allocator scheme implemenation
  13. xcache.shm_scheme =        "mmap"
  14. ; to disable: xcache.size=0
  15. ; to enable : xcache.size=64M etc (any size > 0) and your system mmap allows
  16. xcache.size  =                32M
  17. ; set to cpu count (cat /proc/cpuinfo |grep -c processor)
  18. xcache.count =                 2
  19. ; just a hash hints, you can always store count(items) > slots
  20. xcache.slots =                8K
  21. ; ttl of the cache item, 0=forever
  22. xcache.ttl   =                 0
  23. ; interval of gc scanning expired items, 0=no scan, other values is in seconds
  24. xcache.gc_interval =           0

  25. ; same as aboves but for variable cache
  26. xcache.var_size  =            8M
  27. xcache.var_count =             1
  28. xcache.var_slots =            8K
  29. ; default ttl
  30. xcache.var_ttl   =             0
  31. xcache.var_maxttl   =          0
  32. xcache.var_gc_interval =     300

  33. xcache.test =                Off
  34. ; N/A for /dev/zero
  35. xcache.readonly_protection = Off
  36. ; for *nix, xcache.mmap_path is a file path, not directory.
  37. ; Use something like "/tmp/xcache" if you want to turn on ReadonlyProtection
  38. ; 2 group of php won't share the same /tmp/xcache
  39. ; for win32, xcache.mmap_path=anonymous map name, not file path
  40. xcache.mmap_path =    "/dev/zero"


  41. ; leave it blank(disabled) or "/tmp/phpcore/"
  42. ; make sure it's writable by php (without checking open_basedir)
  43. xcache.coredump_directory =   ""

  44. ; disable cache after crash
  45. xcache.disable_on_crash =    Off

  46. ; enable experimental documented features for each release if available
  47. xcache.experimental =        Off

  48. ; per request settings
  49. xcache.cacher =               On
  50. xcache.stat   =               On
  51. xcache.optimizer =           Off

  52. [xcache.coverager]
  53. ; per request settings
  54. ; enable coverage data collecting for xcache.coveragedump_directory and xcache_coverager_start/stop/get/clean() functions (will hurt executing performance)
  55. xcache.coverager =          Off
  56. xcache.coverager_autostart =  On
  57. ; ini only settings
  58. ; make sure it's readable (care open_basedir) by coverage viewer script
  59. ; requires xcache.coverager=On
  60. xcache.coveragedump_directory = ""
Copy the Code
Then, install the php5-intl to realize the unicode normalization and restart the linux system.
  1. sudo apt-get update && sudo apt-get install php5-intl && sudo shutdown -r now
Copy the Code
Btw, people can add a php file to check all the modules of php by the web browser, like xcache or GD.
  1. <?php

  2. // Show all information, defaults to INFO_ALL
  3. phpinfo();

  4. // Show just the module information.
  5. // phpinfo(8) yields identical results.
  6. phpinfo(INFO_MODULES);

  7. ?>
Copy the Code
The last important point is the upload security problem,
If you concern the security that someone may upload malicious files in your server before you enable the upload function of mediawiki,
please change mode closing the read/write/excute permission of the web user of the image folder
  1. sudo chmod 000 /var/www/snowiki/images
Copy the Code
After installing these necessary packages or importing the parameters, we can install mediawiki
  1. http://host.name/snowiki
  2. http://host.name/snowiki/mw-config/index.php
Copy the Code
For example of the Chinese Traditional language  step by step to finish the installing.
The most important point is the prefix of database, I use zh_ and en_ to separate the table of the same database name, you can select any prefix what you like.


















Remember to download and move the LocalSettings.php file to snowiki ( file system ) folder, then the basic mediawiki platform is ok.

Step 5 : Setup The Multi-language Support of Mediawiki

First, you need register one of the  top-level domain (TLDs) and set two subdomain to the recoder type A(address)
Like my mediawiki use the zh and en to match with two kinds of languages -Traditional Chinese and English mediawiki platform and we can refer the document of wiki family to realize multi-language.

Edit the lighttpd config file to prepare the wiki family environment.
  1. sudo vi /etc/lighttpd/lighttpd.conf
Copy the Code
For example:
Before changing


After Changing

(Please change "ip" and "domain.name" as appropriate)
Then edit the file name of LocalSettings.php (for example: LocalSettings_zh.php) and create a new php file (LocalSettings.php) to control these multi-language mediawiki from mediawiki file system directory - snowiki

Rename the setting file
  1. sudo mv LocalSettings.php LocalSettings_zh.php
Copy the Code
Because you rename the localsetting file, you can install another mediawiki
Navigate your web browser to the page  and according the above installing steps again to prepare a new mediawiki usning another language, please remember you need use another prefix is not the same as the setting you install the old mediwiki use before.
  1. http://zh.domain.name/snowiki/mw-config/index.php
Copy the Code
After you finish another mediawiki, you need upload the setting file to your server again and rename to LocalSettings_en.php.
Because of you don't have any LocalSettings.php file to let file system to recognize your mediawikis, you need create a new LocalSettings.php.
  1. sudo vim LocalSettings.php
Copy the Code
  1. <?php
  2.         switch ($_SERVER["SERVER_NAME"])
  3.         {
  4.                 case "zh.domain.name":
  5.                         require_once "LocalSettings_zh.php";
  6.                         break;

  7.                 case "en.domain.name":
  8.                         require_once "LocalSettings_en.php";
  9.                         break;
  10.                 default:
  11.                         echo "This wiki is not available. Please go to the official forum - http://bdmv.info/snow. Or, welcome to visit one the these wikimedia - zh.bdmv.info or en.bdmv.info.";
  12.                         exit(0);
  13.         }
Copy the Code
Don't forget to fix the $wgServer parameter to applicable domain - zh.domain.name or en.domain.nam of your two localsettings (like LocalSettings_zh.php) .
We will hope to control the individual mediawik by lighttpd config in the future.
If you really be paitent to follow the steps over here, I congrulate you that you can use the full function of multi-language mediawiki at least, and I will tell guys more detail to optimize the midiawikis.

Step 6 : Change the Full Web Address to the Short Url

We refer offcial document to enter this site to get all the information automatically.

For example,


Add the parameters of above first block  to the end of the function - $HTTP["host"] == "zh.domain.name" { }, like the below picture


Btw, people can edit another log file to debug this specific sub-domain like above picture the first four lines, if any issue is happened.
And if your server have any other file system is working and you don't want the wiki redirect rule to inflence other web service, you can add an execption like below example
  1. static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
  2. url.redirect = ( "^/(?!snowiki|other_folders|robots\.txt|favicon\.ico)(.*)" => "/snowiki" )
Copy the Code
If the steps execute successfully , the short url will work fine
It mean the wiki items [ http://zh.domain.name/snowiki/index.php?title=首頁 ] will automatically become to [ http://zh.bdomain.name/snowiki/首頁 ].

Step 7: Enable the Interwiki and Edit the Interwiki Data
(Troubleshooting, someimes this plugin may not work fine, I am very sorry <(_ _)>)
Because of we install the multi-language english and Chinese mediawiki, we can refer the Interwiki guide to link pages of the two mediawiki
Although mediawiki tarball archived the interwiki extension, we steill need enable this extension when we want to edit the interwiki in the Special pages.
Please add the below parameter to your both two mediawiki localsettings.
  1. $wgGroupPermissions['sysop']['interwiki'] = true;
Copy the Code


After we enable the interwiki extension, go to the Special:Interwiki  and add Add an interwiki prefix


Repeat the same steps to add two interwiki data of both multi-language mediawiki


Fianlly, we need edit ./languages/Names.php to line the interwiki prefix we add to the correct side bar sentence.


The last version of mediawiki seems has some issue of interwiki...debuging
I find the new interwiki in version mediawiki may not run successfully, it show some error message.
But, when I try to upgrade the old version mediawiki to the last version, the interwiki is no problem.
The steps of installing the interwiki is correct in the theory, I will be continued checking this problem...sorry
Guys can refer the below example to know the result of successful installing the interwiki.

http://en.bdmv.info/snowiki/OVH
http://zh.bdmv.info/snowiki/OVH

Step 8 : Save The Backup of Your Mediawiki

Before we hope to start editing mediawiki or do any upgrade of mediawiki, I hope we should save the backup of the file system and database first.
Because of the detabase size of my mediawiki is still small, I consider install a cloud client of Copy and sync the database to another another server by Copy.
Copy's sync app can both support linux and windows os, that is why I select this cloud to save the backup.

Refer this tutorial can install the x2go to the ubuntu server, and I will select to open a new terminal in desktop environment.
If you don't wnat to build the desktop environment, copy still can work in the terminal (CLI), people can create a new screen and type the specified command to active the sync,
Besides guys need create a new free member in Copy, you need to download the linux client or transfer the linux from another host to your linux platform manually , it is inconvenient...  

Nagivate the web browser (Firefox/Googlee Chrome...etc) to Copy's website and you can get the free space after you create a new account,
Welcome to use my Referal link to register, then you and me both will get emore 5GB space bones after you confilm the mail and install the client in your computer. \( ^∀^)/  

Then extract the archive to a location you like and use terminal run the commandline - ./CopyAgent to open the user interface
If you don't wnat to buile the desktop environment, I also try to use CLI to excute copy's sync client, that is easy, too. you just need to create a new screen before type the below command.
Type the command like below example then the app can run-time auto sync.
  1. sudo ./CopyConsole -username=[your_login_account] -password=[your_login_password] -root=[/home/account/location]
Copy the Code



After the sync finish, the terminal will show the message - All files up to date.Keep the screen in the background, the copy's client can do sync in real time by crontab's mission.
Guys can read the readme to get more information by official document.
If you can't install the web browser, you can refer this tutorial to install chrome in ubuntu  server.





Create a new shell script to dump the database. For example, a new script - backup.sh
  1. #!/bin/sh
  2. /etc/init.d/lighttpd stop
  3. nice -n 19 mysqldump -u username -ppassword --default-character-set=binary database_name | nice -n 19 gzip -9 > /home/account/copy/$(date '+%Y-%m%d-%H%M').database_name.sql.gz
  4. /etc/init.d/lighttpd start
Copy the Code
The folder - copy set to the sync location of Copy, so I can add a new job to crontab.
Cron is the time-based job scheduler in Unix-like computer operating systems, if you want to save the backup everyday, you can add a new job to crontab like below picture. The cron will save the backup in next morning at 3 o'clock inthe furture.
  1. sudo vi /etc/crontab
Copy the Code



After you do any edit of your crontab file, plese restart the cron
  1. sudo /etc/init.d/cron restart
Copy the Code

Btw, if you want to import the database to another server  you save to the cloud  (moving your mediawiki ), you can type the command to import that database to mysql after you create the mysql database and grant the same premission of the same username  to the database using the same database name ( the same database name and user name is easier to move your mediawiki).
  1. mysql -u [userid] -p [databasename] < dbdump.sql
Copy the Code
For example of the information I told of Step2, we can type the command like below.
  1. mysql -u bdmv -p wiki < dbdump.sql
Copy the Code
If you want get more detail information about mysqldump and importing step, people can refer the official document - Manual:Backing_up_a_wiki Manual:Moving_a_wiki Restoring_a_wiki_from_backup.

Step 9 : Upgrade Your Mediawiki
Before you do any steps of upgrading, please save the backup of your mediawiki first, whever your database or filesy stem.
If you don't refer wiki family to install mupti-language mediawiki, you can refer this document to run the update script to upgrade, it may upgrade successfully.
Because of  the mediawiki of mine is multi-language, I need to add a new script to call that updata.php file. The wiki family describe the information in detail.

Add a new php file update_subdomain.php and a new shell script update_wikifarm.sh
  1. <?php
  2. $sub = $argv[1]; //$argv gets commandline arguements

  3. // set domain name
  4. $_SERVER['SERVER_NAME'] = $sub . '.domain.org';

  5. echo '--------------------------------------
  6. Running update.php for ' . $sub . '.domain.org
  7. --------------------------------------
  8. ';
  9. include("/var/www/snowiki/maintenance/update.php");
Copy the Code
  1. #!/bin/bash

  2. subdomains=( zh en )

  3. for sub in ${subdomains[@]}
  4.   do
  5.     php update_subdomain.php $sub
  6.   done
Copy the Code
The location of update_subdomain.php is standard - /var/www/snowiki/maintenance/update.php, if the folder name of your mediawiki file system is not snowiki, please change that location  as appropriate.
And, the sudomain of this tutorial are zh and en, if you select othr  sub-domain, please change the parameter as appropriate

Before we upgrade the files ystem, we need to download the last mediawiki tarball and extract it to web root directory (ex: /var/www/)
Move the uploaded data (ex: images) 、 the local settings (ex: LocalSettings_en.php and LocalSettings.php and LocalSettingsphp) 、skins ( if you use the default skin, you don't need to move the files to new version mediawiki) 、 extensions and any you ever edit the files of the file system to the new version mediawiki,
then we can run the shell to upgrade the mediawiki.
Some special situation like the original mediawiki version is too old...etc, I suggest people read the official document to check your situation in detail.

Upgrade your multi-language mediawiki
  1. chmod ug+x update_wikifarm.sh update_wikifarm.sh && sudo bash update_wikifarm.sh
Copy the Code
If you don't save the Name.php file, after upgrading the mediawiki, please remember to edit languages/Name.php to math the interwiki prefix.

When I upgrade the mediawiki, I confront with a issue. Until now I still don't assure forcing to edit the cache type is the correct step.
If anyone is interested in the problem, you can see this thread.




Reference:
http://www.mediawiki.org/wiki/Manual:Short_URL
http://shorturls.redwerks.org/?url=http%3A%2F%2Fbdmv.info%2Fsnowiki%2Findex.php%3Ftitle%3D%25E9%25A6%2596%25E9%25A0%2581
http://www.mediawiki.org/wiki/Manual:Short_URL/wiki/Page_title_--_Lighttpd_rewrite--root_access
http://www.mediawiki.org/wiki/Manual:Short_URL/Apache
http://www.mediawiki.org/wiki/Manual:$wgArticlePath
http://stackoverflow.com/questions/3654765/apache-htaccess-file-on-lighttpd

Module mod_auth - Using Authentication http://redmine.lighttpd.net/projects/1/wiki/Docs_ModAuth
Upload security https://www.mediawiki.org/wiki/Manual:Security#Upload_security

MediaWiki ShortURL Builder http://shorturls.redwerks.org/
Manual:Wiki family https://www.mediawiki.org/wiki/Manual:Wiki_family
Manual:Short URL https://www.mediawiki.org/wiki/Shorturl
Manual:Interwiki http://www.mediawiki.org/wiki/Manual:Interwiki
Extension:Interwiki http://www.mediawiki.org/wiki/Extension:Interwiki

Manual:Backing_up_a_wiki http://www.mediawiki.org/wiki/Manual:Backing_up_a_wiki
Manual:Moving_a_wiki http://www.mediawiki.org/wiki/Manual:Moving_a_wiki
Manual:Restoring_a_wiki_from_backup http://www.mediawiki.org/wiki/Manual:Restoring_a_wiki_from_backup

You have to log in before you can reply Login | register now

Archiver|Cell Phone|BDMV.INFO

GMT+8, 2024-3-29 03:07 , Processed in 0.022844 second(s), 5 queries , Xcache On.

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

Top