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.
Old look-and-feel of linuxintro.org |
- linuxintro looks good and has a professional "skin" as they call it. Works on mobile devices and on my huge screen at home.
- linuxintro loads quicker. Almost 50x as fast.
- no more code modifications in the mediawiki code
Performance
I wanted to see that linuxintro.org stays quick. To do this, I will use ab (apache benchmark). Measured from a server instance2 in USA, here is a typical performance result of the old linuxintro.org:
thorsten@instance-2:~$ ab -n 100 -c 10 http://www.linuxintro.org/ |grep "Requests per second"
Requests per second: 1.96 [#/sec] (mean)
A typical result from try-linux.blogspot.com is:
Requests per second: 137.28 [#/sec] (mean)
- nginx instead of apache
- mariadb instead of SQLite
- no more facebook comment plugin
Versions
Product | old | new |
---|---|---|
MediaWiki | 1.21.2 | 1.34.2 |
PHP | 5.5.9-1ubuntu4.29 (apache2handler) | 7.3.19 |
WebServer | Apache 2.4.7 | nginx 1.14.2 |
Database | SQLite 3.8.2 with full-text search support | MariaDB 10.3.27 |
OS | Ubuntu 14.04 | Debian 10 |
VM | 2x2.3GHz/4GiB | 1x2.3GHz/1.6GiB |
Trying to get Linuxintro.org mobile-friendly
Minerva does not work, seems there is a hard dependency on https://www.mediawiki.org/wiki/Extension:MobileFrontend.
Solution was to choose the timeless skin, which looks better as well on mobile as on a big screen.
Issue: PHP did not work
I set up an nginx web server, but php was not working. Instead, the server tried to send me the php scripts as text files, it looked like this in the browser:
root@ubuntu:/etc/nginx# service nginx restart
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
root@ubuntu:/etc/nginx# systemctl status nginx.service
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2020-12-27 07:16:03 PST; 9s ago
Docs: man:nginx(8)
Process: 12741 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Dec 27 07:16:03 ubuntu systemd[1]: Starting A high performance web server and a reverse proxy server...
Dec 27 07:16:03 ubuntu nginx[12741]: nginx: [emerg] "fastcgi_pass" directive is duplicate in /etc/nginx/sites-enabled/default:62
Dec 27 07:16:03 ubuntu nginx[12741]: nginx: configuration file /etc/nginx/nginx.conf test failed
Dec 27 07:16:03 ubuntu systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Dec 27 07:16:03 ubuntu systemd[1]: nginx.service: Failed with result 'exit-code'.
Dec 27 07:16:03 ubuntu systemd[1]: Failed to start A high performance web server and a reverse proxy server.
apt-get install php7.4-xml
Now mediawiki tells me it is ready for installation
Issue: MariaDB
Next issue: copy the data
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;
Next issue: https
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;
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"
Next issue: stumbleupon button
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
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:Next issue: Cannot log in
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.
$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
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.
Keine Kommentare:
Kommentar veröffentlichen