There are similar questions but my set of configuration is not the same.I downloaded the wkhtmltopdf from wkhtmltopdf.org, placed on the project folder, i cant figure out why im still getting access denied.
Trying to point django to run the wkhtmltopdf
in order to generate a pdf file.
Running NGINX with UNICORN
Using SUPERVISOR
Ubuntu 16
in my unicorn_supervisor log i got:
Internal Server Error: /invoice/1/pdf
Traceback (most recent call last):emphasized text
File "/home/instantuser/app/lib/python3.5/site-packages/django/core/handlers/exception.py", line 39, in inner
response = get_response(request)
File "/home/instantuser/app/lib/python3.5/site-packages/django/core/handlers/base.py", line 217, in _get_respons e
response = self.process_exception_by_middleware(e, request)
File "/home/instantuser/app/lib/python3.5/site-packages/django/core/handlers/base.py", line 215, in _get_respons e
response = response.render()
File "/home/instantuser/app/lib/python3.5/site-packages/django/template/response.py", line 109, in render
self.content = self.rendered_content
File "/home/instantuser/app/lib/python3.5/site-packages/wkhtmltopdf/views.py", line 78, in rendered_content
cmd_options=cmd_options
File "/home/instantuser/app/lib/python3.5/site-packages/wkhtmltopdf/utils.py", line 186, in render_pdf_from_temp late
cmd_options=cmd_options)
File "/home/instantuser/app/lib/python3.5/site-packages/wkhtmltopdf/utils.py", line 124, in convert_to_pdf
return wkhtmltopdf(pages=filename, **cmd_options)
File "/home/instantuser/app/lib/python3.5/site-packages/wkhtmltopdf/utils.py", line 110, in wkhtmltopdf
return check_output(ck_args, **ck_kwargs)
File "/usr/lib/python3.5/subprocess.py", line 626, in check_output
**kwargs).stdout
File "/usr/lib/python3.5/subprocess.py", line 693, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied
The wkhtmltopdf file:
-rwxr-xr-x 1 instantuser instantuser 39804584 Nov 22 10:11 wkhtmltopdf
Unicorn process:
instant+ 2949 0.1 0.5 70344 23216 ? S 18:51 0:00 /home/instantuser/app/bin/python3 ../bin/gunicorn instanthst.wsgi:application --name instanthst --workers 3 --user=instantuser --group=instantuser --bind=unix:/home/instantuser/app/instanthst/run/gunicorn.sock --log-level=debug --log-file=-
instant+ 2954 0.3 1.2 171712 51992 ? S 18:51 0:00 /home/instantuser/app/bin/python3 ../bin/gunicorn instanthst.wsgi:application --name instanthst --workers 3 --user=instantuser --group=instantuser --bind=unix:/home/instantuser/app/instanthst/run/gunicorn.sock --log-level=debug --log-file=-
instant+ 2955 0.3 1.2 171704 51936 ? S 18:51 0:00 /home/instantuser/app/bin/python3 ../bin/gunicorn instanthst.wsgi:application --name instanthst --workers 3 --user=instantuser --group=instantuser --bind=unix:/home/instantuser/app/instanthst/run/gunicorn.sock --log-level=debug --log-file=-
instant+ 2957 0.3 1.2 171568 51960 ? S 18:51 0:00 /home/instantuser/app/bin/python3 ../bin/gunicorn instanthst.wsgi:application --name instanthst --workers 3 --user=instantuser --group=instantuser --bind=unix:/home/instantuser/app/instanthst/run/gunicorn.sock --log-level=debug --log-file=-
ubuntu 2970 0.0 0.0 12944 964 pts/0 S+ 18:53 0:00 grep --color=auto unicorn
NGINX Process
root 3006 0.0 0.0 125112 1460 ? Ss 18:55 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 3007 0.0 0.0 125436 3108 ? S 18:55 0:00 nginx: worker process
www-data 3008 0.0 0.1 125712 5060 ? S 18:55 0:00 nginx: worker process
ubuntu 3104 0.0 0.0 12944 940 pts/0 S+ 19:09 0:00 grep --color=auto nginx
Why am I getting access denied since the wkhtmltopdf file owner is the same running unicorn?
I'm able to run the command in the terminal but python cant run it. why?
I solve this problem by creating an shell script file to call the wkhtmltopdf.
wkhtmltopdf.sh
#!/bin/sh
xvfb-run -a -s "-screen 0 1024x768x16" wkhtmltopdf $*
Thank you all for the help.