如果导出队列能成功执行(队列不执行看这里)但是并未生成文件,那么原因大部份可能是出在FTP上。
ECSTORE2.0采用了PHP的FTP模块,所以先确认你的环境是否安装了FTP模块,如果没有,安装并在PHP.INI中配置好模组路径。
功能文件:\app\importexport\lib\policy\ftp.php ,程序中使用 ftp_nb_put() 异步上传,这里告诉大家一个调试方法:在适当的位置加入 logger::info('debug info');
然后查看 /data/logs/queue/日期.php 的日志输出,可以直接ssh用 tail -f /data/logs/queue/日期.php
【原理】利用PHP的 tempnam() 函数上传临时文件至 服务器的 /tmp目录,再用 ftp_nb_put() 将文件上传至FTP服务器。
【原因】有的FTP服务器需要使用被动模式PASV连接。
【解决方法】
修改 \app\importexport\lib\policy\ftp.php 文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
public
function __construct(){
$
this
->ftp_server = app::get(
'importexport'
)->getConf(
'ftp_server_setting'
);
if
(!$
this
->conn){
$
this
->ftp_server[
'port'
] = $
this
->ftp_server[
'port'
] ? $
this
->ftp_server[
'port'
] : 21;
$
this
->conn = ftp_connect($
this
->ftp_server[
'host'
],$
this
->ftp_server[
'port'
]);
$
this
->bb=ftp_login($
this
->conn,$
this
->ftp_server[
'name'
],$
this
->ftp_server[
'pass'
]);
}
if
($
this
->ftp_server[
'pasv'
]==
'true'
){
ftp_pasv($
this
->conn,$
this
->ftp_server[
'pasv'
]);
//vmax 开启被动模式
}
$
this
->cd($
this
->ftp_server[
'dir'
]);
}
|
修改 \app\importexport\view\admin\ftp.html
1
2
3
4
|
<p style=
"margin:20px 0"
><{t}>被动模式(PASV):<{/t}>
<input type=
"radio"
name=
"pasv"
value=
"true"
<{
if
$ftp_server.pasv==
'true'
}>checked <{/
if
}>>开启
<input type=
"radio"
name=
"pasv"
value=
"false"
<{
if
$ftp_server.pasv==
'false'
}>checked <{/
if
}>>关闭
</p>
|
懒一点的话,就只在FTP.PHP文件中加入 ftp_pasv($this->conn,true); 吧!
最后附上我的FTP模块安装记录,供新手参考:
841 cd lanmp/lanmp/php-5.3.27/ext/ftp 846 phpize 847 ./configure -with-php-config=/www/wdlinux/php/bin/php-config 848 make 849 make install 850 ll /www/wdlinux/apache_php-5.3.27/lib/php/extensions/no-debug-non-zts-20090626/ 851 vim /www/wdlinux/etc/php.ini 852 service httpd restart