PHP script fails when called from browser, but not from CLI

It drives me crazy.

I reduced my problem to this: I have a simple test.php file that calls a php file (this is from a larger application, so in fact we need to execute a lot of php scripts from the main script):

<?php

 exec("php /var/www/setActive.php 273 1 2>&1",$arO,$nO);
echo $nO.'|'.implode(',',$arO);

The source path for setActive.php is longer, I shortened it for this example.

Now if I try:

[root@stg]# sudo -u apache php test.php

I get:

0|

Great, that means the setActive.php script runs smoothly.

Now, if I try it from a browser or from curl:

[root@stg]#curl http://my.url/path/test.php

This is what I get:

1|Could not open input file: /var/www/setActive.php

I have already looked through all the permissions. The Apache user has access to all directories and files. This worked fine on another server. I looked at the php.ini files and there is no difference between them.

, , , apache. .

, !

.

Linux, Cent OS. PHP 5.3.23

+4
1

.. , , apache. "ChrootDir":

http://httpd.apache.org/docs/2.2/mod/mpm_common.html#chrootdir

syscall chroot() '/' dir , , , .

0

Source: https://habr.com/ru/post/1533448/


All Articles