Sonntag, 27. Oktober 2013

read e-books with Linux

Yes! I read an e-book on my Linux computer \o/

I did this on 2013-10-25 with SUSE Linux 12.2:

  • go to http://www.amazon.com and get some free e-books.
  • downloaded their Kindle reader for Windows
  • delete the old version of the Windows Emulator wine from my computer. To do this, open a console and type
    rpm -e wine wine-32bit wine-mp3
    rpm -ivh wine-1.7.4-*.rpm wine-gecko-*.rpm wine-32bit-*.rpm
  • Now you start the reader's installation:
    wine Downloads/KindleForPC-installer.exe
  • And start the reader:
    cd .wine/drive_c/Program\ Files/Amazon/Kindle
    wine Kindle.exe

Dienstag, 22. Oktober 2013

pretty URL in mediawiki

For my personal homepage http://www.staerk.de/thorsten I use mediawiki. That way I can edit it whenever I want, even from an internet cafe or the like.

When I write about e.g. my Cybermaster I do not want it to appear anywhere but on http://www.staerk.de/thorsten/cybermaster. This is called a prettyURL and I want to show here how I do it. My URL http://www.staerk.de/thorsten corresponds to the directory /var/www/staerk.de/thorsten on the server. I am using mediawiki 1.21.2 on Apache2 under Ubuntu Linux 10.04
  • make sure Apache has the "rewrite" module loaded:
    # apache2ctl -t -D DUMP_MODULES 2>&1 | grep rewrite
    rewrite_module (shared)
  • configure apache to rewrite your requests as discussed here:
    RewriteRule ^/?thorsten(/.*)?$ %{DOCUMENT_ROOT}/thorsten/index.php [L]

    RewriteRule ^/*$ %{DOCUMENT_ROOT}/thorsten/index.php [L]

  • restart apache
    /etc/init.d/apache2 restart
  • Add the following line to LocalSettings.php:
    $wgArticlePath = "/thorsten/$1";

Now your wiki will look "strange" like this:

The reason for this "strange" look is that the skins are missing. Mediawiki is using a file called load.php and when loading it, apache will use its rewrite-rules and try to load it as a wiki page. The solution is:
  • add the following condition above the first rewrite rule:
    RewriteCond %{REQUEST_URI} !^/thorsten/load.*$

Then it looks better, but still the images are missing. No problem, reading apache's access log at /var/log/apache2/other_vhosts_access.log I find that clients try to download them from /thorsten/Images. So
  • add another condition above the rewrite rule:
    RewriteCond %{REQUEST_URI} !^/thorsten/images.*$

and the page looks again as it should:

See also

Freitag, 4. Oktober 2013

Error creating thumbnail: Unable to save thumbnail to destination

I just set up mediawiki on http://www.staerk.de/thorsten. Whenever I upload an image I see the error message:
Error creating thumbnail: Unable to save thumbnail to destination

1. Permissions

Now the first thing you should check when you get this error message is that your server's directories are writeable to the web server process. This is Ubuntu Linux so as long as the files are owned by www-data everything is okay. They were so this is not the problem:

/var/www/staerk.de/thorsten# ll
-rw-r--r--  1 www-data www-data     1088 Sep  3 18:56 thumb_handler.php
-rw-r--r--  1 www-data www-data      956 Sep  3 18:56 thumb_handler.php5
-rw-r--r--  1 www-data www-data       86 Sep  3 18:56 wiki.phtml
[...]

2. Logs

So I had to dig deeper. I looked into the server log if there was any entry at the time when I uploaded:
cat /var/log/apache/error_log
There was no message at these times so I moved on.

3. PHP's safe_mode

php's safe_mode feature is another thing that can make accessing files impossible. safe_mode is a great feature of PHP and it should never be turned off except for experimenting and troubleshooting. So I opened /etc/php5/apache2/php.ini, searched for safe_mode and set it to off:
safe_mode = Off
restarted the web server with the command
/etc/init.d/apache2 restart
and during the next time when I uploaded an image the error was gone.
So I set safe_mode to On again, restarted apache and entered the following line into /var/www/staerk.de/thorsten/LocalSettings.php:
putenv('TMPDIR=/var/www/staerk.de/thorsten');
Now whenever I upload a file I get a warning in /var/log/apache2/error.log like:

[Fri Oct 04 08:37:50 2013] [error] [client 95.113.203.63] PHP Warning:  putenv(): Safe Mode warning: Cannot set environment variable 'TMPDIR' - it's not in the allowed list in /var/www/staerk.de/thorsten/LocalSettings.php on line 31, referer: http://www.staerk.de/thorsten/index.php/Special:Upload

So what is in the allowed list?
Looking into /etc/php5/apache2/php.ini helps. I set it to empty which allows to change all environment variables:
safe_mode_allowed_env_vars =
And the error changes. The error now says:
Error creating thumbnail: Unable to run external programs in safe mode.
Googling helped. In /var/www/staerk.de/thorsten/LocalSettings.php I added at the end:
$wgUseImageMagick = false
and it works as you can see on http://www.staerk.de/thorsten

Raspberry Pi, test my internet connection

Since start of Corona times, I use my internet at home also for work. So its reliability and performance has become crucial. Performance see...