Don't get it to work on nginx in a subdir
wottpal opened this issue · 9 comments
Hey Fabian,
I've tried your plugin on my apache local dev environment and it works like a charm. But on my nginx-webserver it stucks at scanning through all pages. (It doesn't even start I think)
I have it running in a sub-directory, maybe that causes some problems, but actually I never had any problems with this nginx-conf:
#####################
#####################
# KIRBY-CONFIGURATION #
# block content
location ~ ^/normannenhaus/content/(.*).(txt|md|mdown)$ {
rewrite ^/normannenhaus/content/(.*).(txt|md|mdown)$ /error redirect;
}
# block all files in the site folder from being accessed directly
location ~ ^/normannenhaus/site/(.*)$ {
rewrite ^/normannenhaus/site/(.*)$ /error redirect;
}
# block all files in the kirby folder
location ~ ^/normannenhaus/kirby/(.*)$ {
rewrite ^/normannenhaus/kirby/(.*)$ /error redirect;
}
# site links
location ~ /normannenhaus {
autoindex off;
try_files $uri $uri/ /normannenhaus/index.php?$uri&$args;
auth_basic "Restricted Content";
auth_basic_user_file /etc/nginx/.htpasswd;
# (Also tried it without password-protection)
}
# panel links
location ~ /normannenhaus/panel {
try_files $uri $uri/ /normannenhaus/panel/index.php?$uri&$args;
}
# deny access to .htaccess files
location ~ /\.ht {
deny all;
}
#####################
#####################
This is how it looks in the panel:
(FYI there are way more than 29 images)
This is how images are looking:
This is an excerpt from my site-config in kirby:
/**
* Server-Configuration
*/
c::set('url', 'https://beta.wottpal.com/normannenhaus');
c::set('subfolder', '/normannenhaus');
I am also running on HTTPS if that helps any further.
Thanks in advance!
Dennis
Hey @dkerzig,
at least you routing setup should be fine, as otherwise ImageKit could not display those red error images. These errors are mostly caused by:
- Insufficient permissions on the thumbs folder
- PHP does not have enough memory avalable for processing large images. This error usually only occurs when using the GD libary for thumbnail creation. (see you error log for messages like "PHP Fatal error: Allowed memory size of […] bytes exhausted". If you’re already on Kirby 2.4, my error images do not always show up, because ImageKit’s error-handling seems to interefere with the new implemented one of Kirby, I have to further investigate this. But if there are no errors, it should not cause any other problems.
- If you use ImageMagick, you might have to set the correct path to the executable in your config.php
Please check all of those 3 possibilities.
To provide you some help with the admin panel, if would be very helpful, if you could open the dev tools of you browser, catching all AJAX/XHR requests done by the widget. Please check the responses. If there’s something suspicious, please tell me.
If nothing of that works, I would be great, if you could give me temporary access to your panel, so I can have a look.
Hi Fabian,
so one part of the problem is solved. It turned out that in my freshly installed php7-environment the gd-package was not installed by default and I had to do this manually. (If somebody stumbles into the same: sudo apt-get install php7.0-gd
.)
Now there are no longer these red warning thumbs an all seems to be properly generated if I open the specific page. Unfortunately the discovery & generation in the panel-widget still has the same problem :/
I will do some AJAX-debugging in the next days and will post my results here :)
Thanks for your help,
Dennis
Hey Dennis, nice to hear that you could solve at least one part of the plugin. If anyway, if you’re able to install whatever you like on your server, I can only recomend to use ImageMagick instead of GD library. Image Quality, Speed and possibilities of optimization are far greater, that with the GD library (especially when combining it with the optimizers of the upcoming ImageKit 1.1).
I’m excited to hear about your AJAX-debugging results.
Cheers
Fabian
Hey Fabian,
I installed ImageMagick via sudo apt-get install php-imagick
and set the following in my config: c::set('imagekit.driver', 'im')
. Still the same problem.
I made a screenshot of the console JS-error and XHR-requests when I click the generate-button. (The first XHR request in the list is made before that click).
I've also created a login for you to the server & panel and will send you a pm shortly :)
Dennis
Hey Dennis,
using ImageMagick has nothing todo with the panel widget, as it is only another backend for Kirby to process thumbnails. ImageKit uses Kirby’s built-in Thumb class as well as the built-in driver. Also, Kirby does not use PHPs Imagick-extension, but the ImageMgick command-line utility. In order to activate ImageMagick, your have to install the CLI tools on your server, those are completely independent from PHP. And you have to activate it in your config.php like this:
c::set('thumbs.driver','im');
c::set('thumbs.bin', '/usr/local/bin/convert');
I trief to investigate into your wigdet issue, but I cannot solve it so far. there are several HTML errors in the page "kontakt", but when I copied the code into an empty template on my test server, it worked. Maybe I could have a look at your template code. Did you turn on debugging in your config file/could you find something in the PHP error log file?
BTW: Kirby 2.4 will introduce a new improved error handling interface as well as the content represenations. These changes are partially in conflict with the ImageKit widget. That means, error handling needs a few adaptions be further improved. But as your site uses Kirby 2.3.2, this should not be an issue.
Hi Fabian,
it's so curious that everything works fine on both my local and the production apache. This is the error.log from the nginx-environment:
2016/10/19 09:21:06 [error] 20679#20679: *111 FastCGI sent in stderr: "PHP message: PHP Warning: Cannot modify header information - headers already sent by (output started at /var/www/beta.wottpal.com/normannenhaus/kirby/toolkit/lib/f.php:752) in /var/www/beta.wottpal.com/normannenhaus/site/plugins/imagekit/lib/complainingthumb.php on line 152
PHP message: PHP Warning: Cannot modify header information - headers already sent by (output started at /var/www/beta.wottpal.com/normannenhaus/kirby/toolkit/lib/f.php:752) in /var/www/beta.wottpal.com/normannenhaus/site/plugins/imagekit/lib/complainingthumb.php on line 153
PHP message: PHP Warning: Cannot modify header information - headers already sent by (output started at /var/www/beta.wottpal.com/normannenhaus/kirby/toolkit/lib/f.php:752) in /var/www/beta.wottpal.com/normannenhaus/site/plugins/imagekit/lib/complainingthumb.php on line 154
PHP message: PHP Warning: Cannot modify header information - headers already sent by (output started at /var/www/beta.wottpal.com/normannenhaus/kirby/toolkit/lib/f.php:752) in /var/www/beta.wottpal.com/normannenhaus/site/plugins/imagekit/lib/complainingthumb.php on line 163" while reading upstream, client: 178.62.248.166, server: beta.wottpal.com, request: "GET /normannenhaus/thumbs/veranstaltungen/voita-cd-release-party/dsc09959-400x266-47-26.jpg HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "beta.wottpal.com", referrer: "https://beta.wottpal.com/normannenhaus/"
2016/10/19 10:17:08 [error] 20679#20679: *124 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Class 'DOMDocument' not found in /var/www/beta.wottpal.com/normannenhaus/site/plugins/imagekit/widgets/imagekit/lib/api.php:62
Stack trace:
#0 [internal function]: Kirby\Plugins\ImageKit\Widget\API->Kirby\Plugins\ImageKit\Widget\{closure}('<!DOCTYPE html>...', 9)
#1 {main}
thrown in /var/www/beta.wottpal.com/normannenhaus/site/plugins/imagekit/widgets/imagekit/lib/api.php on line 62" while reading response header from upstream, client: 94.219.203.145, server: beta.wottpal.com, request: "GET /normannenhaus/kontakt HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "beta.wottpal.com", referrer: "https://beta.wottpal.com/normannenhaus/panel/"
2016/10/19 10:17:26 [error] 20679#20679: *135 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Class 'DOMDocument' not found in /var/www/beta.wottpal.com/normannenhaus/site/plugins/imagekit/widgets/imagekit/lib/api.php:62
Stack trace:
#0 [internal function]: Kirby\Plugins\ImageKit\Widget\API->Kirby\Plugins\ImageKit\Widget\{closure}('<!DOCTYPE html>...', 9)
#1 {main}
thrown in /var/www/beta.wottpal.com/normannenhaus/site/plugins/imagekit/widgets/imagekit/lib/api.php on line 62" while reading response header from upstream, client: 94.219.203.145, server: beta.wottpal.com, request: "GET /normannenhaus/kontakt HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "beta.wottpal.com", referrer: "https://beta.wottpal.com/normannenhaus/panel/"
2016/10/19 11:34:53 [error] 20679#20679: *160 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Class 'DOMDocument' not found in /var/www/beta.wottpal.com/normannenhaus/site/plugins/imagekit/widgets/imagekit/lib/api.php:62
Stack trace:
#0 [internal function]: Kirby\Plugins\ImageKit\Widget\API->Kirby\Plugins\ImageKit\Widget\{closure}('<!DOCTYPE html>...', 9)
#1 {main}
thrown in /var/www/beta.wottpal.com/normannenhaus/site/plugins/imagekit/widgets/imagekit/lib/api.php on line 62" while reading response header from upstream, client: 94.219.203.145, server: beta.wottpal.com, request: "GET /normannenhaus/kontakt HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "beta.wottpal.com", referrer: "https://beta.wottpal.com/normannenhaus/panel/"
I have send you a bundle of my site via mail, if you want to investigate further. Templates and Snippets are in the /src/site/ folder and you can compile it easily via gulp dist
if you've done a npm install
. Then you obviously need an apache/nginx to test :)
Thank you,
Dennis
And a note on the kontakt
, veranstaltungen
and buchen
-pages: They all go for the default template which results in an empty page. I only use them embedded in my home-page via snippets.
PHP Fatal error: Uncaught Error: Class 'DOMDocument' not found in /var/www/beta.wottpal.com/normannenhaus/site/plugins/imagekit/widgets/imagekit/lib/api.php:62
Do you have the DOM module of PHP installed? ImageKit uses it to scan throught pages. This would explain a lot …
I've installed the dom-module via sudo apt-get install php-xml
, restarted my server and now it works.
Is there a way to do any kind of feature-detection so you could display these kind of problems as a warning in the panel-widget? I really wonder why all these packages (php7.0-gd
and php-xml
) were not included by default in my php7 installation :/ Or just include it in the Troubleshooting-Section.
Thank you so much!
🎉🎉🎉🎉🎉🎉🎉
OT: Really looking forward to future updates and your responsive-plugin (currently I use a handcrafted solution like you can see in the bundle I've send. I particularly mean src/site/plugins/responsify
for cropping responsive versions via the focusCrop-plugin and src/js/lazy-img.js
for lazy-loading.
For example I use it to generate images in /src/site/snippets/components.event-card.php
just if you are curious. :)
Dennis