|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19552 path is always where php was compiled
Submitted: 2002-09-22 16:53 UTC Modified: 2002-09-24 23:45 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: sproctor at ccs dot neu dot edu Assigned:
Status: Not a bug Package: Apache2 related
PHP Version: 4.2.3 OS: linux
Private report: No CVE-ID: None
 [2002-09-22 16:53 UTC] sproctor at ccs dot neu dot edu
$_ENV['PWD'] always returns /home/sproctor/php-4.2.3 (where php was compiled).  I expect it to be /var/www/reliance/pn (where the script is run from).  I compiled php with apxs2 and apache 2.0.40.

It's not just the variable that's wrong, but doing something like include "filename" will search in /home/sproctor/php-4.2.3, for clarity.



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-09-23 05:27 UTC]
Please try using this CVS snapshot:
For Windows:

 [2002-09-24 15:27 UTC] sproctor at ccs dot neu dot edu
I tried the latest version.  now $_ENV['PWD'] is just /home/sproctor/php4-200209240900.  I imagine it's an apache2 issue because that's the only weird thing I'm doing.  apache2 works fine on our server for everything else.  I'll try building it as a CGI and see if that works.
 [2002-09-24 15:56 UTC]
This might be for one of two reasons, this was the dir you started apache from, or it might be a bug in apache2. I cannot see how this bug comes from PHP. 

The variables' and the values for them are taken directly from the server or environment variables provided to PHP.


- James
 [2002-09-24 16:18 UTC] sproctor at ccs dot neu dot edu
it causes php scripts to not run.  the problem isn't that $_ENV['PWD'] is wrong, it's that php looks in the wrong place for files to include.

if I "include 'foo.php';"  it will look for it in /home/sproctor/php-xxx instead of from the location of the file.

The CGI version works fine, the apache1 version works fine, the apache2 version fails.  It's not too big of a deal for me thought because we have the CGI version working.

Perhaps it's a bug in apache2, either way PHP seems rather unusable as an apache2 module right now.

Thanks for the help,
 [2002-09-24 17:32 UTC]
There was a bug with virtual directory support in 4.2.3 used with multithreaded web servers. It's been fixed in both STABLE and HEAD branches.

You should not rely on environment for CWD in a multithreaded server, since all threads share the same. The directory you're getting is probably the one you were in when starting Apache2. Use getcwd() instead.
 [2002-09-24 23:45 UTC] sproctor at ccs dot neu dot edu
I had the same problems in php4-200209240900.  when was the problem fixed?  I can try it again if you think it's fixed now.  Also, when will the next stable version be released?

Thanks again,
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Jan 28 12:05:53 2023 UTC