Migrate Mediawiki: Difference between revisions
No edit summary |
|||
| (15 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
Following this: | |||
https://www.mediawiki.org/wiki/Manual:Restoring_a_wiki_from_backup | |||
and https://www.mediawiki.org/wiki/Manual:Upgrading (as we are upgrading from 1.39 to 1.45.1) | |||
==Installing requirements== | |||
ssh cc | |||
sudo su | sudo su | ||
apt install mariadb-server | apt install mariadb-server imagemagick | ||
mysql | mysql | ||
| Line 18: | Line 28: | ||
apt install php php-fpm php-mysql php-xml php-intl php-mbstring php-gd php-curl | apt install php php-fpm php-mysql php-xml php-intl php-mbstring php-gd php-curl | ||
Download Mediawiki from the website | ==Downloading MediaWiki== | ||
Download Mediawiki from the website, following this: https://www.mediawiki.org/wiki/Manual:Upgrading#Command_line | |||
cd /var/www/ | |||
wget https://releases.wikimedia.org/mediawiki/1.45/mediawiki-1.45.1.tar.gz | |||
tar xvzf mediawiki-1.45.1.tar.gz | |||
rm mediawiki-1.45.1.tar.gz | |||
rename the unzipped folder to <code>wiki</code> | |||
Configure nginx | mv mediawiki-1.45.1 wiki | ||
change the permissions | |||
chown -R www-data:cc /var/www/wiki/ | |||
chmod -R 755 /var/www/wiki/ | |||
==Configure nginx== | |||
<pre> | <pre> | ||
# --------------------------------------------------- | # --------------------------------------------------- | ||
# WIKI | # WIKI | ||
location /wiki | # Handling for the article path (pretty URLs) | ||
location /wiki { | |||
index index.php; | |||
rewrite ^/wiki/(?<pagename>.*)$ /wiki/index.php; | |||
} | } | ||
} | # Images | ||
location /wiki/images/deleted { | |||
# Deny access to deleted images folder | |||
deny all; | |||
} | |||
# MediaWiki assets (usually images) | |||
location ~ ^/wiki/resources/(assets|lib|src) { | |||
try_files $uri 404; | |||
add_header Cache-Control "public"; | |||
expires 7d; | |||
} | |||
# Assets, scripts and styles from skins and extensions | |||
location ~ ^/wiki/(skins|extensions)/.+\.(css|js|gif|jpg|jpeg|png|svg|wasm)$ { | |||
try_files $uri 404; | |||
add_header Cache-Control "public"; | |||
expires 7d; | |||
} | |||
# License and credits files | |||
location ~ ^/wiki/(COPYING|CREDITS)$ { | |||
default_type text/plain; | |||
} | |||
</pre> | </pre> | ||
( | ==Migrate the database== | ||
On our old OVH server: | |||
mysqldump --user=wikidb_user --password=wikidb_userpassword wikidb > dump_of_wikidb.sql | |||
On our new Servus server: | |||
mysql -u wikidb_user -p wikidb < dump_of_wikidb.sql | |||
==Update!== | |||
php maintenance/run.php update | |||
Then this error appeared: <code>Class "Wikimedia\Parsoid\DOM\HTMLDocument" not found</code> | |||
Followed this: https://phabricator.wikimedia.org/T409283 | |||
And this response worked: | |||
The problem is that Wikimedia\Parsoid\DOM\HTMLDocument isn't properly autoloaded. I solved it temporarily like this: | |||
require_once('vendor/wikimedia/parsoid/src/DOM/HTMLDocument.php'); | |||
Insert this line right before $doc = HTMLDocument::createEmpty( "UTF-8" ); in vendor/wikimedia/parsoid/src/Utils/DOMCompat.php. | |||
Then again: | |||
php maintenance/run.php update | |||
Worked! | |||
==Install extensions== | |||
All extensions need to be reinstalled, to make sure we are using the latest version compatible to 1.45.1. | |||
===EtherpadLite=== | |||
Throws no error. But does not render? Hmm... | |||
===VisualEditor=== | |||
Gave again a parsoid error: | |||
Error: Class Wikimedia\Parsoid\DOM\DOMImplementation not found | |||
Solved with adding this: | |||
require_once('vendor/wikimedia/parsoid/src/DOM/DOMImplementation.php'); | |||
To this file: | |||
nano /var/www/wiki/vendor/wikimedia/parsoid/src/Wt2Html/TreeBuilder/ParsoidDOMBuilder.php | |||
This solved it... but it feels tricky to do these manual hacks.... | |||
Let's upgrade when there is a new stable mediawiki version released! | |||
[[Category:Sysadmin]] | |||
Latest revision as of 10:55, 16 January 2026
Following this:
https://www.mediawiki.org/wiki/Manual:Restoring_a_wiki_from_backup
and https://www.mediawiki.org/wiki/Manual:Upgrading (as we are upgrading from 1.39 to 1.45.1)
Installing requirements
ssh cc
sudo su
apt install mariadb-server imagemagick
mysql
CREATE USER 'wiki'@'localhost' IDENTIFIED BY 'INSERTPASSWORDHERE';
CREATE DATABASE wikidb;
GRANT ALL PRIVILEGES ON wikidb.* TO 'wiki'@'localhost';
FLUSH PRIVILEGES;
EXIT;
apt install php php-fpm php-mysql php-xml php-intl php-mbstring php-gd php-curl
Downloading MediaWiki
Download Mediawiki from the website, following this: https://www.mediawiki.org/wiki/Manual:Upgrading#Command_line
cd /var/www/ wget https://releases.wikimedia.org/mediawiki/1.45/mediawiki-1.45.1.tar.gz tar xvzf mediawiki-1.45.1.tar.gz rm mediawiki-1.45.1.tar.gz
rename the unzipped folder to wiki
mv mediawiki-1.45.1 wiki
change the permissions
chown -R www-data:cc /var/www/wiki/ chmod -R 755 /var/www/wiki/
Configure nginx
# ---------------------------------------------------
# WIKI
# Handling for the article path (pretty URLs)
location /wiki {
index index.php;
rewrite ^/wiki/(?<pagename>.*)$ /wiki/index.php;
}
# Images
location /wiki/images/deleted {
# Deny access to deleted images folder
deny all;
}
# MediaWiki assets (usually images)
location ~ ^/wiki/resources/(assets|lib|src) {
try_files $uri 404;
add_header Cache-Control "public";
expires 7d;
}
# Assets, scripts and styles from skins and extensions
location ~ ^/wiki/(skins|extensions)/.+\.(css|js|gif|jpg|jpeg|png|svg|wasm)$ {
try_files $uri 404;
add_header Cache-Control "public";
expires 7d;
}
# License and credits files
location ~ ^/wiki/(COPYING|CREDITS)$ {
default_type text/plain;
}
Migrate the database
On our old OVH server:
mysqldump --user=wikidb_user --password=wikidb_userpassword wikidb > dump_of_wikidb.sql
On our new Servus server:
mysql -u wikidb_user -p wikidb < dump_of_wikidb.sql
Update!
php maintenance/run.php update
Then this error appeared: Class "Wikimedia\Parsoid\DOM\HTMLDocument" not found
Followed this: https://phabricator.wikimedia.org/T409283
And this response worked:
The problem is that Wikimedia\Parsoid\DOM\HTMLDocument isn't properly autoloaded. I solved it temporarily like this:
require_once('vendor/wikimedia/parsoid/src/DOM/HTMLDocument.php');
Insert this line right before $doc = HTMLDocument::createEmpty( "UTF-8" ); in vendor/wikimedia/parsoid/src/Utils/DOMCompat.php.
Then again:
php maintenance/run.php update
Worked!
Install extensions
All extensions need to be reinstalled, to make sure we are using the latest version compatible to 1.45.1.
EtherpadLite
Throws no error. But does not render? Hmm...
VisualEditor
Gave again a parsoid error:
Error: Class Wikimedia\Parsoid\DOM\DOMImplementation not found
Solved with adding this:
require_once('vendor/wikimedia/parsoid/src/DOM/DOMImplementation.php');
To this file:
nano /var/www/wiki/vendor/wikimedia/parsoid/src/Wt2Html/TreeBuilder/ParsoidDOMBuilder.php
This solved it... but it feels tricky to do these manual hacks....
Let's upgrade when there is a new stable mediawiki version released!