Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I set up a m1.large EC2 instance and want to use it to download logs off a cdn's server. I had the code working just fine on my ubuntu laptop but once uploaded to the server the ftp_rawlist() function stopped working. As far as i can tell the code is still logging into the ftp server but rawlist isn't returning any files.

here is the sample code:


$FTP_USERNAME = 'username';
$FTP_PASSWORD = 'pass';
$FTP_SERVER   = 'cdn.server';
$FTP_LOGDIR   = 'logs';

$conn_id = ftp_connect($FTP_SERVER) or die('Couldn\'t connect to '.$FTP_SERVER);

if(!ftp_login($conn_id, $FTP_USERNAME, $FTP_PASSWORD)) {
        die('Couldn\'t connect as '.$FTP_USERNAME);

ftp_chdir($conn_id, $FTP_LOGDIR);

$rawlist = ftp_rawlist($conn_id, '.');



and the output is this:


even though i know the directory isn't empty.

When setting up the server these are the commands i used to install everything:

sudo yum install php
sudo yum install php-mysql
sudo yum install php-pear
sudo pear channel-discover
sudo pear install aws/sdk

I even opened all the ports for the security group but even then the output was still bool(false). And php -i shows that ftp is enabled.

Any help would be greatly appreciated, i have been racking my brain all day trying to figure this out.

share|improve this question
Duplicate of… – Eric Hammond Dec 8 '11 at 1:44
up vote 2 down vote accepted

Needed to run it in passive mode

ftp_pasv($conn_id, true);

share|improve this answer
That or I was gonna suggest you might need to open up your Security Group to allow ftp-data (20/tcp) which is needed if you're not using PASV FTP connections. I believe the server initiates the connection back on port 20/tcp after the client has connected on port 21/tcp and the firewall created by the Security Group would reject that unless allowed. – Jeremy Bouse Dec 8 '11 at 19:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.