Search:  
Gentoo Wiki

Apache_Modules_mod_ftpd

Apache2 Series


Main


Modules


Addons & Tunnels


Tips


Configuring


Other

edit

Introduction

mod_ftpd is an ftp module for Apache to allow you to access files over ftp.

Installing

emerge mod_ftpd

Configuring

Define FTPD

File: /etc/conf.d/apache2
APACHE2_OPTS="-D PHP4 -D SSL -D DOC -D FTPD"

Alternate and Quick Config

Here we're going to consider that you don't care about anything fancy, you want something that "Just Works ™" OoB. If you throw some files in /var/ftp, you should be able to access them, no problem.

File: /etc/apache2/conf/modules.d/mod_ftpd.conf
<IfDefine FTPD>
        LoadModule ftpd_module extramodules/mod_ftpd.so

        # Load any of the provider modules here (for user specific chroots)
        #LoadModule ftpd_dbm_module     extramodules/mod_ftpd_dbm.so
        #LoadModule ftpd_dbi_module     extramodules/mod_ftpd_dbi.so
        LoadModule ftpd_default_module  extramodules/mod_ftpd_default.so
        #LoadModule ftpd_fail_module    extramodules/mod_ftpd_fail.so

        Listen 21
        <VirtualHost *:21>
                ServerName coolaj86.homedns.org
                DocumentRoot /var/ftp
                FtpProtocol On
                FtpShowRealPermissions Off
                FtpAllowActive Off # Must be off if you are firewalled
                FtpPasvMinPort 1024
                FtpPasvMaxPort 65535
                FtpLimitOrder default
                FtpDefaultMaxLogins 100

                <Directory /var/ftp>
                        Anonymous_Authoritative On
                        AuthAuthoritative Off
                        Anonymous_NoUserID Off
                        Anonymous_MustGiveEmail Off
                        Anonymous_VerifyEmail Off
                        Anonymous_LogEmail Off
                        Anonymous anonymous
                        AuthName ftp
                        AuthType Basic
                        Require valid-user
                        Order allow,deny
                        Allow from all
                </Directory>

                # only allow changing, retrieving files, and listing on the site
                <Location />
                        <LimitExcept CHDIR GET LIST>
                                Deny from all
                        </LimitExcept>
                </Location>

                # allow making directories, listing, chdir, and uploading files.
                # But don't allow retrieving files.
                # <Location /upload>
                #        <LimitExcept LIST PUT MKCOL CHDIR>
                #                Deny from all
                #        </LimitExcept>
                # </Location>
        </VirtualHost>
</IfDefine>

Accessing your server

You can use one of many ftp clients, or if your client is a linux box, you might also try mounting the ftp connection!

Changing the FTP directory

Gentoo by default will set the ftp directory to /home/ftp. if you wish to change the directory please do this edit of /etc/apache2/modules.d/mod_ftpd.conf (yours may be /etc/apache2/conf/modules.d/mod_ftpd.conf) and change the following 2 lines

File: /etc/apache2/modules.d/mod_ftpd.conf (yours may be /etc/apache2/conf/modules.d/mod_ftpd.conf)
...
DocumentRoot /home/ftp
...
 <Directory /home/ftp>
...

Troubleshooting

ftp works from localhost, but not externally (after a few days) This can happen or many reasons such as the following:

$IPTABLES -A FORWARD -p tcp -s $i --sport 1024:65535 -d $j --dport 21  
       -m state --state NEW,ESTABLISHED -j ACCEPT  
$IPTABLES -A FORWARD -p tcp -s $j --sport 21 -d $i --dport 1024:65535 
       -m state --state RELATED,ESTABLISHED -j ACCEPT  
$IPTABLES -A FORWARD -p tcp -s $i --sport 1024:65535 -d $j --dport 1024:65535  
       -m state --state RELATED,ESTABLISHED -j ACCEPT  
$IPTABLES -A FORWARD -p tcp -s $j --sport 1024:65535 -d $i --dport 1024:65535  
       -m state --state RELATED,ESTABLISHED -j ACCEPT  

where $i is the client and $j the server and $IPTABLES is the iptables command. Note you must "modprobe ip_conntrack_ftp".

Retrieved from "http://www.gentoo-wiki.info/Apache_Modules_mod_ftpd"

Last modified: Sat, 06 Sep 2008 10:53:00 +0000 Hits: 30,307