Invoking ConTeXt from inside php web appliction
I am stuggling with getting ConTeXt to run from inside a php script under Apache. First off, let me say that the installation works fine from the command line as a logged in user. Initially, I tried to do it inline: cmd = ". /opt/context/tex/setuptex /opt/context/tex/setuptex; cd $spool_dir; context $full_input_filename"; system($cmd); which returns exit status 2, "Incorrect usage". Then I created a small bash script with the following lines: #!/usr/bin/env bash . /opt/context/tex/setuptex /opt/context/tex context $1 When I trap the output, I get the following error in the log file: resolvers | caches | fatal error: there is no valid writable cache path defined I also attempted this manually at a bash prompt resulting in the same error: sudo -u www-data bash -c bin/proccontext.sh $FILENAME What would be the correct design pattern to invoke ConTeXt from a web application? This is all under Ubuntu 14.04, BTW. advTHANKSance -- Pavneet Arora m: +1 (647) 406-6843 Waroc Informatik t: +1 (416) 937-9276
On Fri, Jun 17, 2016 at 2:16 PM, Pavneet Arora
I am stuggling with getting ConTeXt to run from inside a php script under Apache. First off, let me say that the installation works fine from the command line as a logged in user.
Initially, I tried to do it inline:
cmd = ". /opt/context/tex/setuptex /opt/context/tex/setuptex; cd $spool_dir; context $full_input_filename"; system($cmd);
which returns exit status 2, "Incorrect usage".
Then I created a small bash script with the following lines:
#!/usr/bin/env bash
. /opt/context/tex/setuptex /opt/context/tex context $1
When I trap the output, I get the following error in the log file:
resolvers | caches | fatal error: there is no valid writable cache path defined
I also attempted this manually at a bash prompt resulting in the same error:
sudo -u www-data bash -c bin/proccontext.sh $FILENAME
What would be the correct design pattern to invoke ConTeXt from a web application? This is all under Ubuntu 14.04, BTW.
advTHANKSance
permissions ? -- luigi
That is what I suspect as well. How do I find out which cache path is being used? Thanks. On 17Jun16, luigi scarso wrote:
On Fri, Jun 17, 2016 at 2:16 PM, Pavneet Arora
wrote: ... When I trap the output, I get the following error in the log file:
resolvers | caches | fatal error: there is no valid writable cache path defined
I also attempted this manually at a bash prompt resulting in the same error:
sudo -u www-data bash -c bin/proccontext.sh $FILENAME
What would be the correct design pattern to invoke ConTeXt from a web application? This is all under Ubuntu 14.04, BTW.
advTHANKSance
permissions ?
-- luigi
-- Pavneet Arora m: +1 (647) 406-6843 Waroc Informatik t: +1 (416) 937-9276
That is what I suspect as well. How do I find out which cache path is being used?
I'm using Debian+ConTeXt+Apache+PHP. I've struggled a bit to make it work, but now it works. It works even inside a docker container. In my PHP code I've put this: putenv("TEXMFCACHE=/var/cache/context/texmf-cache"); This forces ConTeXt to use that directory as cache. Then I made /var/cache/context/texmf-cache world-writable: chmod ugo+rwx /var/cache/context/texmf-cache Perhaps it's not the best choice for security. Try that and tell me if it works. Best regards, Massi
Unfortunately, while the mtxrun command works for a shell user:
$ mtxrun -script base --variables | grep cache
resolvers | lists | env: $SELFAUTOPARENT/texmf-cache
resolvers | lists | var: $SELFAUTOPARENT/texmf-cache
resolvers | lists | exp: /opt/context/tex/texmf-cache
resolvers | lists | res: /opt/context/tex/texmf-cache
the result is the same for www-data:
$ sudo -u www-data bash -c ". /opt/context/tex/setuptex /opt/context/tex; mtxrun --script base --variables | grep cache"
resolvers | caches | fatal error: there is no valid writable cache path defined
I have to think that setuptex isn't able to set up the runtime
environment for www-data, somehow?
On Fri, Jun 17, 2016 at 2:25 PM, Pavneet Arora
That is what I suspect as well. How do I find out which cache path is being used?
Thanks.
$ mtxrun --script base --variables |grep cache -- Pavneet Arora m: +1 (647) 406-6843 Waroc Informatik t: +1 (416) 937-9276
On Fri, Jun 17, 2016 at 2:42 PM, Pavneet Arora
Unfortunately, while the mtxrun command works for a shell user:
$ mtxrun -script base --variables | grep cache resolvers | lists | env: $SELFAUTOPARENT/texmf-cache resolvers | lists | var: $SELFAUTOPARENT/texmf-cache resolvers | lists | exp: /opt/context/tex/texmf-cache resolvers | lists | res: /opt/context/tex/texmf-cache
the result is the same for www-data:
$ sudo -u www-data bash -c ". /opt/context/tex/setuptex /opt/context/tex; mtxrun --script base --variables | grep cache" resolvers | caches | fatal error: there is no valid writable cache path defined
I have to think that setuptex isn't able to set up the runtime environment for www-data, somehow?
Is texmf-cache writable by www-data ? When logged as www-data, the cache writable should be the /home/www-data/luatex-cache/<..> folder, while the standard one is used as readonly folder Just make a test: in www-data home # . /opt/context/tex/setuptex /opt/context/tex then make a simple "Hello world" test.tex and read the log. -- luigi
That is really the crux of the issue, since www-data does *not* have a login shell. It is used only by apache. Can setuptex be made to point to the home directory explicitly where the website is housed, e.g., '/home/wwwuser' with user 'wwwuser'? On 17Jun16, luigi scarso wrote:
Is texmf-cache writable by www-data ? When logged as www-data, the cache writable should be the /home/www-data/luatex-cache/<..> folder, while the standard one is used as readonly folder
Just make a test: in www-data home # . /opt/context/tex/setuptex /opt/context/tex then make a simple "Hello world" test.tex and read the log.
-- Pavneet Arora m: +1 (647) 406-6843 Waroc Informatik t: +1 (416) 937-9276
On 6/17/2016 3:39 PM, Pavneet Arora wrote:
That is really the crux of the issue, since www-data does *not* have a login shell. It is used only by apache.
Can setuptex be made to point to the home directory explicitly where the website is housed, e.g., '/home/wwwuser' with user 'wwwuser'?
On 17Jun16, luigi scarso wrote:
Is texmf-cache writable by www-data ? When logged as www-data, the cache writable should be the /home/www-data/luatex-cache/<..> folder, while the standard one is used as readonly folder
Just make a test: in www-data home # . /opt/context/tex/setuptex /opt/context/tex then make a simple "Hello world" test.tex and read the log.
you can try /pathtomtxrun/mtxrun --tree=/home/tex context .... Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On 17 June 2016 at 14:16, Pavneet Arora wrote:
I am stuggling with getting ConTeXt to run from inside a php script under Apache. First off, let me say that the installation works fine from the command line as a logged in user.
Initially, I tried to do it inline:
cmd = ". /opt/context/tex/setuptex /opt/context/tex/setuptex; cd $spool_dir; context $full_input_filename"; system($cmd);
Unrelated to the problem, but ... Instead of sourcing setuptex you should just add /opt/context/tex/texm-linux64 (or whawever folder that is) to the environmental variable PATH. The setuptex script doesn't do anything else and is just a convenience script for users. In scripting you should better set PATH. You can also manually set TEXMFCACHE if you want. Not that it matters much, but I don't know why one would want the overhead of running an additional script each time. Mojca
participants (5)
-
Hans Hagen
-
luigi scarso
-
massifr@fastwebnet.it
-
Mojca Miklavec
-
Pavneet Arora