Changes

Jump to navigation Jump to search
2,657 bytes added ,  15:40, 9 July 2016
m
Installation for web applications to be used with Apache.
For more information: [[Fonts in LuaTeX]]
 
== Apache webserver installation ==
 
Another common usecase is invoking ConTeXt from within a web application. Because web directories are often self-contained, and in the case of Apache under Ubuntu, ownership of the directory and its contents are assigned to a user and group without a login shell, e.g., <code>www-data:www-data</code> this prevents a web application from invoking a ConTeXt installation done using either the single-user or system-wide method listed above.
 
In this case the solution is to install ConTeXt within the website tree, and ideally in the public sub-tree. The public sub-tree is commonly the home directory for the application and relative pathnames are resolved as if immediately below it.
 
For example, in the case of the PHP web framework Laravel, ConTeXt can be installed alongside other assets in the <path-to-document-root>/public/context directory:
 
<pre>
cd <path-to-document-root>/public
mkdir context
cd context
wget http://minimals.contextgarden.net/setup/first-setup.sh
# Install the latest beta of ConTeXt
# This takes a long time, so go have a coffee
# Flags you can add to the first-setup.sh call:
# --modules=all # Install all third-party modules
# --context=current # Install latest stable version
# --engine=luatex # Install only MkIV, leave out MkII
# # This shrinks the install from 270 MB to 200 MB
 
sh ./first-setup.sh --modules=all
</pre>
 
Once installed, you need to ensure that the permissions are correct for Apache to be able to access it (you will either need <code>sudo</code> privileges or root access):
 
<pre>
$ cd <path-to-document-root>/public
$ sudo chmod -R www-data:www-data context
</pre>
 
Now as part of your application's invocation of ConTeXt, you will need to set up the shell environment. This is easily done by creating a simple BASH shell script, also to be installed in the public part of the document tree:
 
<pre>
#!/usr/bin/env bash
 
#
# proccontext.sh
#
# To be installed in <path-to-document-root>/public/bin
 
. <path-to-document-root>/public/context/tex/setuptex <path-to-document-root>/public/context/tex
 
cd tex/spool
context $1 > /tmp/context_run.log
</pre>
 
Here the dynamically generated ConTeXt source file is expected to be found in the <code><path-to-document-root>/tex/spool</code> directory.
 
Now within your application, you can invoke this shell script (in this case using PHP):
 
<pre>
$cmd = "bin/proccontext.sh $input_filename";
$last_line = system($cmd, $ret_val);
</pre>
 
And the output will once again be found in <code><path-to-document-root>/tex/spool</code>.
==Arch Linux==

Navigation menu