全力打造多功能FreeBSD服务器
Proftpd的配置文件proftpd.conf在/usr/local/etc/目录下,针对不用的认证可以使用不同的配置文件。使用MySQL认证,可以把mod_sql.conf拷贝到/usr/local/etc下面并将其改名为proftpd.conf。
修改proftpd.conf文件,具体内容如下:
#设置FTP服务器的名称:
ServerName “My FTP Server”
#设置FTP服务器的类型:
ServerType standalone
DefaultServer on
#设置根,可以限制用户在某个地方活动,增强服务器的安全性。
DefaultRoot ~
#设置FTP服务端口号,标准的FTP服务端口是21。
Port 21
#设置新建文件或目录时,设置权限的掩码:
Umask 022
#设置系统日志文件:
SystemLog /var/log/ftp.syslog
#设置记录文件传输的日志文件:
TransferLog /var/log/ftp.transferlog
#设置最大的尝试登录的次数,如果超过自动断开连接:
MaxLoginAttempts 3
#设置断点继传
AllowRetrieveRestart on
#针对IP的速率限制(以BPS为单位,下面是80KB/S)
RateReadBPS 80000
RateWriteBPS 80000
#设置MySQL认证:
<Global>
#数据库联接的信息,DatabaseName是数据库名, HostName是主机名,
#Port是端口号,UserName是连接数据库的用户名,Password是密码。
SQLConnectInfo DatabaseName@HostName:Port UserName Password
#我的实例是SQLConnectInfo FTP@localhost:3306 root ******
#数据库认证的类型:
SQLAuthTypes Backend Plaintext
#指定用来做用户认证的表的有关信息。
SQLUserInfo FTPUSERS userid passwd uid gid home shell
#设置如果shell为空时允许用户登录:
RequireValidShell off
#数据库的鉴别,这里是用于用户的方式:
SQLAuthenticate users
#如果home目录不存在,则系统会为根据它的home项新建一个目录:
SQLHomedirOnDemand on
</Global>
#防止DoS攻击,设置最大的了进程:
MaxInstances 30
#设置正常服务的系统用户与组:
User ftpusers
Group ftpgroups
#设置用户登录时显示的信息及进入各个子目录中的信息:
DisplayLogin welcome.msg
DisplayFirstChdir .message
#设置最大的登录数:
MaxClients10
#支持断点续传:
AllowRetrieveRestart on
AllowStoreRestart on
测试:
完成了文件的配置,你可以启动Proftpd服务了,用来测试是否成功:
修改apahce的配置文件,使通过mysql添加的proftpd用户目录能被web浏览
将UserDir public_html
改为UserDir /home/ftp/*/
然后重启apache使改动生效,再启动proftpd用test帐号登陆,进行测试。
# /usr/local/proftpd/sbin/proftpd –n &
注意:在FreeBSd4.7和5.0下运行Proftpd,这时可能会提示下面的错误
/usr/local/ftp/sbin/proftpd: error while loading shared libraries: libmysqlclient.so.10: cannot open shared object file:
No such file or directory
解决方案如下:
安装mysql时,将mysql库所在的目录添加进配置文件中,例如
echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
然后执行ldconfig -v|grep libmysqlclient ,再试试!
或者将/usr/local/mysql/lib/mysql/下的文件全部copy到/usr/lib中即可。
如果test登陆成功的话,在test用户根目录里放置一个index.html文件
通http://yourserver/~test/看能否访问。
未完待续,希望起到抛砖引玉的作用,大家可以接着写啊,偶技术太烂了,已经好一阵子没玩过BSD了,555~~~~
我的proftpd.conf配置文件:
ServerName "白狐狸''s FTP Server"
ServerType standalone
DefaultServer on
# Port 21 is the standard FTP port.
Port 21
# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
Umask 022
#limit the user in his owner directory
DefaultRoot ~
#put the proftpd log files in /var/log/ftp.syslog
SystemLog /var/log/ftp.syslog
#TransferLog log files
TransferLog /var/log/ftp.transferlog
#set The maxtimes user Attempts times
MaxLoginAttempts 3
#setup the Restart
AllowRetrieveRestart on
#setup the download and upload speed
RateReadBPS 80000
RateWriteBPS 80000
#setup the disk quota
QuotaDirectoryTally on
#quota b"|"Kb"|"Mb"|"Gb"
#setup the disk quota
QuotaDirectoryTally on
#quota b"|"Kb"|"Mb"|"Gb"
QuotaDisplayUnits Kb
QuotaEngine on
QuotaLog /var/ftp/Quota.log
QuotaShowQuotas on
# We put our mod_sql directives in a <Global> block so they''ll be
# inherited by the <Anonymous> block below, and any other <VirtualHost>
# blocks we may want to add. For a simple server these don''t need to
# be in a <Global> block but it won''t hurt anything.
<Global>
# Specify our connection information. Both mod_sql_mysql and
# mod_sql_postgres use the same format, other backends may specify a
# different format for the first argument to SQLConnectInfo. By not
# specifying a fourth argument, we''re defaulting to ''PERSESSION''
# connections -- a connection is made to the database at the start of
# the session and closed at the end. This should be fine for most
# situations.
# SQLConnectInfo dbname@host:port username password
SQLConnectInfo ftp@localhost:3306 root 12345678
# Specify our authentication schemes. Assuming we''re using
# mod_sql_mysql, here we''re saying ''first try to authenticate using
# mysql''s password scheme, then try to authenticate the user''s
# password as plaintext''. Note that ''Plaintext'' isn''t a smart way to
# store passwords unless you''ve got your database well secured.
SQLAuthTypes Backend Plaintext
# Specify the table and fields for user information. If you''ve
# created the database as it specifies in ''README.mod_sql'', you don''t
# need to have this directive at all UNLESS you''ve elected not to
# create some fields. In this case we''re telling mod_sql to look in
# table ''users'' for the fields ''username'',''password'',''uid'', and
# ''gid''. The ''homedir'' and ''shell'' fields are specified as ''NULL'' --
# this will be explained below.
# SQLUserInfo users username password uid gid NULL NULL
SQLUserInfo ftpusers userid passwd uid gid home shell
# Here we tell mod_sql that every user it authenticates should have
# the same home directory. A much more common option would be to
# specify a homedir in the database and leave this directive out. Note
# that this directive is necessary in this case because we specified
# the homedir field as ''NULL'', above. mod_sql needs to get homedir
# information from *somewhere*, otherwise it will not allow access.
# SQLDefaultHomedir "/tmp"
# This is not a mod_sql specific directive, but it''s here because of
# the way we specified ''SQLUserInfo'', above. By setting this to
# ''off'', we''re telling ProFTPD to allow users to connect even if we
# have no (or bad) shell information for them. Since we specified the
# shell field as ''NULL'', above, we need to tell ProFTPD to allow the
# users in even though their shell doesn''t exist.
RequireValidShell off
# Here we tell mod_sql how to get out group information. By leaving
# this commented out, we''re telling mod_sql to go ahead and use the
# defaults for the tablename and all the field names.
# SQLGroupInfo groups groupname gid members
# For small sites, the following directive will speed up queries at
# the cost of some memory. Larger sites should read the complete
# description of the ''SQLAuthenticate'' directive; there are options
# here that control the use of potentially expensive database
# queries. NOTE: these arguments to ''SQLAuthoritative'' limit the way
# you can structure your group table. Check the README for more
# information.
SQLAuthenticate users
# Finally, some example logging directives. If you have an integer
# field named ''count'' in your users table, these directives will
# automatically update the field each time a user logs in and display
# their current login count to them.
# SQLNamedQuery getcount SELECT "count, userid from users where userid=''%u''"
# SQLNamedQuery updatecount UPDATE "count=count+1 WHERE userid=''%u''" users
# SQLShowInfo PASS "230" "You''ve logged on %{getcount} times, %u"
# SQLLog PASS updatecount
SQLHomedirOnDemand on
#...SQL...............
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 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 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}''" quotatallies
SQLNamedQuery insert-quota-tally INSERT "%{0}, %{1}, %{2}, %{3}, %{4}, %{5}, %{6}, %{7}" quotatallies
QuotaLimitTable sql:/get-quota-limit
QuotaTallyTable sql:/get-quota-tally/update-quota-tally/insert-quota-tally
# close our <Global> block.
</Global>
# 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 normal user and group permissions for the server.
User ftpusr
Group ftpgrp
# Normally, we want files to be overwriteable.
<Directory /*>
AllowOverwrite on
AllowRetrieveRestart on
AllowStoreRestart on
</Directory>
# A basic anonymous configuration, no upload directories. If you
# don''t want to support anonymous access, simply remove this
# <Anonymous ..> ... </Anonymous> block.
<Anonymous ~ftp>
User ftp
Group ftp
# We want clients to be able to login with "anonymous" as well as "ftp"
UserAlias anonymous ftp
# Limit the maximum number of anonymous logins
MaxClients 10
# We want ''welcome.msg'' displayed at login, and ''.message'' displayed
# in each newly chdired directory.
DisplayLogin welcome.msg
DisplayFirstChdir .message
# Limit WRITE everywhere in the anonymous chroot
<Limit WRITE>
DenyAll
</Limit>
</Anonymous>