500 error
Hello!
I'm trying to see if wxhtmltox could replace html2pdf lib in Simple Invoices application.
phpinfo shows that extension is enabled (0.10.0_beta5 ), but loading test_pdf.php script gives 500 error (Cherokee server).
Any hint how to troubleshoot it?
Here is the trace: http://pastebin.com/cQbaSqcS
make sure the process that the script is running as is able to write to the directory where the test.pdf is being written.
try changing the output directory to /tmp/test.pdf and see if that works
I set dir to 777 and there is still problem.
However, after changing setup in my server to use php-cgi instead of php-fpm, I've found the following in my error.log file:
wkhtmltox: cannot connect to X server
this is actually an issue with the library this extension wraps, libwkhtmltox. It requires that you have the X11 libs installed (but does not require an X11 server to be running)
Try installing X11 libs...
this is actually an issue with the library this extension wraps, libwkhtmltox. It requires >that you have the X11 libs installed (but does not require an X11 server to be running)
but i'm testing on full-fledged X desktop running LXDE on my desktop (localhost) machine, so, X11 libs are installed.
can you confirm that the command line version of wkhtmltopdf works correctly?
Did you compile libwkhtmltox from source?
can you confirm that the command line version of wkhtmltopdf works correctly?
[gour@atmarama gour] wkhtmltopdf http://simpleinvoices.org/ si.pdf
Loading page (1/2)
Printing pages (2/2)
Done
Did you compile libwkhtmltox from source?
yes
what about trying to run wkhtmltopdf (CLI version) as the same user that php-fcgi runs as? I'm guessing that user isn't allowed to access the X11 server...
what about trying to run wkhtmltopdf (CLI version) as the same user that php-fcgi runs as? I'm guessing that user isn't allowed to access the X11 server...
well, i executed wkhtmltopdf as user 'gour' and here is the part of 'ps -ef' output:
gour 8371 4700 0 07:11 ? 00:00:01 /usr/sbin/cherokee-worker gour 8414 4700 0 07:11 ? 00:00:00 /usr/bin/php-cgi -b 127.0.0.1:47990 gour 8417 8414 0 07:11 ? 00:00:00 /usr/bin/php-cgi -b 127.0.0.1:47990 gour 8418 8414 0 07:11 ? 00:00:00 /usr/bin/php-cgi -b 127.0.0.1:47990 gour 8419 8414 0 07:11 ? 00:00:00 /usr/bin/php-cgi -b 127.0.0.1:47990 gour 8420 8414 0 07:11 ? 00:00:00 /usr/bin/php-cgi -b 127.0.0.1:47990 gour 8515 8414 0 07:15 ? 00:00:00 /usr/bin/php-cgi -b 127.0.0.1:47990
so you can see that php-cgi runs as 'gour' as well as Cherokee webserver.
Any idea?
what happens when you run the test_pdf.php script from the command line:
$ php test_pdf.php
Also - in the wkhtmltopdf tree theres a directory called examples - make it. It will produce a binary, pdf_c_api, that tests usage of libwkhtmltox.
what happens when you run the test_pdf.php script from the command line:
$ php test_pdf.php
Nothing, iow. no errors.
Also - in the wkhtmltopdf tree theres a directory called examples - make it. It will produce a binary, pdf_c_api, that tests usage of libwkhtmltox.
[gour@atmarama examples] ./pdf_c_api Loading page Printing pages Done httpErrorCode: 0
Anything else?
can you run a single worker instance of php-cgi and produce a strace or gdb output of what it's trying to do when that script is run?
Here it s: http://pastebin.com/PubrADFT (strace.log), but being quite new with strace, I'm not sure if it will be useful.
or this one: http://pastebin.com/FNJ3t9m0
i've updated the git repository to address this issue
please recompile, test, and confirm it's working correctly
I've tried, but have problem...
Here is the snippet from ./configure:
checking for libwkhtmltox support... yes, shared
found in /usr
checking for wkhtmltopdf_init in -lwkhtmltox... yes
which, imho, looks good, but 'make install' fails:
[gour@atmarama php-wkhtmltox] su -c "make install"
Password:
/bin/sh /home/gour/repos/git/php-wkhtmltox/libtool --mode=compile cc -I. -I/home/gour/repos/git/php-wkhtmltox -DPHP_ATOM_INC -I/home/gour/repos/git/php-wkhtmltox/include -I/home/gour/repos/git/php-wkhtmltox/main -I/home/gour/repos/git/php-wkhtmltox -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /home/gour/repos/git/php-wkhtmltox/phpwkhtmltox.c -o phpwkhtmltox.lo
mkdir .libs
cc -I. -I/home/gour/repos/git/php-wkhtmltox -DPHP_ATOM_INC -I/home/gour/repos/git/php-wkhtmltox/include -I/home/gour/repos/git/php-wkhtmltox/main -I/home/gour/repos/git/php-wkhtmltox -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /home/gour/repos/git/php-wkhtmltox/phpwkhtmltox.c -fPIC -DPIC -o .libs/phpwkhtmltox.o
/home/gour/repos/git/php-wkhtmltox/phpwkhtmltox.c: In function ‘zm_shutdown_phpwkhtmltox’:
/home/gour/repos/git/php-wkhtmltox/phpwkhtmltox.c:27:9: error: wkhtmltoimage_initialized’ undeclared (first use in this function)
/home/gour/repos/git/php-wkhtmltox/phpwkhtmltox.c:27:9: note: each undeclared identifier is reported only once for each function it appears in
/home/gour/repos/git/php-wkhtmltox/phpwkhtmltox.c: In function ‘zif_wkhtmltox_convert’:
/home/gour/repos/git/php-wkhtmltox/phpwkhtmltox.c:106:14: error: ‘wkhtmltoimage_initialized’ undeclared (first use in this function)
make: *** [phpwkhtmltox.lo] Error 1
gour, I've corrected this error, please pull and try again.
thanks.
Build works now, but, again, I get 500 error.