Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm trying to FTP out using a php script on EC2. When using passive mode it works great but it fails in active mode. I've tried opening high ports in EC2 security group but it's still not working. What do I need to do? Thanks

share|improve this question
    
Can I ask: Why in the world are you still using FTP? FTP Must Die. –  EEAA Feb 24 '13 at 13:54
    
I agree with the sentiment but my app has to support it. –  Adam Jimenez Feb 24 '13 at 16:26

1 Answer 1

up vote 3 down vote accepted

In order to do active FTP from PHP, you will need at least three things to be in place:

  1. Data port to be open in the EC2 security group - which you have
  2. Your script should send out the external IP address of the EC2 instance and not the internal IP (10.x.x.x)
  3. You must explicitly set the active option in whichever library you are using for FTP
share|improve this answer
    
I think the problem is 2 - how do I solve that? BTW not using a library, but php's built-in ftp extensions. –  Adam Jimenez Feb 24 '13 at 15:42
    
It would depend on the FTP client (PHP library) that you are using, or play around with the server configuration (not recommended). –  Akber Choudhry Feb 24 '13 at 15:43
    
PHP's bult-in ftp php.net/manual/en/book.ftp.php –  Adam Jimenez Feb 24 '13 at 16:22
    
You're probably out of luck on EC2 unless you want to patch the PHP extension code yourself. Some 'smarter' firewalls will do Layer 7 tinkering and change the IP address transparently but apparently EC2 does not do it. –  Akber Choudhry Feb 24 '13 at 16:37
    
I think you're right. I wonder if I can use ftp_raw or curl. Really appreciate your help, thank you. –  Adam Jimenez Feb 24 '13 at 17:44

Your Answer

 
discard

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.