Migrate Mediawiki: Difference between revisions

From Creative Crowds wiki
Jump to navigation Jump to search
No edit summary
 
(8 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
  ssh cc
Line 19: Line 27:


  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
==Downloading MediaWiki==


Download Mediawiki from the website, following this: https://www.mediawiki.org/wiki/Manual:Upgrading#Command_line
Download Mediawiki from the website, following this: https://www.mediawiki.org/wiki/Manual:Upgrading#Command_line
Line 36: Line 46:
  chmod -R 755 /var/www/wiki/
  chmod -R 755 /var/www/wiki/


Configure nginx
==Configure nginx==


<pre>
<pre>
Line 71: Line 81:
</pre>
</pre>


Migrate the database
==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!==


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)
php maintenance/run.php update


Then this error appeared: <code>Class "Wikimedia\Parsoid\DOM\HTMLDocument" not found</code>
Then this error appeared: <code>Class "Wikimedia\Parsoid\DOM\HTMLDocument" not found</code>


Followed this: https://phabricator.wikimedia.org/T409283
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!  
Worked!  


Done
==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]]
[[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!