[Pmwiki-users] PmWikiOnBoa CookBook
Carlo Strozzi
carlos
Mon Aug 4 07:22:57 CDT 2003
Hi,
I think I had a major success in getting PmWiki to use REST-style (*)
URIs also in a CGI-based setup, with the Boa web server in my case.
(*) http://internet.conveyor.com/RESTwiki/moin.cgi
Here's how it can be done. Be warned that I have not tested it thoroughly
yet, but preliminary tests have proven to work well, so I'm confident.
PHP can be run on Boa only as a CGI program, not as embedded server code.
There are probably many ways to accomplish the same results, but here is
how I did it:
1) I use cgiwrap, so that pmwiki runs as whatever user-level account
I like (let's say "goofy"), with much improved security I think.
2) Supposing your CGI scripts (including php4) are in /usr/lib/cgi-bin/ ,
and that cgiwrap is configured to look for CGIs into ~goofy/cgi-bin/ ,
here is a simple shell front-end to the whole movie :
$ cat ~goofy/cgi-bin/pmwiki.sh
#!/bin/sh
if [ -n "$PATH_INFO" ] # turn into QUERY_STRING
then
q="pagename=$(echo $PATH_INFO | sed 's,/,,;s,/,.,')"
[ -n "$QUERY_STRING" ] && QUERY_STRING="$q&$QUERY_STRING"
export QUERY_STRING
fi
export REDIRECT_STATUS=200 # needed to fool php4.
export PATH_INFO=/pmwiki.php
cd /home/goofy/cgi-bin/pmwiki # set proper working directory.
exec /usr/lib/cgi-bin/php4 "$@" # in case ISINDEX is allowed, dunno.
# EOF
For performance reasons my /bin/sh is a link to /bin/ash, but the
script will work just fine with any other bourne-workalike.
And here's how pmwiki is installed in ~goofy/cgi-bin/pmwiki/ :
$ ls -al ~goofy/cgi-bin/pmwiki/
drwxr-sr-x 6 goofy goofy 4096 Jul 30 16:17 .
drwxr-sr-x 3 goofy goofy 4096 Jul 28 14:41 ..
-rw-r--r-- 1 goofy goofy 18009 Feb 7 2002 COPYING
drwxr-sr-x 2 goofy goofy 4096 Jul 29 10:12 local
-rw-r--r-- 1 goofy goofy 26660 Jul 28 14:46 php.ini
-rw-r--r-- 1 goofy goofy 1037 Mar 4 07:35 pmwiki-50.gif
-rw-r--r-- 1 goofy goofy 15421 Jul 24 2002 pmwiki-50.psd
-rw-r--r-- 1 goofy goofy 39641 Jul 30 19:33 pmwiki.php
drwxr-sr-x 2 goofy goofy 4096 Jul 30 00:13 scripts
lrwxrwxrwx 1 goofy goofy 48 Jul 28 14:43 uploads -> /home/goofy/public_html/pmwiki/uploads
drwxr-s--- 2 goofy goofy 4096 Jul 30 00:14 wiki.d
drwxr-sr-x 2 goofy goofy 4096 Jul 24 00:27 wikilib.d
Note how the "uploads" directory points at an area that is accessible
to the web server for reading. And note also the "php.ini" file, that
needs to be configured according to your tastes/needs. I think the
most important setting in it is:
doc_root = /home/goofy/cgi-bin/pmwiki
It just looks complicated, but it isn't really all that much :-)
Given the above setup, your URL to enter PmWiki will be:
http://your.server/cgi-bin/cgiwrap/goofy/pmwiki.sh
So far, so good. But then php_sapi_name() in pmwiki.php will
detect that the calling interface is CGI, and use those ugly
QUERY_STRING settings to perform its job. But this is easy to
overcome: just set $EnablePathInfo=1; in your local.php and
path-based URIs will magically be used also with Boa (and
probably with other CGI-based setups).
Finally, pmwiki.php and upload.php should be modified to use both
"Location:" based redirections as well as html-based ones, as Partick
already knows. I attach my versions again, in case someone is going
to test the above.
comments will be most welcome.
Carlo
P.S.: Patrick, when/if you want me to turn this into a page on
http://www.pmichaud.com/wiki/ just let me know
--
For best reading please set the Courier font.
Freedom for Business: http://swpat.ffii.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pmwiki.php
Type: application/x-httpd-php
Size: 39715 bytes
Desc: not available
Url : http://contra.vosn.net/pipermail/pmwiki-users_pmichaud.com/attachments/20030804/f2dd6142/pmwiki-0001.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: upload.php
Type: application/x-httpd-php
Size: 8687 bytes
Desc: not available
Url : http://contra.vosn.net/pipermail/pmwiki-users_pmichaud.com/attachments/20030804/f2dd6142/upload-0001.bin
More information about the pmwiki-users
mailing list