[NTG-context] 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 Informatikt: +1 (416) 937-9276 ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] Invoking ConTeXt from inside php web appliction
Dear Hraban, Sorry that this has taken me so long. The report card application has been deployed, and although I am still going through and resolving minor bugs, it is very much in use (350 students leaving on Tu who already have their foundation work marked and commented within the system; output via ConTeXt). Anyway, I have updated the Wiki, but am unsure if I missed anything. So can everyone have a look and let me know: http://wiki.contextgarden.net/ConTeXt_Standalone#Apache_webserver_installation Regards. > Henning Hraban Ramm texml at fiee.net > Fri Jun 17 20:49:11 CEST 2016 > > Please document this in the wiki (I had similar problems, should have done it at that time ) -- Pavneet Arora m: 647.406.6843 Waroc Informatikw: 416.937.9276 ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Invoking ConTeXt from inside php web appliction
On Fri, Jun 17, 2016 at 2:16 PM, 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); > > 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 ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Invoking ConTeXt from inside php web appliction
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 Informatikt: +1 (416) 937-9276 ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Invoking ConTeXt from inside php web appliction
On Fri, Jun 17, 2016 at 2:25 PM, Pavneet Arora wrote: > 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 -- luigi ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Invoking ConTeXt from inside php web appliction
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 wrote: > 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 Informatikt: +1 (416) 937-9276 ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Invoking ConTeXt from inside php web appliction
On Fri, Jun 17, 2016 at 2:42 PM, Pavneet Arora wrote: > 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 ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Invoking ConTeXt from inside php web appliction
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 Informatikt: +1 (416) 937-9276 ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Invoking ConTeXt from inside php web appliction
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 - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Invoking ConTeXt from inside php web appliction
Ah, we were thinking along the same lines! ;) I had just initiated a local install inside .../www/public when I received your email, which is in fact the DocumentRoot for this website, and did: $ chmod -R www-data:www-data context So ConTeXt is installed in .../www/public/context. Now I can source: $ . .../www/public/context/tex/setuptex .../www/public/context/tex and it all works. Many thanks, Luigi, for all of your suggestions. On 17Jun16, luigi scarso wrote: > (off list) > > On Fri, Jun 17, 2016 at 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'? > > > > Is it an option to make a context installation only for apache ? > I mean a context that is owned by www-data (if this is the apache user), > into a folder readable by apache. > > -- > luigi -- Pavneet Arora m: +1 (647) 406-6843 Waroc Informatikt: +1 (416) 937-9276 ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Invoking ConTeXt from inside php web appliction
Am 2016-06-17 um 20:57 schrieb Pavneet Arora : > $ chmod -R www-data:www-data context > > So ConTeXt is installed in .../www/public/context. > > Now I can source: > > $ . .../www/public/context/tex/setuptex .../www/public/context/tex > > and it all works. Please document this in the wiki (I had similar problems, should have done it at that time…) E.g. "Webserver_Setup", linked from http://wiki.contextgarden.net/ConTeXt_Standalone#Unix-like_platforms_.28Linux.2FMacOS_X.2FFreeBSD.2FSolaris.29 I’ll add my setup behind a Django/Nginx installation. Greetlings, Hraban --- http://www.fiee.net http://wiki.contextgarden.net https://www.cacert.org (I'm an assurer) GPG Key ID 1C9B22FD ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Invoking ConTeXt from inside php web appliction
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 ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Invoking ConTeXt from inside php web appliction
Am 2016-07-09 um 17:45 schrieb Pavneet Arora : > Sorry that this has taken me so long. The report card application has > been deployed, and although I am still going through and resolving minor > bugs, it is very much in use (350 students leaving on Tu who already have > their foundation work marked and commented within the system; output via > ConTeXt). Nice to hear about your success! In my case, my customer, a publisher of several special interest magazines, uploads lists of customers and their ad bookings into my web app and gets nicely TeXed voucher shipping documents. > Anyway, I have updated the Wiki, but am unsure if I missed anything. So > can everyone have a look and let me know: > http://wiki.contextgarden.net/ConTeXt_Standalone#Apache_webserver_installation I’m quite sure it’s a bad idea to install ConTeXt (or anything like that) in a public, i.e. web-accessible, directory! Even if I can’t imagine an attack via accessing files from the ConTeXt tree, experienced attackers might. I don’t use PHP any more, but I’m quite sure there’s a better way. I run ConTeXt from a Django (Python) web app behind Nginx, and there only static files (i.e. images, CSS etc.) are directly accessible, and I can call a system-wide installed ConTeXt owned by root (i.e. nobody else can change it). Greetlings, Hraban --- http://www.fiee.net http://wiki.contextgarden.net GPG Key ID 1C9B22FD ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Invoking ConTeXt from inside php web appliction
I believe that public in this case refers to public assets such as CSS, js, etc., where one puts custom files rather than publicly accessible, e.g., wp-uploads for WordPress. In the case of most frameworks, URL access is limited to specified routes only which point to controller methods. ConTeXt, when installed in this manner, can only be run as www-data:www-data, i.e., by httpd. I wasn’t able to get it work using any of the other suggestions. Is there another template you can suggest? Pavneet Arora m: +1 (647) 406-6843 e: pavneet_ar...@waroc.com From: Henning Hraban Ramm___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Invoking ConTeXt from inside php web appliction
In principle this is workable up to the point that the output PDF needs to be handed off to the user. In my case, it is the (authenticated) parent who is requesting their child’s report card in one of two forms each of which is created dynamically at any point along the school “term”. The user is waiting for the output PDF from the browser. In Laravel this is accomplished by using: return response()->download($full_output_filename)->deleteFileAfterSend(true); whereupon the end user sees the familiar Open, Save, … dialogue. But the dispatcher pattern is very useful, and I like it very much. In another area, I use it to monitor a directory for forms input, which are done off-line on W10 tablets using a browser and the Mongoose lightweight httpd, and then uploaded using sftp (under Cygwin). Thanks, again, for the suggestions. Pavneet Arora m: +1 (647) 406-6843 e: pavneet_ar...@waroc.com From: luigi scarso___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Invoking ConTeXt from inside php web appliction
> 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 ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___