简体   繁体   中英

Trouble including PHP file on ubuntu 12.10 using nginx and php5-fpm

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM