JHP can be configured locally for the content folder, or globally on server level with necessary permisions.
profile.ijs is modified to recognize the event of CGI invokation and diverting te processing to JHP. The following code is added to the end of profile.ijs:
0!:0 <jhostpath add, '\jhp\run.ijs'
For UNIX, CGI wrapper jhp.sh, populates two environment variables for physical path of the requested page and J path. Then it just invokes jconsole. Spacifically, in bash, it has the following code:
#!/bin/sh export PATH_TRANSLATED=`echo $SCRIPT_URL | sed -e 's|url_prefix|server_path|'` export JPATHj601=/path_to/j601 $JPATHj601/jconsole
Where url_prefix
is part of URL to be mapped,
server_path
is physical path it maps to, and
path_to
is actual location of J installation.
To handle different directories, you can either create a smart regex
or multiple wrapper scripts.
The web directory is configured so that on request to any
page the .jhp
extension, jconsole (or its wrapper
on UNIX) is called.
Web site base location is /home/groups/mysite/
with URL http://mysite.server.com/
. CGI folder is
/home/groups/mysite/cgi-bin
. Content folder is
/home/groups/mysite/htdocs
.
/cgi-bin/jhp.sh
#!/bin/sh export PATH_TRANSLATED=`echo $SCRIPT_URL | sed -e 's|^/|/home/groups/mysite/htdocs/|'` export JPATHj601=/home/groups/mysite/j601 $JPATHj601/jconsole
/home/groups/mysite/htdocs/jhp/.htaccess
RewriteEngine on RewriteBase /jhp/ RewriteRule .*\.jhp /cgi-bin/jhp.sh
Alternative .htaccess option is
ScriptAliasMatch .*\.jhp /cgi-bin/jhp.sh
It is assumed that J is installed in /Users/user/j601 (or other version in place of 601). There is a user's personal web site http://localhost/~user/ located at /Users/user/Sites.
Make sure the following lines are uncommented in /private/etc/httpd/httpd.conf
LoadModule cgi_module libexec/httpd/mod_cgi.so LoadModule alias_module libexec/httpd/mod_alias.so AddModule mod_cgi.c AddModule mod_alias.c
Edit /private/etc/httpd/users/user.conf (you will need sudo permissions) to have the following.
<Directory "/Users/user/Sites/"> Options Indexes MultiViews AllowOverride AuthConfig Indexes Order allow,deny Allow from all </Directory> <IfModule mod_alias.c> ScriptAliasMatch .*\.jhp /Users/user/j601/jhp.sh </IfModule>
Copy to config/jhp_mac.sh to /Users/user/j601/jhp.sh, make sure it has chmod 755 and edit its contents to have
#!/bin/sh export PATH_TRANSLATED=`echo $SCRIPT_URL | sed -e 's|^/~\([^/]*\)|/Users/\1/Sites|'` export JPATHj601=/Users/user/j601 $JPATHj601/jconsole
Restart the Apache web server. Navigate http://localhost/~user/jhp.
If you encounter server errors, see Logs|var/log/httpd/error_log in Utilities/Console application.
It is only necessary to create a mapping from .jhp files to call jconsole.exe
#!/bin/sh echo "Content-Type: text/plain" echo "" env exit
NB. 0!:0 <jhostpath add, '\jhp\run.ijs' echo 'Content-Type: text/plain',CRLF,CRLF,'test2',CRLF exit ''
({.a.) (1!:12) ::] fn;0 NB. 12 not 2 (9!:47) ::] fn
require 'libpath' ... elseif. UNAME-:'Linux' do. gl=: find_dll 'GL' glu=:find_dll 'GLU'