Skip to main content

PHP working from shell, not from web page

  • September 26, 2019
  • 1 reply
  • 0 views

Apologies if there is an answer already in the other post about PHP not working - I looked and tried what I could to no avail.

I’ve got Rocket PHP working from the shell, installed in /Rocket/php/ :

MCZ:~/bin :  ll /Rocket/php/bin
total 107072
-rw-r--r--   1 JOCS065  OMVSGRP  18140978 Jun 14  2017 php
-rw-r--r--   1 JOCS065  OMVSGRP  17977181 Jun 14  2017 php-cgi
-rw-r--r--   1 JOCS065  OMVSGRP     3837 Jun 14  2017 php-config
-rw-r--r--   1 JOCS065  OMVSGRP    68855 Sep 26 11:46 php.ini
-rw-r--r--   1 JOCS065  OMVSGRP  18517848 Jun 14  2017 phpdbg
-rw-r--r--   1 JOCS065  OMVSGRP     4544 Jun 14  2017 phpize
MCZ:~/bin :  ll
total 34
-rwxr-xr-x   1 JOCS065  JOCS2         71 Sep 26 11:35 HelloWorld.php*
-rwxr-xr-x   1 JOCS065  20            51 Mar 22  2019 HelloWorld.py*
-rwxr-xr-x   1 JOCS065  JOCS2        278 Sep 25 11:20 unzip.sh*
MCZ:~/bin :  cat HelloWorld.php
#!/Rocket/php/bin/php
  echo "Hello World!";
  echo "PHP is so easy!";
MCZ:~/bin :  ./HelloWorld.php
Hello World!
PHP is so easy!

But when I try to run a PHP script fromthe apache server, I get (from the apache log)

EDC5130I Exec format error. (errno2=0xEF076015): [client 10.16.10.14:57693] couldn't create child process: 130: hello.php                                      
EDC5130I Exec format error. (errno2=0xEF076015): [client 10.16.10.14:57693] AH01223: couldn't spawn child process: /u/jocs065/ihsconfig/ihs/jocs065/cgi-bin/hel

This is my script:

#!/Rocket/php/bin/php
<?php 
print <<<eot
<html>
 <head>
  <title>PHP Test Page</title>
 </head>
 <body>
<h1>Hello World</h1>' 
 </body>
</html>
eot;
?>

I’ve done this:

Add the following lines to httpd.conf:

> ScriptAlias /php/ " /path/to/php/ "
> AddType application/x-httpd-php .php
> Action application/x-httpd-php “/php/bin/php-cgi”

Open php.ini and change cgi.fix_pathinfo to zero:

> cgi.fix_pathinfo=0

(from Customization server apache and php (Z/os V2r2))

(my scriptalias is actually : ScriptAlias /cgi-bin/ "/u/jocs065/ihsconfig/ihs/jocs065/cgi-bin/")

and I’m pretty sure that the web server is finding my script, it’s just refusing to run it.

I had php working at another site about 3 years ago, and I can’t think of anything else I had to do.

Just to add that previously I had it working using the info in the IBM HTTP server migration redbook but I didn’t need any of the ilphpNoSecure/ilphpSecure wrapper stuff.

And if anyone wants to say “Give up and use Python” then I’m all ears as we have that installed too if it’s easier

1 reply

  • 0 replies
  • September 27, 2019

Apologies if there is an answer already in the other post about PHP not working - I looked and tried what I could to no avail.

I’ve got Rocket PHP working from the shell, installed in /Rocket/php/ :

MCZ:~/bin :  ll /Rocket/php/bin
total 107072
-rw-r--r--   1 JOCS065  OMVSGRP  18140978 Jun 14  2017 php
-rw-r--r--   1 JOCS065  OMVSGRP  17977181 Jun 14  2017 php-cgi
-rw-r--r--   1 JOCS065  OMVSGRP     3837 Jun 14  2017 php-config
-rw-r--r--   1 JOCS065  OMVSGRP    68855 Sep 26 11:46 php.ini
-rw-r--r--   1 JOCS065  OMVSGRP  18517848 Jun 14  2017 phpdbg
-rw-r--r--   1 JOCS065  OMVSGRP     4544 Jun 14  2017 phpize
MCZ:~/bin :  ll
total 34
-rwxr-xr-x   1 JOCS065  JOCS2         71 Sep 26 11:35 HelloWorld.php*
-rwxr-xr-x   1 JOCS065  20            51 Mar 22  2019 HelloWorld.py*
-rwxr-xr-x   1 JOCS065  JOCS2        278 Sep 25 11:20 unzip.sh*
MCZ:~/bin :  cat HelloWorld.php
#!/Rocket/php/bin/php
  echo "Hello World!";
  echo "PHP is so easy!";
MCZ:~/bin :  ./HelloWorld.php
Hello World!
PHP is so easy!

But when I try to run a PHP script fromthe apache server, I get (from the apache log)

EDC5130I Exec format error. (errno2=0xEF076015): [client 10.16.10.14:57693] couldn't create child process: 130: hello.php                                      
EDC5130I Exec format error. (errno2=0xEF076015): [client 10.16.10.14:57693] AH01223: couldn't spawn child process: /u/jocs065/ihsconfig/ihs/jocs065/cgi-bin/hel

This is my script:

#!/Rocket/php/bin/php
<?php 
print <<<eot
<html>
 <head>
  <title>PHP Test Page</title>
 </head>
 <body>
<h1>Hello World</h1>' 
 </body>
</html>
eot;
?>

I’ve done this:

Add the following lines to httpd.conf:

> ScriptAlias /php/ " /path/to/php/ "
> AddType application/x-httpd-php .php
> Action application/x-httpd-php “/php/bin/php-cgi”

Open php.ini and change cgi.fix_pathinfo to zero:

> cgi.fix_pathinfo=0

(from Customization server apache and php (Z/os V2r2))

(my scriptalias is actually : ScriptAlias /cgi-bin/ "/u/jocs065/ihsconfig/ihs/jocs065/cgi-bin/")

and I’m pretty sure that the web server is finding my script, it’s just refusing to run it.

I had php working at another site about 3 years ago, and I can’t think of anything else I had to do.

Just to add that previously I had it working using the info in the IBM HTTP server migration redbook but I didn’t need any of the ilphpNoSecure/ilphpSecure wrapper stuff.

And if anyone wants to say “Give up and use Python” then I’m all ears as we have that installed too if it’s easier

Deleted as problem caused by a bad install.