据我所知,没有任何关于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