0

Looking for help troubleshooting the following PHP inclusion error found in my /var/log/nginx/error.log file?

2013/04/16 22:27:18 [error] 10021#0: *6 FastCGI sent in stderr: "PHP message: PHP Warning:  require(1): failed to open stream: No such file or directory in /usr/share/nginx/www/phpass.php on line 8
PHP message: PHP Fatal error:  require(): Failed opening required '1' (include_path='.:/usr/share/php:/usr/share/pear') in /usr/share/nginx/www/phpass.php on line 8" while reading response header from upstream, client: 127.0.0.1, server: 127.0.0.1, request: "GET /phpass.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "xxxxxxxxx.xxx"

I can see the php file in question (phpass.php, it's just an example phpass script) through my browser, and php is definitely being parsed, but when I include PasswordHash.php my php script fails silently and I keep seeing the above errors in my nginx error log.

Any help would be greatly appreciated.

FYI: /bin/echo $PATH returns:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

I have pasted the sample script I am including PasswordHash.php from below:

<?php

echo "WTF";

echo $_SERVER['DOCUMENT_ROOT'];

//require("/usr/share/nginx/www/includes/phpass-0.3/PasswordHash.php") or die("shit");
//require("includes/phpass-0.3/PasswordHash.php") or die("shit");
require_once("PasswordHash.php") or die("shit");

echo "WTF";

$pwdHasher = new PasswordHash(8, FALSE);

echo "WTF";

$password = "password";

//$hash is what you would store in your database
$hash = $pwdHasher->HashPassword($password);

//$hash would be the $hashed stored in your database for this user
$checked = $pwdHasher->CheckPassword($password, $hash);
if ($checked) {
    echo 'password correct\n\n<br/>';
} else {
    echo 'wrong credentials\n\n<br/>';
}

echo "The \$password is 'password' and it's hash is '$hash'\n\n<br/>";

?>

The first "WTF" and "$_SERVER['DOCUMENT_ROOT']" get posted just fine. Nothing else is shown on my phpass.php page after that however, and when I go into my nginx error log file I see the error shown at the top of this post.

darkAsPitch
  • 1,855
  • 4
  • 23
  • 35
  • are phpass.php and PasswordHash.php in same dir? – raidenace Apr 16 '13 at 22:46
  • They are now, and I am still unable to include the file. I tried including PasswordHash.php from an /includes/ folder, and when that didn't work I moved it to the main www folder and still no luck including the file. – darkAsPitch Apr 16 '13 at 22:54
  • can you paste the `include` line? – raidenace Apr 16 '13 at 22:57
  • I have pasted the entire script at the bottom of my question. – darkAsPitch Apr 16 '13 at 23:01
  • two things to try: 1 - change `require_once` to `include_once` and see if shit gets printed (no pun intended :-) 2- try using `require_once dirname(__FILE__) . '/PasswordHash.php';` – raidenace Apr 16 '13 at 23:06

1 Answers1

0

This is the answer to my question: require_once () or die() not working

Apparently adding "or die('text')" to the end of my require_once command was my downfall.

Community
  • 1
  • 1
darkAsPitch
  • 1,855
  • 4
  • 23
  • 35