Some time ago I wrote AdaptiveThumb, and mediawiki extension that allows pictures with relative sizes in mediawiki.
You can then use e.g. the following syntax:
<pic src="mindmap.jpg" width=30% align=text caption="this is a mindmap" />
You can find an example here: www.linuxintro.org/wiki/BaBE, a demo there: http://www.staerk.de/thorsten/Adaptivethumb, download and install it from https://www.mediawiki.org/wiki/Extension:AdaptiveThumb, and you can contribute and report bugs on https://github.com/tstaerk/adaptivethumb.
To test this extension, I use VMware Workstation 15 Player and install Ubuntu 20.04. This is the plan:
Product | Version |
MediaWiki | 1.34.2 |
PHP | 7.3.19 |
WebServer | nginx 1.14.2 |
Database | SQLite |
OS | Ubuntu 20.04 |
VM software | VMware Workstation 15
|
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:
This is nonsense - I want the server to execute the php scripts, not to download it.
So, quickly went to /etc/nginx/sites-available/default and uncommented this block:
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
# With php-cgi (or other tcp sockets):
fastcgi_pass 127.0.0.1:9000;
}
Please note that I tested this solution with Ubuntu 20 while this blog is about Debian 10. You may have to replace /var/run/php/php7.4-fpm.sock by /var/run/php7.3-fpm.sock. To find out, do an
ls /var/run/php/php7.*
Then install the server-side php code that is needed by this block:
apt-get install php-fpm
Then nginx did not start any longer:
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.
Let's find out why:
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.
Looking into this, I find out that /etc/nginx/sites-enabled/default is a symbolic link to /etc/nginx/sites-available/default and both files are sourced, so it is no wonder that the fastcgi_pass directive is duplicate. So I delete the link:
root@ubuntu:/etc/nginx/sites-enabled# rm default
Now nginx starts again, but does not open port 80
copied default, removed line 62, and it worked.
Now I copy mediawiki software to /var/www/html/wiki and point the browser to localhost/wiki/index.php. It tells me it needs the php extensions mbstring and xml.
apt-get install php-mbstring
apt-get install php7.4-xml
Now mediawiki tells me it is ready for installation
Next issue: 403 Forbidden
On the next day I got the next issue - I got a 403 Forbidden when I try to access /wiki:
Solution: don't go to localhost/wiki, go to localhost/wiki/index.php
Next issue: CamelCase
Now it was time to install my extension adaptivethumb:
cd /var/www/html/wiki/extensions
wget --no-check-certificate https://github.com/tstaerk/adaptivethumb/archive/master.zip
unzip master.zip
mv adaptivethumb-master adaptivethumb
Now adding to LocalSettings.php
wfLoadExtension ( 'AdaptiveThumb ' );
makes that the whole wiki does not work any longer. You have to add
wfLoadExtension ( 'adaptivethumb' );
instead.
Next issue: git
Now I learned how to use git. First I created a public key:
ssh-keygen -t rsa
Then I uploaded this to github, now I could get the repository to my local machine using the command
git clone git@github.com:tstaerk/adaptivethumb.git
And I could git commit and push from there.
Next issue: debugging output
Sometimes when you debug a program, you need output like "what value has variable xyz". For this, php has the error_log functionality. It outputs your message (mostly) to a file. To find out what file, use phpinfo(). For me, phpinfo() delivered "no value" for error_log. I changed the config file and restarted php-fpm using the commands
service php7.4-fpm stop
service php7.4-fpm start
Then, phpinfo pointed to a file. Then, I could use
error_log("test from adaptivethumb\n",3,"/tmp/errors2");
to log errors to /tmp/errors2
So I found out that $wgAllowExternalImages is false using
if ($wgAllowExternalImages) error_log("wgallow is true",3,"/tmp/errors2");
else error_log("wgallow is false",3,"/tmp/errors2");
Next issue: wgAllowExternalImages
The next issue was that
<pic src="mindmap.jpg" width=30% align=text caption="this is a mindmap" />
Keine Kommentare:
Kommentar veröffentlichen