Forum OpenACS Development: How to use PHP(libphp4.so)

Collapse
Posted by Nima Mazloumi on
Hi everybody,

has someone experience with using the PHP4 module with the aolserver?

I did the following changes to config.tcl but the php-files are return as simple text.

ns_param  php            ${bindir}/libphp4.so

ns_section ns/server/${server}/module/php
ns_param map /*.php
ns_param map /*.php3
ns_param map /*.php4

The libphp4.so is located in /opt/aolserver/bin together with all the other modules used by the aolserver.

Thank you very much for your help.

Greetings,
Nima

Collapse
Posted by Jonathan Ellis on
what does your logfile say on server startup?  if it's working you should see something about libphp4 successfully loaded.
Collapse
Posted by Nima Mazloumi on
This is what the server log says:
[06/Nov/2003:09:36:26][32019.16384][-main-] Notice: modload: loading '/opt/aolserver/bin/libphp4.so'
[06/Nov/2003:09:36:26][32019.16384][-main-] Notice: Registering PHP for "/*.php"
[06/Nov/2003:09:36:26][32019.16384][-main-] Notice: Registering PHP for "/*.php3"
[06/Nov/2003:09:36:26][32019.16384][-main-] Notice: Registering PHP for "/*.php4"

Also I am not sure how to add the extension mapping. .adp-files are mapped like this:

ns_section ns/server/${server}/adp
ns_param  map          /*.adp
ns_param  enableexpire  false
ns_param  enabledebug
ns_param  defaultparser fancy

But I found the following for php (with module) which registeres the php extensions above. With module in the path I don't get the registration notice.

ns_section ns/server/${server}/module/php
ns_param map /*.php
ns_param map /*.php3
ns_param map /*.php4

Now when I call a page without the extension .php only text outside of the php-tag is displayed. When I call a page with .php then I get the following error message:

Warning: Unknown(/www/unima0/www/servicecontractor/helloworld.php): failed to create stream: No such file or directory in Unknown on line 0

Warning: Unknown(): Failed opening '/www/unima0/www/servicecontractor/helloworld.php' for inclusion (include_path='.:/usr/share/php') in Unknown on line 0

Collapse
Posted by Jonathan Ellis on
well, yes, of course if you call a page w/o .php it's not going to send it to the php processor.  that's what your mapping says after all.

the only other thing you might want for your config is to add index.php to your directoryfile line.  but for the most part AOLServer is doing what you want, now you have to configure libphp correctly...  for instance does /usr/share/php exist and does the user you are running aolserver as have permissions for it?

Collapse
Posted by Nima Mazloumi on
Sorry! There must be a misunderstanding.

I wrote a simple php document:

<html>
<head>
  <title>PHP-Test</title>
</head>
<body>
Test:<?php echo "<p>Hallo Welt</p>"; ?>
</body>
</html>

Calling this page w/o .php returns:

Test:

Calling this page with .php returns:

Warning: Unknown(/www/unima0/www/servicecontractor/helloworld.php): failed to create stream: No such file or directory in Unknown on line 0

Warning: Unknown(): Failed opening '/www/unima0/www/servicecontractor/helloworld.php' for inclusion (include_path='.:/usr/share/php') in Unknown on line 0

I will check /usr/share/php

Collapse
Posted by Jonathan Ellis on
again,

ns_section ns/server/${server}/module/php
ns_param map /*.php
ns_param map /*.php3
ns_param map /*.php4

this means only .php .php3 or .php4 files will be handed off to the php processor.  "Calling this page w/o .php" SHOULD result in exactly no php interpretation and your browser will ignore the php tags leaving you with Test:.

Collapse
Posted by Nima Mazloumi on
So what does the No such file or directory Warning mean when I add the .php?

I added phph.ini to /usr/share/php but nothing happens.