Installation:Debian:ProFTPd

From PMWH2 - PHPMyWebHosting's official wiki
Jump to: navigation, search
up

Installation

On Debian GNU/Linux you need to install the following packages:

  • proftpd-common
  • proftpd-mysql
  • ucf

On Debian GNU/Linux use this command to install all at once:

apt-get install proftpd-common proftpd-mysql ucf

Configuration

First we create a mysql user to access the proftpd tables:

bash #> mysql -u root -p mysql
Enter password: 
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 32 to server version: 4.0.16-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> GRANT SELECT,UPDATE on pmwh.proftpd to 'proftpd'@'localhost' identified by "proftpd-password";
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT SELECT on pmwh.proftpd_groups to 'proftpd'@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT SELECT on pmwh.proftpd_quotalimits to 'proftpd'@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT SELECT,INSERT,UPDATE on pmwh.proftpd_quotatallies to 'proftpd'@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

Then edit /etc/proftpd.conf and replace the content with the following content:

ServerName                      "%v"
ServerType                      standalone
DeferWelcome                    on

DefaultRoot                     ~

MultilineRFC2228                on
DefaultServer                   on
ShowSymlinks                    on

TimeoutNoTransfer               600
TimeoutStalled                  600
TimeoutIdle                     1200

DisplayLogin                    welcome.msg
DisplayFirstChdir               .message
ListOptions                     "-l"

DenyFilter                      \*.*/

Port                            21

# To prevent DoS attacks, set the maximum number of child processes
# to 30.  If you need to allow more than 30 concurrent connections
# at once, simply increase this value.  Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd)
MaxInstances                    30

# Set the user and group that the server normally runs at.
User                            vmail
Group                           vmail

# Umask 022 is a good standard umask to prevent new files and dirs
# (second parm) from being group and world writable.
Umask                           022  022
# Normally, we want files to be overwriteable.
AllowOverwrite                  on

SQLAuthTypes                    Crypt
SQLAuthenticate                 users* groups*

# used to connect to the database
# databasename@host database_user user_password
SQLConnectInfo                  pmwh@localhost proftpd proftpd-password

# Here we tell ProFTPd the names of the database columns in the "usertable"
# we want it to interact with. Match the names with those in the db
SQLUserInfo                     proftpd username password NULL gid homedir NULL

# Here we tell ProFTPd the names of the database columns in the "grouptable"
# we want it to interact with. Again the names match with those in the db
SQLGroupInfo                    proftpd_groups groupname gid members

# set min UID and GID - otherwise these are 999 each
SQLMinID                        500

# create a user's home directory on demand if it doesn't exist
SQLHomedirOnDemand on

# User quotas
# ===========
QuotaEngine on
QuotaDirectoryTally on
QuotaDisplayUnits Mb
QuotaShowQuotas on

SQLNamedQuery get-quota-limit SELECT "name, quota_type, per_session, limit_type, bytes_in_avail, bytes_out_avail, bytes_xfer_avail, files_in_avail, files_out_avail, files_xfer_avail FROM proftpd_quotalimits WHERE name = '%{0}' AND quota_type = '%{1}'"

SQLNamedQuery get-quota-tally SELECT "name, quota_type, bytes_in_used, bytes_out_used, bytes_xfer_used, files_in_used, files_out_used, files_xfer_used FROM proftpd_quotatallies WHERE name = '%{0}' AND quota_type = '%{1}'"

SQLNamedQuery update-quota-tally UPDATE "bytes_in_used = bytes_in_used + %{0}, bytes_out_used = bytes_out_used + %{1}, bytes_xfer_used = bytes_xfer_used + %{2}, files_in_used = files_in_used + %{3}, files_out_used = files_out_used + %{4}, files_xfer_used = files_xfer_used + %{5} WHERE name = '%{6}' AND quota_type = '%{7}'" proftpd_quotatallies

SQLNamedQuery insert-quota-tally INSERT "%{0}, %{1}, %{2}, %{3}, %{4}, %{5}, %{6}, %{7}" proftpd_quotatallies

QuotaLimitTable sql:/get-quota-limit
QuotaTallyTable sql:/get-quota-tally/update-quota-tally/insert-quota-tally

RootLogin off
RequireValidShell off

SQLLog                          RETR,STOR insertfileinfo
SQLNamedQuery                   insertfileinfo UPDATE "bytes=bytes+'%b' where username='%u'" proftpd

SQLDefaultUID                   1005       # [VMAIL-UID]
SQLDefaultGID                   1005       # [VMAIL-GID]

Finally

Restart proftpd by

/etc/init.d/proftpd restart