The trouble I am having is getting to connect to PHP from the HTTP Server. I am new to PHP and I tried to understand from the distributed world on how the two are paired together, i.e. Apache Server and PHP. It seems to be fairly straight forward in that world.
There seem to be two ways of invoking PHP with Apache (1) PHP as Dynamic Shared Object (DSO) application and the other as Common Gateway Interface (CGI). The recommended way seems to be the DSO. To go the DSO way some directives in Apache need to be set like the LoadModule Directive which looks like
LoadModule php5_module /usr/local/apache/lib/lipphp5.so
But I can't seem to find any modules ending in .so within the PHP installation I did using Miniconda from Rocket. Apparently in Linux world the PHP compile puts the libphp5.so file in places like
/usr/lib/httpd/modules
I do not find any such path or directory on z/OS
Then the other Apache Directive like below
AddType application/x-httpd-php .php
to associate files ending in .php as PHP programs. I did add that directive, in addition I also added
Action application/x-httpd-php <path-to-my-php-bin-where-my-php-binary-resides>
Then I put my helloworld.php program in the Document Root directory of the IBM HTTP Server but I could not get my simple helloworld.php program working. When I try accessing helloworld.php from my browser as http://<IP-address>/helloworld.php I get HTTP 404 page not found error. My hello.php program looks like this
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World. This is my first php program</p>'; ?>
</body>
</html>
I then changed the extension of the script file and renamed it as hellp.html instead of hello.php and I ended up with a blank HTML web page in the browser. I viewed the source of the blank web page (right click mouse and choose View Source) and I see that the above code in the program/script was sent to the browser as-is without being sent to php parser. So in essence the HTTP Server did not kick in the PHP processor at all.
So I thought I will try accessing helloworld.php as a CGI application and add the shebang
#!/usr/lpp/php/bin/php
as the first line of my hello.php program so that HTTP server simply picks up the php binary path and passes the rest of the php script to it. I got a 500 HTTP severe error code and when I looked at the HTTP Server log I see the following message in it. I masked the actual IP Address with xxx.xx.xx.xx below.
[cgi:error] [pid 384:tid 2931157262162460675] [client xxx.xx.xx.xx:51402]End of script output before headers: php
so my attempt at running it as a CGI script also fell apart. I am seeking help to understand:
- What are the configuration directives I need in httpd.conf so that I can run my PHP applications from within/via the IBM HTTP server
- How can I run PHP as a (a) DSO application and as (b) CGI application ? What should be my HTTP Server settings/directives for both scenarios.
- Is there something I should do on the PHP side a well?
Thank you very much in advance for any help
Nagaraj