I have 20 years of experience with Linux in the job and wanted to give something back, so I founded linuxintro.org, a wiki where you can learn about Linux.
However, this wiki page quickly outdated: Mobile phones became the new standard for reading internet and I had to adapt Linuxintro to it. After some patching, a general overhaul was due. This is the topic here.
Issue: MariaDB
This was my first contact with MariaDB. I was surprised how similar it is to mySQL. However, it drove me mad to understand how to log in: You have to call it with -p, but not give the password in the command line. Here as an example how you show the databases:
root@instance-2:/var/www/html/mediawiki/extensions/adaptivethumb# mysql -u admin -pEnter password: Welcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 5742Server version: 10.3.27-MariaDB-0+deb10u1 Debian 10Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> show databases -> ;+--------------------+| Database |+--------------------+| information_schema || mediawiki || my_wiki || mysql || performance_schema |+--------------------+5 rows in set (0.001 sec)
Next issue: copy the data
To copy the articles I decided for the scripts in mediawiki's maintenance folder. You call them on the command line:
root@oldlinuxintro:/var/www/linuxintro.org/maintenance# php dumpBackup.php --full >/tmp/fullbackup.xml
Copied them using scp
And you restore them with the command
root@newlinuxintro:/var/www/html/mediawiki/maintenance# php importDump.php /root/fullbackup.xml
That's 29MB of data, pure text!!! The pictures are still missing.
Next issue: /wiki path
Now, when I go to http://35.238.169.171/mediawiki, the browser gets redirected to http://35.238.169.171/index.php?title=Main_Page and you can see this in the address bar. In the file system, mediawiki's software is in /var/www/html/mediawiki
So I added to LocalSettings.php:
$wgArticlePath = '/wiki/$1'; # Virtual path. This directory MUST be different from the one used in $wgScriptPath
$wgUsePathInfo = true;
and it worked:
Next issue: https
https still is not enabled, just http. Obviously the data to be transmitted is not secret, I do not even provide a login section. I found out my web server is nginx, not apache:
root@instance-2:/var/www/html/mediawiki# service apache2 status● apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Sat 2020-12-26 09:11:46 UTC; 7h ago Docs: https://httpd.apache.org/docs/2.4/ Process: 6807 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)Dec 26 09:11:46 instance-2 systemd[1]: Starting The Apache HTTP Server...Dec 26 09:11:46 instance-2 apachectl[6807]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80Dec 26 09:11:46 instance-2 apachectl[6807]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80Dec 26 09:11:46 instance-2 apachectl[6807]: no listening sockets available, shutting downDec 26 09:11:46 instance-2 apachectl[6807]: AH00015: Unable to open logsDec 26 09:11:46 instance-2 apachectl[6807]: Action 'start' failed.Dec 26 09:11:46 instance-2 apachectl[6807]: The Apache error log may have more information.Dec 26 09:11:46 instance-2 systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILUREDec 26 09:11:46 instance-2 systemd[1]: apache2.service: Failed with result 'exit-code'.Dec 26 09:11:46 instance-2 systemd[1]: Failed to start The Apache HTTP Server.root@instance-2:/var/www/html/mediawiki# service nginx status● nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2020-12-26 09:52:22 UTC; 6h ago Docs: man:nginx(8) Process: 7141 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Process: 7142 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Main PID: 7143 (nginx) Tasks: 2 (limit: 1967) Memory: 7.2M CGroup: /system.slice/nginx.service ├─7143 nginx: master process /usr/sbin/nginx -g daemon on; master_process on; └─7145 nginx: worker processDec 26 09:52:22 instance-2 systemd[1]: Starting A high performance web server and a reverse proxy server...Dec 26 09:52:22 instance-2 systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argumentDec 26 09:52:22 instance-2 systemd[1]: Started A high performance web server and a reverse proxy server.
After editing /etc/nginx/sites-available/mediawiki and restarting nginx, http and https work.
There are now two server blocks, one for http and one for https. I make sure they look identical except for certs stuff.
Next issue: spammers
Mediawiki is by default open, and a popular wiki like Linuxintro easily yields 1000 spam contributions per day. To avoid that, I deny anonymous editing. So I add
$wgGroupPermissions['*' ]['edit'] = false;
$wgGroupPermissions['*' ]['createpage'] = false;
$wgGroupPermissions['*' ]['createtalk'] = false;
$wgGroupPermissions['*']['createaccount'] = false;
to /var/www/html/mediawiki/LocalSettings.php
Next issue: Google Analytics
In the old linuxintro.org, I changed the mediawiki source code so that every html page contains
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-158912120-1"></script>
to register with Google Analytics.
In the new installation, I installed the extension
https://www.mediawiki.org/wiki/Extension:Google_Analytics_Integration
However I did not understand why $wgGoogleAnalyticsOtherCode would be non-optional.
Next issue: DNS
Changed DNS from the old linuxintro.org to the new one :) 11:11 on 2020-12-26.
IP address used to be 50.30.38.138, now is 35.238.169.171
Next issue: URL rewrite
Now, when I surf to http://www.linuxintro.org/... in the browser, the browser URL line gets rewritten to be http://35.238.169.171/.... This is strange, never seen this before. But a look into LocalSettings.php helped. Setting
$wgServer= "http://linuxintro.org"
resolved the thing.
Next issue: stumbleupon button
I realized that I had a button encouraging users to share their experience with linuxintro.org on stumbleupon, that's why the web page now says
<stumbleuponbutton />
Looking into it, there is a mediawiki extension on https://www.mediawiki.org/wiki/Extension:StumbleUponButton
But it seems stumbleupon is now called mix and the buttons do not seem to work any longer.
Next issue: My users
It has been very quiet around linuxintro.org, almost no contributions. My favorite would be that everyone can authenticate towards the wiki via an identity provider and then just start contributing. But I don't want to take over user. Whoever wants to contribute to linuxintro.org, please leave a comment here.
Next issue: comments
When I started with Linuxintro.org, I was very happy to be able to provide a service to the world. This service included content and infrastructure. By infrastructure I mean that I run the mediawiki software and much more. The longer it goes, the more I understand that it is a good idea to concentrate on the content and leave the platform to a provider. A good example are comments. When I started with linuxintro, there was quasi nothing but facebook, so I enabled facebook comments which (a) was not used very widely, (b) adds traffic costs (c) increases site load times and is (d) complex to maintain, so I am abandoning facebook comment. In the long run it may be a good idea to move to a managed environment where I can just publish content like blogspot.com.
Next issue: favicon
The favicon is that little thing on the browser tag's top left that tells you about the site you are calling. For the old linuxintro.org, it looks like this:
For the new one, it is still the default:
To resolve this, I just copied favicon.ico from the old web-server-root-directory to the new one. It's now in /var/www/html/mediawiki. And this is what is defined as "root" in /etc/nginx/sites-available/mediawiki.
Next issue: Cannot log in
Now, trying to log in as ThorstenStaerk (my admin user) does not work. I got the error message
There seems to be a problem with your login session; this action has been canceled as a precaution against session hijacking. Go back to the previous page, reload that page and then try again.
Going back did not work. But once I fixed $wgServer not to point to the IP address any longer, but to http://linuxintro.org and I added
$wgSessionType=CACHE_DB
it worked. I removed the $wgSessionType again.
Next issue: Cannot upload images
I could not upload pictures. To allow it, I set in LocalSettings.php:
$wgEnableUploads = true;
Then it worked.
Next issue: MetaDesc
If you want to tell a search engine what a page is about, you have the chance to do so via a metadesc tag. For this, in mediawiki, they have an extension that can be used starting from mediawiki 1.25. I could not use it before, so I modified the mediawiki source code to recognize metadesc tags. This is now history.
So I installed https://www.mediawiki.org/wiki/Extension:MetaDescriptionTag.
Now let's go to http://linuxintro.org/wiki/set_up_a_webcam and look at the source code. It does contain a meta desc:
And, as supposed, you do not see any of this on the wiki page. But you do see it once you right-click onto the wiki page and select "View page source":
So search engines will know that this page is about webcams ;)
Next issue: The pic tag
To allow images to be resized based on browser size changes, I installed https://www.mediawiki.org/wiki/Extension:AdaptiveThumb
Next issue: regex
I copied regex builder, my page to translate english sentences into a regular expression from the old linuxintro. I copied it to /var/www/html/mediawiki/regex, but nginx now shows "403 forbidden" when I try to access it. In /var/log/nginx/error.log I find a line
2021/01/03 09:36:58 [error] 22918#22918: *50 access forbidden by rule, client: 193.159.30.53, server: linuxintro.org, request: "GET /regex/ HTTP/1.1", host: "linuxintro.org"
It worked once I put into sites-available, on the server for port 80:
location /regex
{
try_files $uri/index.html $uri =404;
}
Next issue: The images
collected all images on the old VM:
in the images directory, did:
cp $(find -iname "*" ) /tmp/images/
Now
/var/www/html/mediawiki$ php maintenance/importImages.php /tmp/images/
Importing Files
Importing hddj36d9hsz20fjaw6q9hv2mf46uc3i.jpg...LocalFileLockError from line 2228 of /var/www/html/mediawiki/includes/filerepo/file/LocalFile.php: Could not open lock file for "mwstore://local-backend/local-public/0/0c/Hddj36d9hsz20fjaw6q9hv2mf46uc3i.jpg". Make sure your upload directory is configured correctly and your web server has permission to write to that directory. See https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:$wgUploadDirectory for more information.
Ok, changed to root and changed the directories' ownership:
root@instance-2:/var/www/html/mediawiki# chown -R www-data:www-data images/
now it works:
root@instance-2:/var/www/html/mediawiki# php maintenance/importImages.php /tmp/images/
Importing Files
Importing hddj36d9hsz20fjaw6q9hv2mf46uc3i.jpg...done.
Importing 200px-Mindmap.png...done.