Problem
How to move mediawiki from ubuntu to wsl?
Solution
Notation
[wikifolder]
: where your wiki locate[wikidb]
: database wiki uses[wikidb_user]
: user of database
Assuming we have two servers:- Server 1
[wikifolder]
: /var/www/html
[wikidb]
: wikidb
[wikidb_user]
: root - Server 2
[wikifolder]
: /var/www/html
[wikidb]
: wikidb
[wikidb_user]
: wikiuser
Old mediawiki is in Server 1. We'd like to back up it, then scp to Server 2, finally restore from it in Server 2.
backup database in Service 1
- First insert the following line into LocalSettings.php
$wgReadOnly = 'Dumping Database, Access will be restored shortly';
this can be removed as soon as the dump is completed.
mysqldump --default-character-set=binary -u root -p -h localhost --opt wikidb > wikidb-backup.sql
For more, See Mysqldump_from_the_command_line, and Back up in schedule
backup website in Service 1
tar czpvf mediawiki-1.23.13-backup.tar.gz /var/www/html
Restore in Service 2
Import the database backup
On the server on which you are restoring MediaWiki, ensure you have
- a correctly-working instance of MySQL
- a MySQL user with appropriate permissions, if you can't use MySQL user root
mkdir mediawiki_backup && cd mediawiki_backup/
cp /mnt/c/Users/chencanyi/Videos/wikidb-backup.sql ~/mediawiki_backup/ # or you can use scp
- If a database exists and you want to entirely replace it from the backup. To destroy the database:
mysqladmin -u wikiuser -p drop wikidb
- Then to create a new database and restore from backup:
mysqladmin -u wikiuser -p create wikidb
mysql -u wikiuser -p wikidb < wikidb-backup.sql
php /var/www/html/maintenance/update.php
Import the MediaWiki files
Assuming you are in Service 1.
scp ubuntu@Service1:~/mediawiki_backup/mediawiki-1.23.13-backup.tar.gz ~/mediawiki_backup/
cd ~/mediawiki_backup/
tar -xvzf mediawiki-1.23.13-backup.tar.gz
rm -fR [wikifolder]/
mv ./var/www/html [wikifolder]
- Restart apache2 & mysql
sudo service apache2 restart
sudo service mysql restart
Check the configuration file
- IP
Something more
- where to find database configure?
cd /var/www/html
vi LocalSettings.php
# Something like
## Database settings
$wgDBtype = "mysql";
$wgDBserver = "localhost";
$wgDBname = "wikidb";
$wgDBuser = "root";
$wgDBpassword = "***";