Migrate Mediawiki: Difference between revisions

From Creative Crowds wiki
Jump to navigation Jump to search
No edit summary
No edit summary
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)
==Installing requirements==


  ssh cc
  ssh cc
Line 19: Line 26:


  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 45:
  chmod -R 755 /var/www/wiki/
  chmod -R 755 /var/www/wiki/


Configure nginx
==Configure nginx==


<pre>
<pre>
Line 71: Line 80:
</pre>
</pre>


Migrate the database
==Migrate the database==
 
On our old OVH server:
 
mysqldump --user=wikidb_user --password=wikidb_userpassword wikidb > file.sql
 
On our new Servus server:
 
 
 
==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.


Worked!  
Worked!  

Revision as of 09:54, 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)

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 > file.sql

On our new Servus server:


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.

Worked!

Done