據我所知,沒有任何關於phpseclib正常工作的具體要求。所以我決定試試共享主機通過SFTP進行連接。關於phpseclib的跟蹤錯誤500
下面的代碼工作在我的本地開發環境和轉移文件到目標,它失敗,出現錯誤的生產共享的主機帳戶500
<?php
set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
include('phpseclib/Net/SFTP.php');
define('NET_SFTP_LOGGING', NET_SFTP_LOG_COMPLEX);
$sftp = new Net_SFTP('url', port);
if (!$sftp->login('username', 'password')) {
exit('Login Failed');
} else {
echo "working";
}
echo $sftp->pwd();
// puts a three-byte file named filename.remote on the SFTP server
$sftp->put('filename.remote', 'xxx');
// puts an x-byte file named filename.remote on the SFTP server,
// where x is the size of filename.local
$sftp->put('filename.remote', 'example.txt', NET_SFTP_LOCAL_FILE);
echo $sftp->getSFTPLog();
?>
如何尋找下這個錯誤並跟蹤其發生?
更詳細的信息(年10月,02編):
php_error.log
[02-Oct-2014 09:26:23 UTC] PHP Notice: fputs(): send of 36 bytes failed with errno=32 Broken pipe in /var/www/virtual/addorange.de/htdocs/phpseclib/phpseclib/Net/SSH2.php on line 3175
[02-Oct-2014 09:26:23 UTC] PHP Notice: Connection closed prematurely in /var/www/virtual/addorange.de/htdocs/phpseclib/phpseclib/Net/SSH2.php on line 3143
和apache_error.log
[Thu Oct 02 09:26:04 2014] [warn] mod_fcgid: read data timeout in 40 seconds
[Thu Oct 02 09:26:04 2014] [error] [client 79.232.85.137] Premature end of script headers: upload.php
[Thu Oct 02 09:26:10 2014] [notice] mod_fcgid: process 9470 going graceful shutdown, sending SIGTERM
[Thu Oct 02 09:26:35 2014] [warn] mod_fcgid: read data timeout in 40 seconds
[Thu Oct 02 09:26:35 2014] [error] [client 79.232.85.137] Premature end of script headers: upload.php
[Thu Oct 02 09:26:40 2014] [notice] mod_fcgid: process 9473 going graceful shutdown, sending SIGTERM
只需從您的主機中讀取錯誤日誌。 – sectus 2014-10-01 08:20:10
您可以發佈完整的錯誤消息,而不是說錯誤500?大多數情況下,這很可能來自'fsockopen'。例如。 PHP本身可能無法連接。也許是因爲防火牆(iptables)問題或某事。 – neubert 2014-10-01 12:44:23
感謝您的關懷,只需添加兩條錯誤日誌條目 – addorange 2014-10-02 09:32:12