1 rpm -qa | grep openssl
2 wget http://www.libssh2.org/download/libssh2-1.6.0.tar.gz
3 tar zxvf llibssh2-1.6.0.tar.gz
4 cd libssh2-1.6.0
5 ./configure
6 make && make install
7 wget http://pecl.php.net/get/ssh2-0.11.3.tgz
8 tar xvf ssh2-0.11.3.tgz
9 cd ssh2-0.11.3
10 phpize
11 ./configure --with-ssh2
12 make
13 cp modules/ssh2.so /alidata/server/php-5.4.23/lib/php/extensions/no-debug-non-zts-20100525
14 echo 'extension=ssh2.so' >> /alidata/server/php-5.4.23/etc/php.ini
15 service nginx restart
16 php -i | grep ssh2
1 public function proccessFile($destinationPath, $filename)
2 {
3 //parent::proccessFile($destinationPath, $filename); // TODO: Change the autogenerated stub
4
5 $remoteBasePath = '/mnt/java/pipeline/ads/upload/';
6 $localBasePath = '/alidata/www/aft/';
7 $connection = ssh2_connect('XXX.XXX.XXX.XXX', 22);
8 ssh2_auth_password($connection, 'username', 'password');
9 /*
10 $sftp = ssh2_sftp($connection);
11 SiteHelpers::PE($sftp);
12 $resFile = fopen("ssh2.sftp://$sftp/mnt/java/pipeline/ads/upload", 'w');
13 $srcFile = fopen('/alidata/www/aft/'.$destinationPath.'/'.$filename,'r');
14 $writtenBytes = stream_copy_to_stream($srcFile, $resFile);
15 fclose($resFile);
16 fclose($srcFile);
17 */
18 $dateDir = date("Y-m/d",strtotime("-1 day"));
19 // SiteHelpers::PE($remoteBasePath.$dateDir.'/'.$filename);
20 // $sftp = ssh2_sftp($connection);
21 // ssh2_sftp_mkdir($sftp,$remoteBasePath.$dateDir);
22 ssh2_exec($connection,'mkdir -p '.$remoteBasePath.$dateDir);
23 ssh2_scp_send($connection,
24 $localBasePath.$destinationPath.'/'.$filename,
25 $remoteBasePath.$dateDir.'/'.$filename);
26
27 Log::info('处理了投放数据');
28 Log::info($destinationPath.'/'.$filename);
29 }