User:BDavis (WMF)/Notes/Thumb.php with Vagrant
Enable Use of thumb.php in Vagrant VM
editCreate a Vagrant "role" that enables thumb.php to handle 404 image requests in the wikimedia instance.
Manual Changes
edit- Add config to LocalSettings.php:
// thumb.php thumbnail generation via 404
$wgThumbnailScriptPath = false;
$wgGenerateThumbnailOnParse = false;
- Configure 404 handler in /etc/apache2/sites-enabled/devwiki (Manual:Thumb.php#MediaWiki_.3E.3D_1.20):
### thumb.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /w/thumb.php?f=$1&width=$2 [PT,QSA,B] ### ^^^^ this works but doesn't match wiki docs ### PT instead of L RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /w/thumb.php?f=$1&width=$2&archived=1 [PT,QSA,B] ### end thumb.php
Note that I used the MediaWiki <= 1.19 syntax. I couldn't get thumb_handler.php
to work properly. It seems like the PathRouter setup isn't quite right to handle it. I also had to change from L
to PT
to get the alias for /w
to take effect.
With these changes in place my vm instance is generating new thumbs on the fly. They are also saved to disk in /svr/images
Puppet
editUsage
editvagrant enable-role multimedia vagrant provision
Once enabled, mediaiwiki instance in vagrant host will no longer generate thumbnails at page render. It will instead automagically generate and cache thumbs that have not been generated yet when HTTP requests are received. This allows a more WMF production matching dev stack as commons uses a similar configuration.
Design
editBasic idea: create a new role that:
- sets needed values in LocalSettings.php
- adds rewrites to apache vhost config
Augmenting LocalSettings is we documented and supported.
- See gerrit:78143 for a patch that makes it even easier
Messing with the vhost config is a little less easy. There are a couple ways it might be handled.
- The mediawiki class could be changed to take more parameters. This could be a simple flag for this feature or a more general system.
- The template for the vhost could be altered to read includes from some filesystem location into the <VirtualHost> scope.
I'm leaning towards the vhost reading include files approach. Here's what I think would be reasonable and extensible:
- new apache::site::include resource type
- This resource would ensure the availablity of an /etc/apache2/site-conf.d/[sitename]/ directory and manage adding a file to it
- modify mediawiki-apache-site.erb to include files from the site include dir
- add a usage of apache::site::include in role::thumb_on_404 to include needed rewrite rules
See gerrit:78260 for proposed solution. --BDavis (WMF) (talk) 18:56, 8 August 2013 (UTC)
- gerrit:78401 and gerrit:78409 superceeded gerrit:78260
- changes merged into master. There may still be some issues to correct re: scope of apache directives.