Difference between revisions of "Mediawiki installation"

From Biowikifarm Metawiki
Jump to: navigation, search
(MediaWiki upgrading)
 
(67 intermediate revisions by 6 users not shown)
Line 1: Line 1:
An overview and record of strategies to install mediawiki the first time, and maintain and upgrade it.
+
Todo
 +
SemanticFormsInputs
  
See also [[Debian installation]] for the underlying server, [[Mediawiki Development]] for links to software documentation etc.
+
An overview and record of strategies to install mediawiki the first time, and maintain and upgrade it. See also:
 +
* [[Debian installation]] for the underlying server,
 +
* [[Mediawiki on biowikifarm]] for a brief introduction to the present configuration/installation
 +
* [[Mediawiki maintenance]]
 +
* [[Mediawiki Development]] for links to software documentation etc.
 +
* See also in [[:category: MediaWiki]] or at the subpages: {{Special:PrefixIndex/{{PAGENAME}}/}}
  
 +
 +
__TOC__
  
 
==First time MediaWiki installation==
 
==First time MediaWiki installation==
  
The first installation was made under mediawiki 1.14. We decided to directly follow the Wikipedia versions by checking out the Trunk revisions. Following [http://www.mediawiki.org/wiki/Download_from_SVN]:
+
Basics: We want to run multiple mediawiki instances from a single software source. Our preferred method uses a mixture of local files in a var/www subfolder (LocalSettings.php, the config and image folder) with the rest of mediawiki files and folders being represented by symbolic links (largely following these [http://dfwlpiki.dfwlp.org/index.php/Advanced_Guide_to_Installing_Multiple_MediaWiki_Sites instructions]; see for a [http://www.steverumberg.com/wiki/index.php?title=WikiHelp_-_Method_Two page probably equivalent to our method] but not used by us). We use "media" as folder name instead of "images"; some folders within images/media need to be writable. The config folder must be writable to www-data if setup is to be run (usually we do not run it, but copy). <!-- FROM OLD SETUP, rather trivial:
sudo mkdir /usr/share/mediawiki; cd /usr/share/mediawiki
+
  cd /var/www/wiki-template/; sudo chmod 755 config
  # Checking out head revision for main and extensions
+
  sudo mv images media; sudo chmod 777 media
  sudo svn checkout http://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3
+
cd /var/www/wiki-template/media/; sudo mkdir archive; mkdir thumb; sudo mkdir temp
  sudo svn checkout http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions
+
sudo chmod 755 archive; sudo chmod 755 thumb; sudo chmod 755 temp
 +
-->
 +
 
 +
===Software needed===
 +
 
 +
<source lang="bash">
 +
# image thumbs and video thumbs
 
  sudo apt-get install imagemagick librsvg2-2 librsvg2-bin
 
  sudo apt-get install imagemagick librsvg2-2 librsvg2-bin
 +
sudo apt-get install ffmpeg ffmpeg2theora
 +
# for graphviz / semantic result formats:
 +
sudo apt-get install graphviz
 +
</source>
  
<small>Notes: "phase3" contains the main application, "extensions" the extension code. (Alternative for a more fixed version would be: svn checkout http://svn.wikimedia.org/svnroot/mediawiki/branches/REL1_13/phase3).</small>
+
<small>(When newer version of ImageMagick is needed, see [[Upgrading Imagemagick to a current version]]. Currently working ok with Debian 6 version)</small>
  
Also, for testing subversion updates, we checkout the wiki a second time into a staging folder:
+
===Installing mediawiki from git (1.20 and later)===
sudo mkdir /usr/share/mediawikistaging; cd /usr/share/mediawikistaging
+
sudo svn checkout http://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3
+
sudo svn checkout http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions
+
  
We want to run multiple mediawiki instances on one server. We created a special, "mixed" form of linking, where the LocalSettings.php, the config and image folder are local, and the rest is linked, following instructions [http://dfwlpiki.dfwlp.org/index.php/Advanced_Guide_to_Installing_Multiple_MediaWiki_Sites here] (an [http://booleandreams.wordpress.com/2007/06/12/running-multiple-instance-of-mediawiki-on-the-same-server-using-the-same-source-code/ alternative method] would probably create problems with the maintenance scripts). Later we detected a [http://www.steverumberg.com/wiki/index.php?title=WikiHelp_-_Method_Two page probably equivalent to our method] (its source?) which may be helpful if problems should arise (but we did not use it yet). We created this mixed linked/local for a "/var/www/wiki-template" folder:
+
Main source: [http://www.mediawiki.org/wiki/Download_from_Git mediawiki.org: Download from Git]. See also [https://gerrit.wikimedia.org/r/#/admin/projects/ overview of wikimedia projects in Git].
  
md /var/www/wiki-template; cd /var/www/wiki-template/
+
'''IMPORTANT CHANGE in comparison to earlier subversion setup: we directly clone all extensions into the /extension folder, instead of cloning elsewhere and then symlinking.'''
# it is important not to add any further "/" anywhere:
+
sudo ln -s /usr/share/mediawiki/phase3/* .
+
sudo rm -rf config
+
sudo cp -vpRP /usr/share/mediawiki/phase3/config .
+
sudo rm -rf images ## may have changed since, check
+
sudo cp -vpRP /usr/share/mediawiki/phase3/images .
+
  
For installation, we need to make the config folder writable by the webserver, for media files some folders within images need to be writable. Also we renamed "images" to "media"
+
: Memo: use "git tag -l | sort -V" um tags sortiert anzuzeigen
  
cd /var/www/wiki-template/; sudo chmod 755 config
+
===First installation only: Create git-clone on biowikifarm===
sudo mv images media; sudo chmod 777 media
+
cd /var/www/wiki-template/media/; sudo mkdir archive; mkdir thumb; sudo mkdir temp
+
sudo chmod 755 archive; sudo chmod 755 thumb; sudo chmod 755 temp
+
  
To enable the display of svn revision numbers on Special:Version pages (as can be seen on the Wikimedia foundation wikis), one also must create a .svn link in each wiki folder from pointing to .svn in phase3.
+
A biowikifarm git-clone (normal, not bare) of the WMF core and extension repo is created.
  
'''Change Owner of media folder; NOT DONE''', seems to be not necessary: (user "www-data" = apache user, confirmed to be present on Debian and most parts of apache run under this, ps -ef): chown www-data: media/
+
<syntaxhighlight lang="bash" style="font-size:105%">
 +
# 1. FIRST create a biowikifarm git-clone (non-bare) for mediawiki-core and mw-extensions (submodules):
 +
  cd /usr/share; sudo mkdir mw-wmf-clone; cd /usr/share/mw-wmf-clone
 +
  sudo git clone https://gerrit.wikimedia.org/r/p/mediawiki/core.git core
 +
  sudo git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions.git extensions
 +
  sudo git clone https://gerrit.wikimedia.org/r/p/mediawiki/skins.git skins # new!
 +
  cd /usr/share/mw-wmf-clone/extensions; sudo git submodule update --init --recursive
 +
  cd /usr/share/mw-wmf-clone/skins; sudo git submodule update --init --recursive
 +
  # Note: with after init, one can use "git foreach". Example:
 +
  #  git submodule foreach 'echo $path `git rev-parse HEAD`'
 +
  #  will show the path and currently checked out commit for each submodule.
 +
</syntaxhighlight>
  
----
+
===Update git and export version to folder===
 +
 
 +
This section is identical to the updating, see [[Mediawiki maintenance#mw core and base extensions|Mediawiki maintenance > MediaWiki version upgrading (core and wikimedia extensions]]. SVN is separate however!
 +
 
 +
=== Installing extensions from Local subversion ===
 +
 
 +
Some extensions unavailable in Wikimedia git exist in our local svn:
 +
 
 +
<syntaxhighlight lang="bash">
 +
# 4. ONLY FOR FIRST TIME CREATION of SVN-Extensions:
 +
# Insert the local-svn-managed extensions into the same folder:
 +
# Note: www-data cannot create the folders, but must be able to write the updates (svn-post-commit hook) -> temp folder
 +
# Remaining Problem: when a new svn folder is added after this initial setup to the local subversion repo,
 +
#  that folder must manually chown to www-data; else svn co post-commit errors will occur.
 +
# e.g.: wikipath="/usr/share/mediawiki20/"
 +
cd "${wikipath}"
 +
sudo mkdir TEMP-LOCAL-svn; ## temp folder
 +
sudo svn checkout file:///var/lib/svn/LocalSVNextensions ./TEMP-LOCAL-svn
 +
sudo chown -R  www-data:www-data ./TEMP-LOCAL-svn
 +
sudo mv ./TEMP-LOCAL-svn/* ./extensions;
 +
sudo rm ./extensions/.svn -R;
 +
sudo mv ./TEMP-LOCAL-svn/.svn ./extensions
 +
sudo rm ./TEMP-LOCAL-svn -r
 +
</syntaxhighlight>
 +
 
 +
===Installation of additional extensions from other sources===
 +
 
 +
<syntaxhighlight lang="bash">
 +
# 5. Installation of additional extensions from other sources
 +
### None yet.
 +
</syntaxhighlight>
 +
 
 +
===Additional tasks===
 +
 
 +
<syntaxhighlight lang="bash">
 +
# 6. Finishing touches. Widgets needs a writable folder:
 +
cd ${wikipath}
 +
sudo chown -R  www-data:www-data ./extensions/Widgets/compiled_templates;
 +
sudo chmod g+w -R  ./extensions/Widgets/compiled_templates;
 +
# eg. sudo chown -R  www-data:www-data /usr/share/mediawiki20/extensions/Widgets/compiled_templates; sudo chmod g+w -R  /usr/share/mediawiki20/extensions/Widgets/compiled_templates
 +
# Widgets does not contain all necessary code (-> Warning: require_once(/usr/share/mediawiki20/phase3/extensions/Widgets/smarty/Smarty.class.php): failed to open stream: No such file or directory...)
 +
# In the absence of installation instructions, using previously saved code:
 +
sudo cp -r /usr/share/mw-missing-code/Widgets/smarty ./extensions/Widgets
 +
sudo cp -r /usr/share/mw-missing-code/Widgets/googlecode ./extensions/Widgets
 +
<!--
 +
# NOTE: in Dec. 2012 the parts were originally copied as seen below:
 +
sudo mkdir /usr/share/mw-missing-code
 +
sudo mkdir /usr/share/mw-missing-code/Widgets
 +
sudo cp -r /usr/share/mediawikistaging/ext-tagged-release/Widgets/smarty /usr/share/mw-missing-code/Widgets
 +
sudo cp -r /usr/share/mediawikistaging/ext-tagged-release/Widgets/googlecode /usr/share/mw-missing-code/Widgets
 +
-->
 +
</syntaxhighlight>
 +
 
 +
 
 +
===Email===
  
'''Email:''' Setting up the email functions requires either a local server, or for external server setting [http://www.mediawiki.org/wiki/Manual:$wgSMTP $wgSMTP]. It also first requires to install the Mail.php functionality:
+
Setting up the email functions requires either a local server, or for external server setting [http://www.mediawiki.org/wiki/Manual:$wgSMTP $wgSMTP]. It also first requires to install the Mail.php functionality:
 
  sudo apt-get install php-mail php-net-smtp
 
  sudo apt-get install php-mail php-net-smtp
 
then add to LocalSettings.php:
 
then add to LocalSettings.php:
 +
 +
<source lang="php">
 
  ini_set("include_path", ".:$IP:$IP/includes:$IP/languages:/usr/share/php/:/usr/share/php/PEAR/");
 
  ini_set("include_path", ".:$IP:$IP/includes:$IP/languages:/usr/share/php/:/usr/share/php/PEAR/");
 
  $wgSMTP = array(
 
  $wgSMTP = array(
Line 55: Line 128:
 
  'password' => "xxx123xxx123xxx123"
 
  'password' => "xxx123xxx123xxx123"
 
  );
 
  );
 +
</source>
 +
 +
Update 2017: We use PEAR (must be installed, see mediawiki manual), and had to use the following, slightly more complex install (probably due to updating rather than fresh install):
 +
sudo pear channel-update pear.php.net; sudo pear install mail pear/Auth_SASL net_smtp
  
 
==Cloning a new wiki==
 
==Cloning a new wiki==
 +
 +
NOTE: some of the following instructions are OLD. THE BETTER PAGE FOR CREATING MEDIAWIKI INSTANCES IS: [[Create a new mediawiki instance]]
 +
 +
-----------
  
 
Any code above needs to be run only the first time. From then on, the template can be reused to clone instances (where "NEW-WIKI" is replaced with the name for your wiki):
 
Any code above needs to be run only the first time. From then on, the template can be reused to clone instances (where "NEW-WIKI" is replaced with the name for your wiki):
 +
<source lang="bash">
 +
## for new virtual host:
 +
cd /var/www/; sudo cp -r wiki-template NEW-hostpath
 +
cd /var/www/NEW-hostpath/w; sudo chmod a+w cache; sudo chmod a+w media
 +
## for new wiki within virtual host:
 +
cd /var/www/; sudo cp -r wiki-template/w hostpath/newwiki
 +
cd /var/www/hostpath/newwiki; sudo chmod a+w cache; sudo chmod a+w media
 +
## if using installer, also: sudo chmod a+w config;
 +
</source>
 +
A useful template wiki as of 2014 is /var/www/v-ztemplate/w
  
  cd /var/www/; sudo cp -r wiki-template NEW-Wiki
+
Current template may require: (wiki may be direct in biowikifarm, in v-host, or nested 1 further)
  cd /var/www/NEW-Wiki; sudo chmod a+w config; sudo chmod a+w cache; sudo chmod a+w media
+
  sudo chown www-data:www-data /var/www/*/media -R
 +
sudo chown www-data:www-data /var/www/*/*/media -R
 +
  sudo chown www-data:www-data /var/www/*/*/*/media -R
 +
sudo chmod 775 /var/www/*/media -R
 +
sudo chmod 775 /var/www/*/*/media -R
 +
sudo chmod 775 /var/www/*/*/*/media -R
  
followed by the install process in a web browser (<nowiki>http://..../NEW-Wiki/config/index.php</nowiki>)
+
To make all LocalSettings writable:
 +
sudo chmod 775 /var/www/*/LocalSettings.php
 +
sudo chmod 775 /var/www/*/*/LocalSettings.php
 +
sudo chmod 775 /var/www/*/*/*/LocalSettings.php
  
Short note for later installs: do not forget to set '''localhost:8088''' with port and '''UTF-8 character set'''. Add root superuser, the wikiuser has very limited rights (table insert to delete, create temp tables only, ''not including'' create table privileges).
+
To reset to readonly:
 +
sudo chmod 640 /var/www/*/LocalSettings.php
 +
sudo chmod 640 /var/www/*/*/LocalSettings.php
 +
sudo chmod 640 /var/www/*/*/*/LocalSettings.php
  
Full notes for settings made on the web forms of the MediaWiki installation: For the DPG (society of phytopathologists in Germany): Name=DPG, contact email gh, language de, License: Creative Commons, choose non-commercial, share-alike, Admin name: WikiSysop, (password noted separate), caching memcached 127.0.0.1:11211, email options left default (or user-to-user disabled), DB config: MySQL, localhost:8088 (the port on which we operate mysql), databasename: pmedwiki, user name wikiuser, (password noted separate). adding root credentials so that wikiuser and tables can be created (wikiuser has insufficient rights). No database table prefix (originally we DID use prefixes and a single db, however, that prevents to ever use the single-sign-on mechanism...), engine=InnoDB, character set ''changed to UTF-8''. Click Install, move LocalSettings.php to the parent directory, remove the config folder:
+
It is possible to use the install process in a web browser (<nowiki>http://..../NEW-Wiki/config/index.php</nowiki>). However, more usually, the database is copied in mysql (todo: go to z_en_template, go to Operations, use copy option, then go to mysql-localhost, privileges, go to wiki user, add privileges for the new database.
  
 +
Short note for later installs:
 +
* '''Set license first''' (setting it will void other entries)
 +
* set '''localhost:8088'''
 +
* set database name and '''UTF-8 character set'''.
 +
* For db creation do not use root, but personal mysql admin account.
 +
 +
Full notes for settings made on the web forms of the MediaWiki installation: For the DPG (society of phytopathologists in Germany): Name=DPG, contact email gh, language de, License: Creative Commons, choose non-commercial, share-alike, Admin name: WikiSysop, (password noted separate), caching memcached 127.0.0.1:11211, email options left default (or user-to-user disabled), DB config: MySQL, localhost:8088 (the port on which we operate mysql), databasename: pmedwiki, user name wikiuser, (password noted separate). adding root credentials so that wikiuser and tables can be created (wikiuser has insufficient rights). No database table prefix (originally we DID use prefixes and a single db, however, that prevents to ever use the single-sign-on mechanism...), engine=InnoDB, character set ''changed to UTF-8''. Click Install, move LocalSettings.php to the parent directory, remove the config folder:
 +
<source lang="bash">
 
  cd /var/www/NEW-Wiki/; sudo mv config/LocalSettings.php .; sudo rm -rf config
 
  cd /var/www/NEW-Wiki/; sudo mv config/LocalSettings.php .; sudo rm -rf config
 +
</source>
 +
  
For each wiki add to the virtual host configuration (e.g. to <code>/etc/apache2/sites-available/default</code>):
+
Procedure as script by AP (not entirely tested):
 +
<blockquote>
 +
<syntaxhighlight lang="bash">
 +
#!/bin/bash
 +
# http://biowikifarm.net/meta/Mediawiki_installation#Cloning_a_new_wiki
 +
wiki_template="./v-ztemplate"
 +
new_wiki_folder="./v-species"
 +
wiki_script_folder="./zt" # default ./w
 +
wiki_config_folder="./mw-config" # default ./w
 +
web_dir="/var/www"
 +
do_web_installation="" # "" is false
  
Alias /NEW-Wiki-VIRTUAL /var/www/NEW-WIKI/index.php
+
cd "${web_dir}"
+
# copy wiki template
and restart Apache2 gracefully:
+
sudo cp -r "${wiki_template}" "${new_wiki_folder}"
 +
# go to wiki folder
 +
cd "${web_dir}/${new_wiki_folder}";
 +
# check if different script folder necessary
 +
if ! [ -d  "${web_dir}/${new_wiki_folder}/${wiki_script_folder}" ];then
 +
  sudo mv "${web_dir}/${new_wiki_folder}/w" "${web_dir}/${new_wiki_folder}/${wiki_script_folder}"
 +
fi
 +
# check rights of folders
 +
cd "${web_dir}/${new_wiki_folder}/${wiki_script_folder}"
 +
sudo chmod a+w cache;
 +
sudo chmod a+w media;
 +
sudo chown www-data:www-data "./media" -R
 +
sudo chmod 775      "./media" -R
  
sudo /usr/sbin/apache2ctl -k graceful
+
if [ "${do_web_installation}" ];then
# or not graceful: sudo /usr/sbin/apache2ctl -k restart
+
  # check if the mw-config directory for first install is there
   
+
  if ! [ -d "${web_dir}/${new_wiki_folder}/${wiki_script_folder}/${wiki_config_folder}" ];then
For each wiki using ShortURLs, the robot.txt must be updated.
+
    sudo cp /usr/share/mw-wmf-clone/core/mw-config/* ./mw-config/
 +
    sudo mkdir "${web_dir}/${new_wiki_folder}/${wiki_script_folder}/"
 +
    sudo chown www-data:www-data "${web_dir}/${new_wiki_folder}/${wiki_script_folder}/${wiki_config_folder}" -R
 +
    if [ -e "${web_dir}/${new_wiki_folder}/${wiki_script_folder}/LocalSettings.php" ];then
 +
      # installation script won't start if LocalSettings.php is there
 +
      # backup file with date suffix
 +
      modified_date=`stat --format="%y" "${web_dir}/${new_wiki_folder}/${wiki_script_folder}/LocalSettings.php" | awk '{ print $1 }'`
 +
      sudo mv "${web_dir}/${new_wiki_folder}/${wiki_script_folder}/LocalSettings.php" "${web_dir}/${new_wiki_folder}/${wiki_script_folder}/LocalSettings.php.${modified_date}"
 +
    fi
 +
  sudo chmod a+w "${wiki_config_folder}";
 +
  fi
 +
fi
  
Some extensions need execution of a sql command for each db (where "DBNAME" and "DBUSER" are replaced with actual db name and user) (<code>ls /var/www/NEW-Wiki/extensions/*.sql</code>):
+
################################################
 +
# step: configure web server (nginx)
 +
################################################
  
  mysql -u USER -p --database=studienstiftungswiki < /usr/share/mediawiki/extensions/ConfirmAccount/ConfirmAccount.sql
+
################################################
   mysql -u USER -p --database=studienstiftungswiki < /usr/share/mediawiki/extensions/OpenID/openid_table.sql
+
# step: wiki installation
  mysql -u USER -p --database=studienstiftungswiki < /usr/share/mediawiki/extensions/TitleKey/titlekey.sql
+
# if you install a single Wiki use http://your-url.com/wgArticlePath/mw-config/index.php
  echo "CREATE VIEW dpl_clview AS SELECT IFNULL(cl_from, page_id) AS cl_from, IFNULL(cl_to, '') AS cl_to, cl_sortkey FROM page LEFT OUTER JOIN categorylinks ON page_id=cl_from;" | mysql -u USER -p DBNAME
+
# OR
 +
# copy a wiki database template, (adjust another) LocalSettings.php and run as final step:
 +
#   sudo -u www-data php ./maintenance/update.php  --quick --conf ./LocalSettings.php
 +
################################################
 +
# step: update database
 +
################################################
 +
cd "${web_dir}/${new_wiki_folder}/${wiki_script_folder}";        sudo -u www-data php ./maintenance/update.php  --quick --conf ./LocalSettings.php
 +
</syntaxhighlight>
 +
</blockquote>
  
echo "CREATE VIEW dpl_clview AS SELECT IFNULL(cl_from, page_id) AS cl_from, IFNULL(cl_to, '') AS cl_to, cl_sortkey FROM page LEFT OUTER JOIN categorylinks ON page_id=cl_from;" | mysql -u mb-gh -p --database=studienstiftungswiki
+
For each wiki add to the virtual host configuration to (Originally apache, but as of 2012 to nginx) and restart:
 +
<source lang="bash">
 +
# sudo /usr/sbin/apache2ctl -k graceful && sudo service nginx restart && sudo service php5-fpm restart
 +
sudo service apache2 restart && sudo service nginx restart && sudo service php5-fpm restart
 +
</source>
  
Similar tables would be needed for the '''OAI (OpenArchiveInitiative) extension'''. The documentation is very poor so that '''THIS IS NOT YET APPLIED AND THE EXTENSION DISABLED FOR THE TIME BEING!''' ARE ALL TABLES COVERED BELOW?
+
'''For each wiki using ShortURLs, the robot.txt must be updated!'''
# mysql -u USER -p DBNAME < /usr/share/mediawiki/extensions/OAI/oaiaudit_table.sql 
+
# mysql -u USER -p DBNAME < /usr/share/mediawiki/extensions/OAI/oaiharvest_table.sql 
+
# mysql -u USER -p DBNAME < /usr/share/mediawiki/extensions/OAI/oaiuser_table.sql 
+
# mysql -u USER -p DBNAME < /usr/share/mediawiki/extensions/OAI/update_table.sql
+
 
+
To simplify the setup, we have extracted the common settings from LocalSettings.php into a file called MediaWikiCommonSettings.php directly in the www-root. Usually, because of the manual change to MediaWikiCommonSettings.php, we manually modify a template LocalSettings.php from any wiki and use it instead of the one created by the install process.
+
  
Note: virtual wiki path in ''lower case'' is preferable, because it helps to highlight the page title (having Title-Case)!
+
Some extensions need execution of a sql command for each db (where "DBNAME" and "DBUSER" are replaced with actual db name and user) (<code>ls /var/www/NEW-Wiki/extensions/*.sql</code>):
 +
<source lang="bash"> 
 +
  mysql -u USER -p --database=xwiki < /usr/share/mediawiki/extensions/OpenID/openid_table.sql
 +
  mysql -u USER -p --database=xwiki < /usr/share/mediawiki/extensions/TitleKey/titlekey.sql
 +
</source>
 +
 
 +
ConfirmAccount from /usr/share/mediawiki/extensions/ConfirmAccount/ConfirmAccount.sql would create 2 tables: "account_requests", "account_credentials". It is necessary only in the shared sign-on wiki (for us this is metawiki). OpenID creates single table "user_openid". Titlekey creates single table "titlekey". Note: We no longer add the DPL views. <!-- DPL is no longer supported in newer wikis, old had:  echo "CREATE VIEW dpl_clview AS SELECT IFNULL(cl_from, page_id) AS cl_from, IFNULL(cl_to, '') AS cl_to, cl_sortkey FROM page LEFT OUTER JOIN categorylinks ON page_id=cl_from;" | mysql -u USER -p --database=studienstiftungswiki -->
 +
 
 +
To simplify the setup, we have extracted the common settings from LocalSettings.php into a file called MediaWikiCommonSettings.php directly in the www-root. Usually, because of the manual change to MediaWikiCommonSettings.php, we manually modify a template LocalSettings.php from any wiki and use it instead of the one created by the install process.
  
Notes: Using "commons" for image is problematic because easily confused with wikipedia (and the desirable WP interwiki link). "Media" is bad because existing "media:" prefix. Currently, we use m script and openmedia rewrite path inside species-id as a media repository.
+
Note: virtual wiki path is preferable in ''lower case'' because it helps to highlight the page title (having Title-Case)!
  
 
==Configuration after setup==
 
==Configuration after setup==
Line 109: Line 270:
 
* Timezone settings added: ( #Set Default Timezone: // $wgLocaltimezone="Europe/Berlin"; // $wgLocalTZoffset = +120; // putenv("TZ=$wgLocaltimezone");)
 
* Timezone settings added: ( #Set Default Timezone: // $wgLocaltimezone="Europe/Berlin"; // $wgLocalTZoffset = +120; // putenv("TZ=$wgLocaltimezone");)
 
* Security information on preventing editing by anonymous users and user-creation options under [http://www.mediawiki.org/wiki/Preventing_Access Preventing_Access]; we added following to MediaWikiCommonSettings.php:
 
* Security information on preventing editing by anonymous users and user-creation options under [http://www.mediawiki.org/wiki/Preventing_Access Preventing_Access]; we added following to MediaWikiCommonSettings.php:
 +
<syntaxhighlight lang="php">
 +
$wgEnableUploads  = true; # (Make sure the php.ini settings are correct, see above)
 +
$wgMaxImageArea = 5e7; # Default is 1.25e7.
 +
  # (support thumb generation for large line drawings which may only be 1.4 MB but larger 5000 px)
 +
# Disable anonymous editing
 +
$wgGroupPermissions['*']['edit'] = false;
 +
# Prevent new user registrations except by sysops
 +
$wgGroupPermissions['*']['createaccount'] = false;
 +
# possible fix to enable JavaScript to function also under https AND http.
 +
$wgProto = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
 +
$wgServer = $wgProto."://the-wiki-url.net";
  
$wgEnableUploads  = true; # (Make sure the php.ini settings are correct, see above)
+
</syntaxhighlight>
$wgMaxImageArea = 5e7; # Default is 1.25e7.
+
  # (support thumb generation for large line drawings which may only be 1.4 MB but larger 5000 px)
+
# Disable anonymous editing
+
$wgGroupPermissions['*']['edit'] = false;
+
# Prevent new user registrations except by sysops
+
$wgGroupPermissions['*']['createaccount'] = false;
+
 
+
 
(Perhaps see also [http://23rdworld.com/2007/03/30/how-to-make-your-mediawiki-private/ a blog describing this method]). A better method than limiting creation to sysops it the [http://www.mediawiki.org/wiki/Extension:ConfirmAccount ConfirmAccount] extension, which we installed (see extensions below).
 
(Perhaps see also [http://23rdworld.com/2007/03/30/how-to-make-your-mediawiki-private/ a blog describing this method]). A better method than limiting creation to sysops it the [http://www.mediawiki.org/wiki/Extension:ConfirmAccount ConfirmAccount] extension, which we installed (see extensions below).
 
----
 
  
 
==Enabling extensions==
 
==Enabling extensions==
  
The first part, establishing the symbolic links, must be done once for the subversion-managed mediawiki installation. Normally further actions are necessary (LocalSettings.php) for each wiki, but we perform them centrally in MediaWikiCommonSettings.php. Yet some db-specific actions are necessary for some extensions, see at the end. Most extensions are already available through the subversion download. Symbolic links are created to enable selected extensions, initially for:
+
The first part, establishing the symbolic links, must be done only once for the subversion-managed mediawiki installation, since all further wiki installations symlink to the same phase3/extensions folder. Normally further actions are necessary (LocalSettings.php) for each wiki, but we perform them centrally in MediaWikiCommonSettings.php. Yet some db-specific actions are necessary for some extensions, see at the end. Most extensions are already available through the subversion download. Symbolic links are created to enable selected extensions, initially for:
 
+
cd /usr/share/mediawiki/phase3/extensions
+
ln -s ../../extensions/CategoryTree
+
ln -s ../../extensions/CentralAuth
+
ln -s ../../extensions/CentralNotice
+
ln -s ../../extensions/CharInsert
+
ln -s ../../extensions/Cite
+
ln -s ../../extensions/ConfirmAccount
+
ln -s ../../extensions/ConfirmEdit
+
ln -s ../../extensions/CrossNamespaceLinks
+
ln -s ../../extensions/DismissableSiteNotice
+
ln -s ../../extensions/DynamicPageList
+
ln -s ../../extensions/ExpandTemplates
+
ln -s ../../extensions/FlaggedRevs
+
ln -s ../../extensions/Gadgets
+
ln -s ../../extensions/GoogleMaps
+
ln -s ../../extensions/intersection
+
ln -s ../../extensions/Interwiki
+
ln -s ../../extensions/ImageMap
+
ln -s ../../extensions/inputbox
+
# No longer used (now using MediaFunctions): ln -s /usr/share/mediawiki/NonSvnExtensions/ImageSizeInfoFunctions
+
ln -s /usr/share/mediawiki/NonSvnExtensions/LinkedImage
+
# NOT: MakeBot, Makesysop, both now core functionality (although still listed as extension in en/de wikipedia)
+
ln -s ../../extensions/MathStatFunctions
+
ln -s ../../extensions/MediaFunctions
+
ln -s ../../extensions/MultiUpload
+
ln -s ../../extensions/MWSearch
+
ln -s /usr/share/mediawiki/NonSvnExtensions/IdentificationTool
+
ln -s ../../extensions/OAI
+
ln -s ../../extensions/OpenID
+
ln -s ../../extensions/Oversight
+
ln -s ../../extensions/PasswordReset
+
ln -s ../../extensions/ParserFunctions
+
ln -s /usr/share/mediawiki/NonSvnExtensions/RawFile
+
ln -s ../../extensions/Renameuser
+
ln -s ../../extensions/ReplaceText
+
ln -s ../../extensions/SemanticMediaWiki
+
ln -s ../../extensions/SemanticForms
+
ln -s ../../extensions/SharedUserRights
+
# Following two not in subversion:
+
ln -s /usr/share/mediawiki/NonSvnExtensions/ShibbolethAuthentication
+
ln -s /usr/share/mediawiki/NonSvnExtensions/SQL2Wiki
+
ln -s ../../extensions/StringFunctions
+
ln -s ../../extensions/SyntaxHighlight_GeSHi
+
ln -s ../../extensions/TitleKey
+
ln -s ../../extensions/TreeAndMenu
+
 
+
 
+
This is further necessary to self-written extensions such as:
+
ln -s /usr/share/mediawiki/NonSvnExtensions/IdentificationTool
+
ln -s /usr/share/mediawiki/NonSvnExtensions/MetadataHarvester
+
 
+
Only for Key to Nature the following special extensions are linked in:
+
cd /usr/share/mediawiki/phase3/extensions
+
ln -s /usr/share/mediawiki/NonSvnExtensions/AddScriptCss
+
ln -s /usr/share/mediawiki/NonSvnExtensions/StubManager
+
ln -s /usr/share/mediawiki/NonSvnExtensions/VideoFlash
+
 
+
 
+
[http://www.mediawiki.org/wiki/Extension:SyntaxHighlight SyntaxHighlight] needs an additional checkout from a different source:
+
 
+
cd /usr/share/mediawiki/extensions/SyntaxHighlight_GeSHi
+
svn checkout http://geshi.svn.sourceforge.net/svnroot/geshi/trunk/geshi-1.0.X/src/ geshi
+
 
+
The CentralAuth extension needs to create the following tables a single time (file CentralAuth/central-auth.sql, stored here for immediate repetition, but may be obsolete with software updates):
+
<div style="font-size:0.75em">
+
CREATE TABLE globalnames (gn_name varchar(255) binary not null, primary key (gn_name)) TYPE=InnoDB;
+
CREATE TABLE localnames (ln_wiki varchar(255) binary not null, ln_name varchar(255) binary not null, primary key (ln_wiki, ln_name), key (ln_name, ln_wiki)) TYPE=InnoDB;
+
CREATE TABLE globaluser (gu_id int auto_increment, gu_name varchar(255) binary, gu_enabled varchar(14) not null, gu_enabled_method enum('opt-in', 'batch', 'auto', 'admin'), gu_home_db varchar(255) binary, gu_email varchar(255) binary, gu_email_authenticated char(14) binary, gu_salt varchar(16) binary, gu_password tinyblob, gu_locked bool not null default 0, gu_hidden bool not null default 0, gu_registration varchar(14) binary, gu_password_reset_key tinyblob, gu_password_reset_expiration varchar(14) binary, gu_auth_token varbinary(32) NULL, primary key (gu_id), unique key (gu_name), key (gu_email)) TYPE=InnoDB;
+
CREATE TABLE localuser (lu_wiki varchar(255) binary not null, lu_name varchar(255) binary not null, lu_attached_timestamp varchar(14) binary, lu_attached_method enum ('primary', 'empty', 'mail', 'password', 'admin', 'new', 'login'), primary key (lu_wiki, lu_name), key (lu_name, lu_wiki)) TYPE=InnoDB;
+
CREATE TABLE global_user_groups (gug_user int(11) not null, gug_group varchar(255) not null, PRIMARY KEY (gug_user,gug_group), KEY (gug_user), key (gug_group)) TYPE=InnoDB;
+
CREATE TABLE global_group_permissions (ggp_group varchar(255) not null, ggp_permission varchar(255) not null, PRIMARY KEY (ggp_group, ggp_permission), KEY (ggp_group), KEY (ggp_permission)) TYPE=InnoDB;
+
</div>
+
 
+
  
In LocalSettings/CommonSettings, add the following corresponding code at the end '''(requires updating!)''':
+
The CentralAuth extension is difficult to install, although seemingly the only extension supporting single-sign one (users can be shared through shared tables, but sign-ons in browers must be repeated). The initial attempts to use CentralAuth failed. New help is available since, and http://noc.wikimedia.org/conf/highlight.php?file=CommonSettings.php would be an important resource.
  
# EXTENSIONS:
+
In LocalSettings/CommonSettings, add the information for the extensions. The following example may be outdated, check against current file:
# MakeBot, MakeSysop are still listed in en/de wikipedia, but obsolete, now in core!
+
<source lang="php">
$wgUseAjax = true; // needed for CategoryTree
+
  # NEEDS UPDATING - OUT OF DATE VERSIONS PRESENTLY REMOVED!
require_once("$IP/extensions/CategoryTree/CategoryTree.php");
+
</source>
#### DISABLED: (configuration problems) #####require_once("$IP/extensions/CentralAuth/CentralAuth.php");
+
  ##this needs configuration of http://www.mediawiki.org/wiki/Manual:%24wgConf, which must occurs after the specific settings, see
+
require_once("$IP/extensions/CharInsert/CharInsert.php");
+
require_once("$IP/extensions/Cite/SpecialCite.php");
+
+
# ConfirmAccount needs email enabled! Otherwise users can't get their passwords...
+
#### DISABLED #####require_once("$IP/extensions/ConfirmAccount/SpecialConfirmAccount.php");
+
  $wgMakeUserPageFromBio = true; // Set the person's bio as their userpage?
+
  $wgAutoUserBioText = ''; // Text to add to bio pages if the above option is on
+
  $wgAutoWelcomeNewUsers = true;
+
  $wgUseRealNamesOnly = false; // Make the username of the real name? DEFAULT was true
+
  $wgConfirmAccountRejectAge = 30 * 24 * 3600; // 1 month = How long after accounts have been requested/held before they count as 'rejected'
+
  $wgAccountRequestThrottle = 5; // How many requests can an IP make at once; DEFAULT was 1, but this is for firewalled users
+
  $wgAccountRequestMinWords = 3; // Minimum biography specs (original was 50)
+
  $wgAccountRequestToS = false; // Show ToS checkbox
+
  $wgAccountRequestExtraInfo = true; // Show confirmation info fields
+
  # If set, will add {{DEFAULTSORT:sortkey}} to userpages for auto-categories.
+
  # The sortkey will be made be replacing the first element of this array
+
  # (regexp) with the second. Set this variable to false to avoid sortkey use.
+
  $wgConfirmAccountSortkey = true;
+
  $wgConfirmAccountSortkey = array( '/^(.+) ([^ ]+)$/', '$2, $1' );  // this will do {{DEFAULTSORT:firstname, lastname}}
+
  # If ConfirmEdit is installed and set to trigger for createaccount, inject catpchas for requests too?
+
  $wgConfirmAccountCaptchas = false; // DEFAULT was true, but this seems redundant
+
  $wgAllowAccountRequestFiles = false; // Default was false
+
  # $wgGroupPermissions['*']['createaccount'] = false;
+
  # $wgGroupPermissions['bureaucrat']['confirmaccount'] = true;
+
  # $wgGroupPermissions['bureaucrat']['requestips'] = true; // This right has the request IP show when confirming accounts
+
  $wgConfirmAccountNotice = true; // Show notice for open requests to admins? Cached, but may still be expensive for thousands of requests.
+
require_once("$IP/extensions/ConfirmEdit/ConfirmEdit.php" );
+
  # ConfirmEdit configuration:
+
  $wgGroupPermissions['*'            ]['skipcaptcha'] = false;
+
  $wgGroupPermissions['user'        ]['skipcaptcha'] = false;
+
  $wgGroupPermissions['autoconfirmed']['skipcaptcha'] = true;
+
  $wgGroupPermissions['bot'          ]['skipcaptcha'] = true;
+
  $wgGroupPermissions['sysop'        ]['skipcaptcha'] = true;
+
  $wgCaptchaTriggers['edit']          = false;
+
  $wgCaptchaTriggers['create']        = false;
+
  $wgCaptchaTriggers['addurl']        = false;
+
  $wgCaptchaTriggers['createaccount'] = true;
+
  $wgCaptchaTriggers['badlogin']      = true;
+
require_once("$IP/extensions/CentralNotice/CentralNotice.php");
+
require_once("$IP/extensions/CrossNamespaceLinks/SpecialCrossNamespaceLinks.php");
+
require_once("$IP/extensions/DismissableSiteNotice/DismissableSiteNotice.php");
+
#add DynamicPageList Extension, used e.g. for automatic event listing on key2nature. See also: http://semeb.com/dpldemo/
+
require_once("$IP/extensions/DynamicPageList/DynamicPageList2.php");
+
### enabling FlaggedRevs requires many further actions (sql)!
+
  ### include_once("$IP/extensions/FlaggedRevs/FlaggedRevs.php");
+
require_once("$IP/extensions/ExpandTemplates/ExpandTemplates.php");
+
require_once("$IP/extensions/Gadgets/Gadgets.php");
+
+
## GoogleMapsExtension: This may have to be moved to individual wikis or secondary commons files, since it is URL dependend
+
  ## Key for http://www.phytopathology.net/:  
+
  $wgGoogleMapsKey = "ABQIAAAAtIv2htpKQclAQPE21vjSBBSL1aXnaBCy0UI5nOCX2jho6QpXrBTEjwGjkp6B0qEgN34MXgC9JE17Ag";
+
## GoogleMaps temporarily disabled again, it adds huge amounts of JavaScript to each page!
+
## xyyfafxy<xykeopkfdrequire_once("$IP/extensions/GoogleMaps/GoogleMaps.php");
+
+
include_once("$IP/extensions/IdentificationTool/IdentificationTool.php"); /* OUR OWN EXTENSION */
+
require_once("$IP/extensions/ImageMap/ImageMap.php");
+
require_once("$IP/extensions/inputbox/inputbox.php");
+
### DISABLED, undocumented usage, unclear whether conflicting with full DynamicPageList:
+
  ### require_once("$IP/extensions/intersection/DynamicPageList.php");
+
require_once("$IP/extensions/Interwiki/SpecialInterwiki.php");
+
  $wgGroupPermissions['*']['interwiki'] = false;
+
  $wgGroupPermissions['sysop']['interwiki'] = true;
+
  # an additional user group is possible, bureaucrats can assign this:
+
  # $wgGroupPermissions['interwiki']['interwiki'] = true;
+
include_once("$IP/extensions/LinkedImage/LinkedImage.php");
+
require_once("$IP/extensions/MathStatFunctions/MathStatFunctions.php");
+
require_once("$IP/extensions/MultiUpload/SpecialMultipleUpload.php");
+
  ### DISABLED, SQL ADDITIONS NEEDED, NO DOCUMENTATION ON USE:
+
  ### require_once("$IP/extensions/OAI/OAIRepo.php");
+
### OpenID: DISABLED! The libraries are installed, the sql executed, but when enabling and navigating to special pages an error occurs
+
  ### require_once("$IP/extensions/OpenID/OpenID.setup.php");
+
+
require_once("$IP/extensions/ParserFunctions/ParserFunctions.php");
+
## Allow Sysops to reset passwords:
+
require_once("$IP/extensions/PasswordReset/PasswordReset.php");
+
  $wgGroupPermissions['sysop']['passwordreset']  = true;
+
require_once("$IP/extensions/RawFile/RawFile.php");
+
require_once("$IP/extensions/Renameuser/SpecialRenameuser.php" );
+
include_once("$IP/extensions/ReplaceText/ReplaceText.php");
+
+
##SEMANTIC MEDIAWIKI:
+
include_once("$IP/extensions/SemanticMediaWiki/includes/SMW_Settings.php");
+
include_once("$IP/extensions/SemanticForms/includes/SF_Settings.php");
+
enableSemantics('example.org'); # replace example.org by the name of the wiki.
+
 
+
include_once("$IP/extensions/SQL2Wiki/SQL2Wiki.php");
+
### NOT YET ENABLED: ShibbolethAuthentication, folder linked, not yet tested or activated
+
require_once("$IP/extensions/StringFunctions/StringFunctions.php");
+
require_once("$IP/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php");
+
### DO NOT ENABLE TitleKey without a good reason. Without it being installed, searching for articles DOES work case-insensitive already. No further explanations could be found.
+
  
 
Additional actions for some extensions:
 
Additional actions for some extensions:
Line 308: Line 305:
 
* (Cite may also need additional action, although the mentioned cite layout file is already present. Nothing done so far, needs testing)
 
* (Cite may also need additional action, although the mentioned cite layout file is already present. Nothing done so far, needs testing)
 
* (Sitenotice: It is possible to set one in LocalSettings.php, but better method is MediaWiki:Sitenotice)
 
* (Sitenotice: It is possible to set one in LocalSettings.php, but better method is MediaWiki:Sitenotice)
* Todo:  
+
 
 +
* Todo:
 
** FlaggedRevs has a number of things to do, '''not yet done'''
 
** FlaggedRevs has a number of things to do, '''not yet done'''
 
** install lucene (links on MWSearch page), add and install MWSearch extension
 
** install lucene (links on MWSearch page), add and install MWSearch extension
Line 314: Line 312:
 
'''Note: according to testing by Evolaris, the CentralNotice extension is slowing down the Wiki functionality significantly, by loading <script type="text/javascript" src="http://smorgasbord.local/trunk/index.php/Special:NoticeLoader"></script> from external sites.''' We may want to disable this function again. the function occurs on both KeyToNature and the JKI installations. Note that, although the en and de Wikipedias themselves use the extension, the script does not appear there!!!
 
'''Note: according to testing by Evolaris, the CentralNotice extension is slowing down the Wiki functionality significantly, by loading <script type="text/javascript" src="http://smorgasbord.local/trunk/index.php/Special:NoticeLoader"></script> from external sites.''' We may want to disable this function again. the function occurs on both KeyToNature and the JKI installations. Note that, although the en and de Wikipedias themselves use the extension, the script does not appear there!!!
  
==Open Questions==
+
==(Failed) Attempt to use GlobalUsage==
  
* '''TODO:''' '''Quiz''': the building tool adopted by Wikiversity! This one comes close to '''identification tools!'''
+
'''GH: THIS WAS TESTED, BUT WE COULD NOT YET GET IT TO WORK!!'''
* '''TODO:''' Install and test Extension:CentralAuth. The special tables are created in wikidb, and a variant for CommonSettings2.php exists in the root. However, configuring the wgConfig variable remained unclear for a config with with prefixed tables for multiple wikis in a single database. Could not get it to work...
+
** CentralAuth is confirmed not to work at present when multiple wikis are kept in a single DB, separated by table prefixes.
+
** Instead we configured one Wiki-database to manage the users from all Wikis (using the localsettings variable [http://www.mediawiki.org/wiki/Manual:$wgSharedDB $wgSharedDB]). This provides single identity, although not single sign-on.
+
** If we fail to get this running, drop the tables again: ''DROP TABLE globalnames; DROP TABLE localnames; DROP TABLE globaluser; DROP TABLE localuser; DROP TABLE global_user_groups; DROP TABLE global_group_permissions;''
+
* GoogleMapsExtension
+
* Configure [http://www.mediawiki.org/wiki/Extension:Gadgets Gadgets Extension], extension is running but no gadgets are active yet (wikED would be nice).
+
* MWSearch (NEEDS LUCENE FIRST)
+
* TitleKey (probably not necessary when MWSearch is active, Article name search is case-insensitive)
+
* OAI (installation problems, sql queries remained unclear)
+
* SemanticMediaWiki (no sql queries needed)'''
+
  
* '''Under Review, potential security thread: '''SQL2Wiki'''
+
Add to common settings:
* '''Not activated:'' '''LdapAuthentication''' (http://www.mediawiki.org/wiki/Extension:LDAP_Authentication)
+
: $wgGlobalUsageDatabase = "openmedia";
* '''Considered:'' '''DataTable''', '''Glossary''' (both currently not in subversion-extensions), '''PDF Export''',
+
: require_once( "$IP/extensions/GlobalUsage/GlobalUsage.php" );
* '''Intersection''' has been disabled again, lack of usage documentation, may conflict with DynamicPageList (Same php file name, same tag??). They have similar purposes, but Intersection is used on WikiNews, DynamicPageList not.
+
** Update: Intersection/DynamicPageList is documented [http://meta.wikimedia.org/wiki/DynamicPageList here], the names are just confusing!
+
  
==Backup/Restore==
+
THIS EXTENSION ONLY WORKS WITH setting up a dummy form of http://www.mediawiki.org/wiki/Manual:$wgLBFactoryConf - even if Loadbalancing is acutally not used!
  
For just the database see: http://www.mediawiki.org/wiki/Manual:Backing_up_a_wiki. A more complete script can be found here: http://www.mediawiki.org/wiki/User:Flominator/Backup_MW - this also backups the folder with uploads (media). Based on that source, adapted scripts were created, execute as:
+
Initialize with:  
 +
<source lang="bash">
 +
# create central table in image repository (only first time; alternatively update.php will also do this):
 +
cd /var/www/v-species/o;    sudo php ./maintenance/sql.php ./extensions/GlobalUsage/GlobalUsage.sql --conf ./LocalSettings.php
 +
# record file usage on all other wikis:
 +
cd /var/www/metawiki;  sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
cd /var/www/studienstiftungswiki;  sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
cd /var/www/testwiki;  sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
cd /var/www/testwiki2;  sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
cd /var/www/v-floramalesiana/w;    sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
cd /var/www/v-ispi/w;  sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
cd /var/www/v-k2n/w;    sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
cd /var/www/v-k2n/h;    sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
cd /var/www/v-k2n/it;  sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
cd /var/www/v-k2n/sl;  sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
cd /var/www/v-lias/w;  sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
cd /var/www/v-nnvm/w;  sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
cd /var/www/v-on/w;    sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
cd /var/www/v-orowiki/w;sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
cd /var/www/v-phytomed/w;      sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
cd /var/www/v-phytopathology/w; sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
cd /var/www/v-plantnet/terms/e; sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
cd /var/www/v-plantnet/terms/f; sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
cd /var/www/v-plantnet/uses/e;  sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
cd /var/www/v-plantnet/uses/f;  sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
cd /var/www/v-rosaceae/w;  sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
cd /var/www/v-species/f;  sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
cd /var/www/v-species/o;  sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
cd /var/www/v-species/s;  sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
cd /var/www/v-species/w;  sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
cd /var/www/v-workbench/w; sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
cd /var/www/v-zsm/w;      sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 +
</source>
  
  cd /var/backups/scripts/; ./backup-mw.sh
+
Removing tables for Cleanup (check for new wikis that need to be added!): DROP TABLE enwiki.globalimagelinks; DROP TABLE ispiwiki.globalimagelinks; DROP TABLE k2n_handbook.globalimagelinks;  DROP TABLE k2n_it.globalimagelinks;  DROP TABLE k2n_sl.globalimagelinks;  DROP TABLE k2n_wiki.globalimagelinks;  DROP TABLE liaswiki.globalimagelinks;  DROP TABLE malesiana_wiki.globalimagelinks;  DROP TABLE metawiki.globalimagelinks;  DROP TABLE nnvmwiki.globalimagelinks;  DROP TABLE onwiki.globalimagelinks;  DROP TABLE openmedia.globalimagelinks;  DROP TABLE orowiki.globalimagelinks;  DROP TABLE plantnet_terms_en.globalimagelinks;  DROP TABLE plantnet_terms_fr.globalimagelinks;  DROP TABLE plantnet_uses_en.globalimagelinks;  DROP TABLE plantnet_uses_fr.globalimagelinks;  DROP TABLE plazi_wiki.globalimagelinks;  DROP TABLE pmedwiki.globalimagelinks;  DROP TABLE rosawiki.globalimagelinks;  DROP TABLE specialmedia.globalimagelinks;  DROP TABLE specieswiki.globalimagelinks;  DROP TABLE species_fr.globalimagelinks;  DROP TABLE studienstiftungswiki.globalimagelinks;  DROP TABLE testwiki.globalimagelinks;  DROP TABLE testwiki2.globalimagelinks;  DROP TABLE wbwiki.globalimagelinks;  DROP TABLE zsm_entomology.globalimagelinks;
  
The additional backup-mw.php script can potentially be used within www to directly create and download a copy of the mediawiki. We are testing this as a measure to build trust.
+
==2011: mwlib extension for open document support==
  
In addition, to create an xml dump, make sure a link to AdminSettings.php exists in the current wiki folder and the maintenance folder is temporarily copied, then run, e.g.:
+
Source: http://code.pediapress.com/wiki/wiki/mwlib-install - the easy-install variant seems more feasable, the git/re2c variant requires code later than debian lenny
cd /var/www/v-k2n/w/maintenance # replace path with actual wiki path
+
php dumpBackup.php --full > /var/backups/wikis/k2n-full.xml
+
php dumpBackup.php --logs > /var/backups/wikis/k2n-logs.xml
+
  
(Note: --logs may not yet be working under version 1.12, it works in 1.14)
+
sudo apt-get install g++ perl python python-dev python-setuptools python-imaging
 +
sudo easy_install -U setuptools
 +
sudo easy_install mwlib && rehash
  
To restore such a xml-dump, remove tables and create new tables with default values in mysql, then:
+
The last command resulted in a number of error, however.
cd /var/www/WIKINAME;  # (replace path with actual wiki path!)
+
php ./maintenance/importDump.php /var/backups/wikis/k2n-full.xml --conf ./LocalSettings.php
+
php ./maintenance/rebuildrecentchanges.php --conf ./LocalSettings.php    # absolutely necessary
+
## If backlinks etc. do not work, or extensions had to be disabled, use (Very slow!!!!):
+
php ./maintenance/rebuildall.php  --quick --conf ./LocalSettings.php
+
  
Notes: In our experience, some extensions may create problems during reimport. We found GoogleMaps and DynamicPageList to cause importDump to abort. After disabling these two extensions, the import worked correctly. However, all DPL pages are then still cached without proper DPL rendering even after re-enabling both extensions. Running rebuildall.php fixed this.
+
==(Failed) Attempt to use pngscale==
 +
https://bugzilla.wikimedia.org/show_bug.cgi?id=9497 / https://github.com/dcoetzee/pngscale
 +
sudo apt-get install libpng-dev
 +
cd /home/XXXXX;
 +
git clone git://github.com/dcoetzee/pngscale.git
 +
# not: git checkout git://github.com/dcoetzee/pngscale.git
 +
cd pngscale
 +
make
 +
cp pngscale /usr/bin
  
Example restore for testing of the wikimediafoundation commons xml-dump:
+
Then in CommonSettings.php:
  cd /var/www/wmf-commons; php ./maintenance/importDump.php  /mnt/wpTest/commonswiki-pages-articles.xml  --conf ./LocalSettings.php
+
  $wgMaxShellFileSize = 2097152
 +
$wgCustomConvertCommandsByExtension['png'] = "/usr/bin/pngscale %s %d %w %h";
  
==Maintenance scripts==
+
==Open Questions==
  
(see http://www.mediawiki.org/wiki/Manual:Maintenance_scripts)
+
* '''TODO:''' Install and test Extension:CentralAuth. The special tables are created in wikidb, and a variant for CommonSettings2.php exists in the root. However, configuring the wgConfig variable remained unclear for a config with with prefixed tables for multiple wikis in a single database. Could not get it to work...
 
+
** CentralAuth is confirmed not to work at present when multiple wikis are kept in a single DB, separated by table prefixes. (Originally, we used such a setup, but have changed to separate databases by now.)
In /usr/share/mediawiki/phase3/ copy AdminSettings.sample to AdminSettings.php, create a new user wikiadmin for mysql with localhost only, and edit AdminSettings.php accordingly. Then, for each wiki, in /var/www/wikifolder/, a symlink must be created linking to /usr/share/mediawiki/phase3/AdminSettings.php. Since we have a symlinked installation, installations scripts must run like:
+
** Instead we configured one Wiki-database to manage the users from all Wikis (using the localsettings variable [http://www.mediawiki.org/wiki/Manual:$wgSharedDB $wgSharedDB]). This provides single identity, although not single sign-on.
+
** If we fail to get this running, drop the tables again: ''DROP TABLE globalnames; DROP TABLE localnames; DROP TABLE globaluser; DROP TABLE localuser; DROP TABLE global_user_groups; DROP TABLE global_group_permissions;''
php /var/www/wikifolder/maintenance/rebuildall.php  --conf /var/www/wikifolder/LocalSettings.php
+
php /var/www/wikifolder/maintenance/importImages.php --conf /var/www/wikifolder/LocalSettings.php /var/www/wikifolder/media/newimages .jpg .png .svg
+
 
+
Rebuild all is necessary after external text, sql, or xml imports.
+
 
+
'''Table corruption:''' rebuildall.php may report that a table, especially searchindex (which is MyISAM even if other tables are InnoDB) is corrupt and needs to be repaired. In phpmyadmin, open a sql window for the affected database, and issue: <code>truncate table searchindex;</code>. Running rebuildall.php afterwards concluded the repair in a case we had.
+
 
+
Rebuilding the file cache (note: permission may be a problem; this will be the commandline user, whereas normally cache is written by apache):
+
cd /var/www/metawiki;      php ./maintenance/rebuildFileCache.php 0 overwrite --conf ./LocalSettings.php
+
cd /var/www/testwiki;      php ./maintenance/rebuildFileCache.php 0 overwrite --conf ./LocalSettings.php
+
cd /var/www/v-k2n/w;        php ./maintenance/rebuildFileCache.php 0 overwrite --conf ./LocalSettings.php
+
cd /var/www/v-k2n/it;      php ./maintenance/rebuildFileCache.php 0 overwrite --conf ./LocalSettings.php
+
cd /var/www/v-lias/w;      php ./maintenance/rebuildFileCache.php 0 overwrite --conf ./LocalSettings.php
+
cd /var/www/v-phytomed/w;  php ./maintenance/rebuildFileCache.php 0 overwrite --conf ./LocalSettings.php
+
cd /var/www/v-phytopathology/w; php ./maintenance/rebuildFileCache.php 0 overwrite --conf ./LocalSettings.php
+
cd /var/www/v-rosaceae/w;  php ./maintenance/rebuildFileCache.php 0 overwrite --conf ./LocalSettings.php
+
cd /var/www/v-species/n;    php ./maintenance/rebuildFileCache.php 0 overwrite --conf ./LocalSettings.php
+
cd /var/www/v-species/o;    php ./maintenance/rebuildFileCache.php 0 overwrite --conf ./LocalSettings.php
+
cd /var/www/v-species/w;    php ./maintenance/rebuildFileCache.php 0 overwrite --conf ./LocalSettings.php
+
cd /var/www/v-workbench/w;  php ./maintenance/rebuildFileCache.php 0 overwrite --conf ./LocalSettings.php
+
 
+
After erroneously localizing commons images not to openmedia but to local wikis, extension Nuke was used to deleted the caching-bot imports, and deleteArchivedFiles to actually delete all archived files:
+
cd /var/www/v-onf/w; php ./maintenance/deleteArchivedFiles.php  --conf ./LocalSettings.php --delete
+
 
+
Fix problems with unparsable image names (see [http://www.mediawiki.org/wiki/Manual:CleanupImages.php]):
+
cd /var/www/v-k2n/w; php ./maintenance/cleanupImages.php --fix  --conf ./LocalSettings.php
+
cd /var/www/v-onf/w; php ./maintenance/cleanupImages.php --fix  --conf ./LocalSettings.php
+
cd /var/www/v-species/o; php ./maintenance/cleanupImages.php --fix  --conf ./LocalSettings.php
+
cd /var/www/v-species/s; php ./maintenance/cleanupImages.php --fix  --conf ./LocalSettings.php
+
 
+
 
+
'''Extension maintenance scripts'''
+
 
+
Some extensions provide their own maintenance scripts in their own extension folder. On a wiki farm, the execution of these scripts may fail due to the linked directory structure. They need an additional link (needs to be created only once):
+
 
+
cd /usr/share/mediawiki/; ln -s /usr/share/mediawikistaging/phase3/maintenance
+
cd /usr/share/mediawikistaging/; ln -s /usr/share/mediawikistaging/phase3/maintenance
+
 
+
Now '''TitleKey''' works:
+
 
+
cd /var/www/testwiki; php ./extensions/TitleKey/rebuildTitleKeys.php --conf ./LocalSettings.php
+
 
+
==MediaWiki configuration tips==
+
 
+
Configuring MediaWiki:Sidebar: New options July 2008, see [http://lists.wikimedia.org/pipermail/wikitech-l/2008-July/038604.html]
+
 
+
It may be useful to copy the contents of http://en.wikipedia.org/wiki/MediaWiki:Common.css  and http://en.wikipedia.org/wiki/MediaWiki:Monobook.css into the Mediawiki:Common.css and MediaWiki:Monobook.css pages of each Wiki where you may want to use copied things e.g. templates from wikipedia.
+
 
+
 
+
==MediaWiki upgrading==
+
 
+
To upgrade Mediawiki first run the update on the staging version (= testwiki, http://biowikifarm.net/test):
+
cd /usr/share/mediawikistaging/; sudo svn update phase3 extensions  -r59858
+
sudo /usr/sbin/apache2ctl -k graceful
+
# Optionally add other updates:
+
sudo apt-get update
+
sudo apt-get upgrade
+
cd /usr/share/; sudo svn update phpmyadmin-dev
+
 
+
After testing and verifying functionality, also update the production version (where "-r52502" indicates to update precisely to revision 52502; this should always be the value of the tested revision from staging / test wiki!):
+
cd /usr/share/mediawiki; sudo svn update phase3 extensions  -r66620
+
sudo /usr/sbin/apache2ctl -k graceful
+
 
+
Occasionally the SVN upgrading of Mediawiki may require an upgrade of the database structures. Again, the update.php must be called with symlink-compatible syntax. Examples:
+
cd /var/www/metawiki; php ./maintenance/update.php  --quick --conf ./LocalSettings.php
+
cd /var/www/testwiki; php ./maintenance/update.php  --quick --conf ./LocalSettings.php
+
cd /var/www/v-k2n/w; php ./maintenance/update.php  --quick --conf ./LocalSettings.php
+
cd /var/www/v-k2n/it; php ./maintenance/update.php  --quick --conf ./LocalSettings.php
+
cd /var/www/v-lias/w; php ./maintenance/update.php  --quick --conf ./LocalSettings.php
+
cd /var/www/v-phytomed/w; php ./maintenance/update.php  --quick --conf ./LocalSettings.php
+
cd /var/www/v-phytopathology/w; php ./maintenance/update.php  --quick --conf ./LocalSettings.php
+
cd /var/www/v-rosaceae/w;  php ./maintenance/update.php  --quick --conf ./LocalSettings.php
+
cd /var/www/v-species/n;  php ./maintenance/update.php  --quick --conf ./LocalSettings.php
+
cd /var/www/v-species/o;  php ./maintenance/update.php  --quick --conf ./LocalSettings.php
+
cd /var/www/v-species/w;  php ./maintenance/update.php  --quick --conf ./LocalSettings.php
+
cd /var/www/v-workbench/w; php ./maintenance/update.php  --quick --conf ./LocalSettings.php
+
 
+
See also [[#Maintenance scripts| Maintenance scripts]] above for further scripts.
+
 
+
==File uploading and Mime types ==
+
 
+
Uploading files with extensions and Content types (MIME types) usually not allowed on wikis:
+
The default of normally allowed extensions is listed <code>$wgFileExtensions</code> in  /includes/DefaultSettings.php (which should never be edited). To allow
+
additional extensions override <code>$wgFileExtensions</code> in LocalSettings.php.
+
 
+
There are also $wgMimeTypeBlacklist and $wgFileBlacklist for file extensions and MIME types that are never allowed for security reasons, even if added to <code>$wgFileExtensions</code>. If needed for special purposes and considered safe, they can be commented out in these blacklists in LocalSettings.php.
+
 
+
If there is still the error message "The file is corrupt or has an incorrect extension. Please check the file and upload again", the reason can be that the file you want to upload has a MIME type for which only certain file extensions are allowed in /includes/mime.types and has an extension not listed there. If considered safe, the extension can be added in that file. The mime type can be determined with the command <code>file -i ''filename''</code>. '''Note:''' Files that are changed manually are then excluded from svn update. To drop own changes and get back to the svn version delete the file and then run svn update (see above).
+
  
 
==Securing MediaWiki==
 
==Securing MediaWiki==
  
See http://www.mediawiki.org/w/index.php?title=Manual:Security
+
See [http://www.mediawiki.org/w/index.php?title=Manual:Security MediaWiki Manual:Security]
  
==Logging/Debugging==
+
----
  
For debugging, you may enable logging of debug and error messages:
+
Further information can be found under '''[[Mediawiki maintenance]]''' (maintenance/backup/upgrading)
  
# create a log-file somewhere
 
  sudo touch /var/www/v-k2n/w/log.txt
 
  sudo chmod 777 /var/www/v-k2n/w/log.txt
 
# edit LocalSettings.php and add the following line after the line including the DefaultSettings.php:
 
  $wgDebugLogFile = "/var/www/v-k2n/w/log.txt";
 
 
Note, that the logfile will get quite big pretty fast, so you should switch on the logging only for short periods of time, and delete the logfile after you're done.
 
 
----
 
  
 
[[Category:Software documentation]]
 
[[Category:Software documentation]]
[[Category:Extensions]]
+
[[Category: MediaWiki Extensions]]
 +
[[Category:MediaWiki]]

Latest revision as of 23:06, 2 January 2018

Todo SemanticFormsInputs

An overview and record of strategies to install mediawiki the first time, and maintain and upgrade it. See also:


First time MediaWiki installation

Basics: We want to run multiple mediawiki instances from a single software source. Our preferred method uses a mixture of local files in a var/www subfolder (LocalSettings.php, the config and image folder) with the rest of mediawiki files and folders being represented by symbolic links (largely following these instructions; see for a page probably equivalent to our method but not used by us). We use "media" as folder name instead of "images"; some folders within images/media need to be writable. The config folder must be writable to www-data if setup is to be run (usually we do not run it, but copy).

Software needed

 # image thumbs and video thumbs
 sudo apt-get install imagemagick librsvg2-2 librsvg2-bin
 sudo apt-get install ffmpeg ffmpeg2theora
 # for graphviz / semantic result formats:
 sudo apt-get install graphviz

(When newer version of ImageMagick is needed, see Upgrading Imagemagick to a current version. Currently working ok with Debian 6 version)

Installing mediawiki from git (1.20 and later)

Main source: mediawiki.org: Download from Git. See also overview of wikimedia projects in Git.

IMPORTANT CHANGE in comparison to earlier subversion setup: we directly clone all extensions into the /extension folder, instead of cloning elsewhere and then symlinking.

Memo: use "git tag -l | sort -V" um tags sortiert anzuzeigen

First installation only: Create git-clone on biowikifarm

A biowikifarm git-clone (normal, not bare) of the WMF core and extension repo is created.

# 1. FIRST create a biowikifarm git-clone (non-bare) for mediawiki-core and mw-extensions (submodules):
  cd /usr/share; sudo mkdir mw-wmf-clone; cd /usr/share/mw-wmf-clone
  sudo git clone https://gerrit.wikimedia.org/r/p/mediawiki/core.git core
  sudo git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions.git extensions
  sudo git clone https://gerrit.wikimedia.org/r/p/mediawiki/skins.git skins # new!
  cd /usr/share/mw-wmf-clone/extensions; sudo git submodule update --init --recursive
  cd /usr/share/mw-wmf-clone/skins; sudo git submodule update --init --recursive
  # Note: with after init, one can use "git foreach". Example:
  #   git submodule foreach 'echo $path `git rev-parse HEAD`' 
  #   will show the path and currently checked out commit for each submodule.

Update git and export version to folder

This section is identical to the updating, see Mediawiki maintenance > MediaWiki version upgrading (core and wikimedia extensions. SVN is separate however!

Installing extensions from Local subversion

Some extensions unavailable in Wikimedia git exist in our local svn:

 # 4. ONLY FOR FIRST TIME CREATION of SVN-Extensions:
 # Insert the local-svn-managed extensions into the same folder:
 # Note: www-data cannot create the folders, but must be able to write the updates (svn-post-commit hook) -> temp folder
 # Remaining Problem: when a new svn folder is added after this initial setup to the local subversion repo,
 #   that folder must manually chown to www-data; else svn co post-commit errors will occur.
 # e.g.: wikipath="/usr/share/mediawiki20/"
 cd "${wikipath}"
 sudo mkdir TEMP-LOCAL-svn; ## temp folder
 sudo svn checkout file:///var/lib/svn/LocalSVNextensions ./TEMP-LOCAL-svn
 sudo chown -R  www-data:www-data ./TEMP-LOCAL-svn
 sudo mv ./TEMP-LOCAL-svn/* ./extensions; 
 sudo rm ./extensions/.svn -R; 
 sudo mv ./TEMP-LOCAL-svn/.svn ./extensions 
 sudo rm ./TEMP-LOCAL-svn -r

Installation of additional extensions from other sources

 # 5. Installation of additional extensions from other sources
 ### None yet.

Additional tasks

 # 6. Finishing touches. Widgets needs a writable folder:
 cd ${wikipath}
 sudo chown -R  www-data:www-data ./extensions/Widgets/compiled_templates;
 sudo chmod g+w -R  ./extensions/Widgets/compiled_templates;
 # eg. sudo chown -R  www-data:www-data /usr/share/mediawiki20/extensions/Widgets/compiled_templates; sudo chmod g+w -R  /usr/share/mediawiki20/extensions/Widgets/compiled_templates
 # Widgets does not contain all necessary code (-> Warning: require_once(/usr/share/mediawiki20/phase3/extensions/Widgets/smarty/Smarty.class.php): failed to open stream: No such file or directory...)
 # In the absence of installation instructions, using previously saved code:
 sudo cp -r /usr/share/mw-missing-code/Widgets/smarty ./extensions/Widgets
 sudo cp -r /usr/share/mw-missing-code/Widgets/googlecode ./extensions/Widgets
<!--
 # NOTE: in Dec. 2012 the parts were originally copied as seen below:
 sudo mkdir /usr/share/mw-missing-code
 sudo mkdir /usr/share/mw-missing-code/Widgets
 sudo cp -r /usr/share/mediawikistaging/ext-tagged-release/Widgets/smarty /usr/share/mw-missing-code/Widgets
 sudo cp -r /usr/share/mediawikistaging/ext-tagged-release/Widgets/googlecode /usr/share/mw-missing-code/Widgets
-->


Email

Setting up the email functions requires either a local server, or for external server setting $wgSMTP. It also first requires to install the Mail.php functionality:

sudo apt-get install php-mail php-net-smtp

then add to LocalSettings.php:

 ini_set("include_path", ".:$IP:$IP/includes:$IP/languages:/usr/share/php/:/usr/share/php/PEAR/");
 $wgSMTP = array(
 'host'     => "160.45.63.40",
 'IDHost'   => "bgbm.org",
 'port'     => 25,
 'auth'     => true,
 'username' => "xxx123",
 'password' => "xxx123xxx123xxx123"
 );

Update 2017: We use PEAR (must be installed, see mediawiki manual), and had to use the following, slightly more complex install (probably due to updating rather than fresh install):

sudo pear channel-update pear.php.net; sudo pear install mail pear/Auth_SASL net_smtp

Cloning a new wiki

NOTE: some of the following instructions are OLD. THE BETTER PAGE FOR CREATING MEDIAWIKI INSTANCES IS: Create a new mediawiki instance


Any code above needs to be run only the first time. From then on, the template can be reused to clone instances (where "NEW-WIKI" is replaced with the name for your wiki):

 ## for new virtual host:
 cd /var/www/; sudo cp -r wiki-template NEW-hostpath
 cd /var/www/NEW-hostpath/w; sudo chmod a+w cache; sudo chmod a+w media
 ## for new wiki within virtual host:
 cd /var/www/; sudo cp -r wiki-template/w hostpath/newwiki
 cd /var/www/hostpath/newwiki; sudo chmod a+w cache; sudo chmod a+w media
 ## if using installer, also: sudo chmod a+w config;

A useful template wiki as of 2014 is /var/www/v-ztemplate/w

Current template may require: (wiki may be direct in biowikifarm, in v-host, or nested 1 further)

sudo chown www-data:www-data /var/www/*/media -R
sudo chown www-data:www-data /var/www/*/*/media -R
sudo chown www-data:www-data /var/www/*/*/*/media -R
sudo chmod 775 /var/www/*/media -R
sudo chmod 775 /var/www/*/*/media -R
sudo chmod 775 /var/www/*/*/*/media -R

To make all LocalSettings writable:

sudo chmod 775 /var/www/*/LocalSettings.php
sudo chmod 775 /var/www/*/*/LocalSettings.php
sudo chmod 775 /var/www/*/*/*/LocalSettings.php

To reset to readonly:

sudo chmod 640 /var/www/*/LocalSettings.php
sudo chmod 640 /var/www/*/*/LocalSettings.php
sudo chmod 640 /var/www/*/*/*/LocalSettings.php

It is possible to use the install process in a web browser (http://..../NEW-Wiki/config/index.php). However, more usually, the database is copied in mysql (todo: go to z_en_template, go to Operations, use copy option, then go to mysql-localhost, privileges, go to wiki user, add privileges for the new database.

Short note for later installs:

  • Set license first (setting it will void other entries)
  • set localhost:8088
  • set database name and UTF-8 character set.
  • For db creation do not use root, but personal mysql admin account.

Full notes for settings made on the web forms of the MediaWiki installation: For the DPG (society of phytopathologists in Germany): Name=DPG, contact email gh, language de, License: Creative Commons, choose non-commercial, share-alike, Admin name: WikiSysop, (password noted separate), caching memcached 127.0.0.1:11211, email options left default (or user-to-user disabled), DB config: MySQL, localhost:8088 (the port on which we operate mysql), databasename: pmedwiki, user name wikiuser, (password noted separate). adding root credentials so that wikiuser and tables can be created (wikiuser has insufficient rights). No database table prefix (originally we DID use prefixes and a single db, however, that prevents to ever use the single-sign-on mechanism...), engine=InnoDB, character set changed to UTF-8. Click Install, move LocalSettings.php to the parent directory, remove the config folder:

 cd /var/www/NEW-Wiki/; sudo mv config/LocalSettings.php .; sudo rm -rf config


Procedure as script by AP (not entirely tested):

#!/bin/bash
# http://biowikifarm.net/meta/Mediawiki_installation#Cloning_a_new_wiki
wiki_template="./v-ztemplate"
new_wiki_folder="./v-species"
wiki_script_folder="./zt" # default ./w
wiki_config_folder="./mw-config" # default ./w
web_dir="/var/www"
do_web_installation="" # "" is false

cd "${web_dir}"
# copy wiki template
sudo cp -r "${wiki_template}" "${new_wiki_folder}"
# go to wiki folder
cd "${web_dir}/${new_wiki_folder}"; 
# check if different script folder necessary
if ! [ -d  "${web_dir}/${new_wiki_folder}/${wiki_script_folder}" ];then
  sudo mv "${web_dir}/${new_wiki_folder}/w" "${web_dir}/${new_wiki_folder}/${wiki_script_folder}"
fi
# check rights of folders
cd "${web_dir}/${new_wiki_folder}/${wiki_script_folder}"
sudo chmod a+w cache; 
sudo chmod a+w media;
sudo chown www-data:www-data "./media" -R
sudo chmod 775      "./media" -R

if [ "${do_web_installation}" ];then
  # check if the mw-config directory for first install is there
  if ! [ -d "${web_dir}/${new_wiki_folder}/${wiki_script_folder}/${wiki_config_folder}" ];then
    sudo cp /usr/share/mw-wmf-clone/core/mw-config/* ./mw-config/
    sudo mkdir "${web_dir}/${new_wiki_folder}/${wiki_script_folder}/"
    sudo chown www-data:www-data "${web_dir}/${new_wiki_folder}/${wiki_script_folder}/${wiki_config_folder}" -R
    if [ -e "${web_dir}/${new_wiki_folder}/${wiki_script_folder}/LocalSettings.php" ];then
      # installation script won't start if LocalSettings.php is there
      # backup file with date suffix
      modified_date=`stat --format="%y" "${web_dir}/${new_wiki_folder}/${wiki_script_folder}/LocalSettings.php" | awk  '{ print $1 }'`
      sudo mv "${web_dir}/${new_wiki_folder}/${wiki_script_folder}/LocalSettings.php" "${web_dir}/${new_wiki_folder}/${wiki_script_folder}/LocalSettings.php.${modified_date}"
    fi
  sudo chmod a+w "${wiki_config_folder}"; 
  fi
fi

################################################
# step: configure web server (nginx)
################################################

################################################
# step: wiki installation
# if you install a single Wiki use http://your-url.com/wgArticlePath/mw-config/index.php
# OR 
# copy a wiki database template, (adjust another) LocalSettings.php and run as final step:
#   sudo -u www-data php ./maintenance/update.php  --quick --conf ./LocalSettings.php
################################################
# step: update database
################################################
cd "${web_dir}/${new_wiki_folder}/${wiki_script_folder}";        sudo -u www-data php ./maintenance/update.php  --quick --conf ./LocalSettings.php

For each wiki add to the virtual host configuration to (Originally apache, but as of 2012 to nginx) and restart:

 # sudo /usr/sbin/apache2ctl -k graceful && sudo service nginx restart && sudo service php5-fpm restart
 sudo service apache2 restart && sudo service nginx restart && sudo service php5-fpm restart

For each wiki using ShortURLs, the robot.txt must be updated!

Some extensions need execution of a sql command for each db (where "DBNAME" and "DBUSER" are replaced with actual db name and user) (ls /var/www/NEW-Wiki/extensions/*.sql):

  
  mysql -u USER -p --database=xwiki < /usr/share/mediawiki/extensions/OpenID/openid_table.sql
  mysql -u USER -p --database=xwiki < /usr/share/mediawiki/extensions/TitleKey/titlekey.sql

ConfirmAccount from /usr/share/mediawiki/extensions/ConfirmAccount/ConfirmAccount.sql would create 2 tables: "account_requests", "account_credentials". It is necessary only in the shared sign-on wiki (for us this is metawiki). OpenID creates single table "user_openid". Titlekey creates single table "titlekey". Note: We no longer add the DPL views.

To simplify the setup, we have extracted the common settings from LocalSettings.php into a file called MediaWikiCommonSettings.php directly in the www-root. Usually, because of the manual change to MediaWikiCommonSettings.php, we manually modify a template LocalSettings.php from any wiki and use it instead of the one created by the install process.

Note: virtual wiki path is preferable in lower case because it helps to highlight the page title (having Title-Case)!

Configuration after setup

  • Logo changed in each LocalSettings
  • Short_URL see: http://www.mediawiki.org/wiki/Manual:Short_URL
  • Timezone settings added: ( #Set Default Timezone: // $wgLocaltimezone="Europe/Berlin"; // $wgLocalTZoffset = +120; // putenv("TZ=$wgLocaltimezone");)
  • Security information on preventing editing by anonymous users and user-creation options under Preventing_Access; we added following to MediaWikiCommonSettings.php:
$wgEnableUploads  = true; # (Make sure the php.ini settings are correct, see above)
$wgMaxImageArea = 5e7; # Default is 1.25e7.
  # (support thumb generation for large line drawings which may only be 1.4 MB but larger 5000 px)
# Disable anonymous editing
$wgGroupPermissions['*']['edit'] = false;
# Prevent new user registrations except by sysops
$wgGroupPermissions['*']['createaccount'] = false;
# possible fix to enable JavaScript to function also under https AND http. 
$wgProto = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
$wgServer = $wgProto."://the-wiki-url.net";

(Perhaps see also a blog describing this method). A better method than limiting creation to sysops it the ConfirmAccount extension, which we installed (see extensions below).

Enabling extensions

The first part, establishing the symbolic links, must be done only once for the subversion-managed mediawiki installation, since all further wiki installations symlink to the same phase3/extensions folder. Normally further actions are necessary (LocalSettings.php) for each wiki, but we perform them centrally in MediaWikiCommonSettings.php. Yet some db-specific actions are necessary for some extensions, see at the end. Most extensions are already available through the subversion download. Symbolic links are created to enable selected extensions, initially for:

The CentralAuth extension is difficult to install, although seemingly the only extension supporting single-sign one (users can be shared through shared tables, but sign-ons in browers must be repeated). The initial attempts to use CentralAuth failed. New help is available since, and http://noc.wikimedia.org/conf/highlight.php?file=CommonSettings.php would be an important resource.

In LocalSettings/CommonSettings, add the information for the extensions. The following example may be outdated, check against current file:

 # NEEDS UPDATING - OUT OF DATE VERSIONS PRESENTLY REMOVED!

Additional actions for some extensions:

  • CharInsert requires after standard installation to create/edit MediaWiki:Edittools
    • Good templates are found (but respect the license!) at en.wikipedia or de.wikipedia.
    • The english WP uses a mixture of direct use and Javascript; it requires also MediaWiki:Edittools.js
    • The place where MediaWiki:Edittools.js is being activated needs still to be found! TODO!
  • ConfirmAccount needs sql commands for each db; details under cloning wikis above.
  • OpenID requires the openidenabled.com 2.x libraries. Debian 4 support those only as backports, so make sure the repository has been added (see above). Then issue apt-get install python-openid. Additional sql code is needed; details under cloning wikis above.
  • (Cite may also need additional action, although the mentioned cite layout file is already present. Nothing done so far, needs testing)
  • (Sitenotice: It is possible to set one in LocalSettings.php, but better method is MediaWiki:Sitenotice)
  • Todo:
    • FlaggedRevs has a number of things to do, not yet done
    • install lucene (links on MWSearch page), add and install MWSearch extension

Note: according to testing by Evolaris, the CentralNotice extension is slowing down the Wiki functionality significantly, by loading <script type="text/javascript" src="http://smorgasbord.local/trunk/index.php/Special:NoticeLoader"></script> from external sites. We may want to disable this function again. the function occurs on both KeyToNature and the JKI installations. Note that, although the en and de Wikipedias themselves use the extension, the script does not appear there!!!

(Failed) Attempt to use GlobalUsage

GH: THIS WAS TESTED, BUT WE COULD NOT YET GET IT TO WORK!!

Add to common settings:

$wgGlobalUsageDatabase = "openmedia";
require_once( "$IP/extensions/GlobalUsage/GlobalUsage.php" );

THIS EXTENSION ONLY WORKS WITH setting up a dummy form of http://www.mediawiki.org/wiki/Manual:$wgLBFactoryConf - even if Loadbalancing is acutally not used!

Initialize with:

 # create central table in image repository (only first time; alternatively update.php will also do this):
 cd /var/www/v-species/o;    sudo php ./maintenance/sql.php ./extensions/GlobalUsage/GlobalUsage.sql --conf ./LocalSettings.php
 # record file usage on all other wikis:
 cd /var/www/metawiki;   sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 cd /var/www/studienstiftungswiki;   sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 cd /var/www/testwiki;   sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 cd /var/www/testwiki2;  sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 cd /var/www/v-floramalesiana/w;     sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 cd /var/www/v-ispi/w;   sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 cd /var/www/v-k2n/w;    sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 cd /var/www/v-k2n/h;    sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 cd /var/www/v-k2n/it;   sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 cd /var/www/v-k2n/sl;   sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 cd /var/www/v-lias/w;   sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 cd /var/www/v-nnvm/w;   sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 cd /var/www/v-on/w;     sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 cd /var/www/v-orowiki/w;sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 cd /var/www/v-phytomed/w;       sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 cd /var/www/v-phytopathology/w; sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 cd /var/www/v-plantnet/terms/e; sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 cd /var/www/v-plantnet/terms/f; sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 cd /var/www/v-plantnet/uses/e;  sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 cd /var/www/v-plantnet/uses/f;  sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 cd /var/www/v-rosaceae/w;  sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 cd /var/www/v-species/f;   sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 cd /var/www/v-species/o;   sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 cd /var/www/v-species/s;   sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 cd /var/www/v-species/w;   sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 cd /var/www/v-workbench/w; sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php
 cd /var/www/v-zsm/w;       sudo php ./extensions/GlobalUsage/refreshGlobalimagelinks.php --conf ./LocalSettings.php

Removing tables for Cleanup (check for new wikis that need to be added!): DROP TABLE enwiki.globalimagelinks; DROP TABLE ispiwiki.globalimagelinks; DROP TABLE k2n_handbook.globalimagelinks; DROP TABLE k2n_it.globalimagelinks; DROP TABLE k2n_sl.globalimagelinks; DROP TABLE k2n_wiki.globalimagelinks; DROP TABLE liaswiki.globalimagelinks; DROP TABLE malesiana_wiki.globalimagelinks; DROP TABLE metawiki.globalimagelinks; DROP TABLE nnvmwiki.globalimagelinks; DROP TABLE onwiki.globalimagelinks; DROP TABLE openmedia.globalimagelinks; DROP TABLE orowiki.globalimagelinks; DROP TABLE plantnet_terms_en.globalimagelinks; DROP TABLE plantnet_terms_fr.globalimagelinks; DROP TABLE plantnet_uses_en.globalimagelinks; DROP TABLE plantnet_uses_fr.globalimagelinks; DROP TABLE plazi_wiki.globalimagelinks; DROP TABLE pmedwiki.globalimagelinks; DROP TABLE rosawiki.globalimagelinks; DROP TABLE specialmedia.globalimagelinks; DROP TABLE specieswiki.globalimagelinks; DROP TABLE species_fr.globalimagelinks; DROP TABLE studienstiftungswiki.globalimagelinks; DROP TABLE testwiki.globalimagelinks; DROP TABLE testwiki2.globalimagelinks; DROP TABLE wbwiki.globalimagelinks; DROP TABLE zsm_entomology.globalimagelinks;

2011: mwlib extension for open document support

Source: http://code.pediapress.com/wiki/wiki/mwlib-install - the easy-install variant seems more feasable, the git/re2c variant requires code later than debian lenny

sudo apt-get install g++ perl python python-dev python-setuptools python-imaging
sudo easy_install -U setuptools
sudo easy_install mwlib && rehash

The last command resulted in a number of error, however.

(Failed) Attempt to use pngscale

https://bugzilla.wikimedia.org/show_bug.cgi?id=9497 / https://github.com/dcoetzee/pngscale

sudo apt-get install libpng-dev
cd /home/XXXXX; 
git clone git://github.com/dcoetzee/pngscale.git
# not: git checkout git://github.com/dcoetzee/pngscale.git
cd pngscale
make
cp pngscale /usr/bin

Then in CommonSettings.php:

$wgMaxShellFileSize = 2097152
$wgCustomConvertCommandsByExtension['png'] = "/usr/bin/pngscale %s %d %w %h";

Open Questions

  • TODO: Install and test Extension:CentralAuth. The special tables are created in wikidb, and a variant for CommonSettings2.php exists in the root. However, configuring the wgConfig variable remained unclear for a config with with prefixed tables for multiple wikis in a single database. Could not get it to work...
    • CentralAuth is confirmed not to work at present when multiple wikis are kept in a single DB, separated by table prefixes. (Originally, we used such a setup, but have changed to separate databases by now.)
    • Instead we configured one Wiki-database to manage the users from all Wikis (using the localsettings variable $wgSharedDB). This provides single identity, although not single sign-on.
    • If we fail to get this running, drop the tables again: DROP TABLE globalnames; DROP TABLE localnames; DROP TABLE globaluser; DROP TABLE localuser; DROP TABLE global_user_groups; DROP TABLE global_group_permissions;

Securing MediaWiki

See MediaWiki Manual:Security


Further information can be found under Mediawiki maintenance (maintenance/backup/upgrading)