标签:
PureFTP+Mysql验证
FTP的原理
21端口开放,用于连接。20端口用于传输数据!
匿名用户
anonymous
主动模式和被动模式
主动模式是客户端主动,例如用1030端口连接21,再开放1031和20端口传输数据,但是如果有防火墙的话,无法主动传输,服务器会打开大于1024端口并且通过客户端进行连接
tar -xjvf pure-ftpd-1.0.22.tar.bz2
./configure –prefix=/usr/local/pureftpd –with-mysql=/usr/local/mysql –with-paranoidmsg –with-shadow –with-welcomemsg –with-uploadscript –with-quotas –with-cookie –with-virtualhosts –with-virtualroot –with-diraliases –with-sysquotas –with-ratios –with-ftpwho –with-throttling –with-language=simplified-chinese
–with-mysql=/usr/local/mysql \ 此处的 /usr/local/mysql 请改为你的mysql实际安装路径.如果出现类似configure: error: Your MySQL client libraries aren’t properly installed 的错误,请将mysql目录下的 include/mysql下的mysql.h文件以及lib/mysql下的全部文件,连接(直接复制过去或许也可)到 /usr/lib 目录下(参考)
cp /usr/local/mysql/lib/libmysqlclent* /usr/lib(真正解决办法)
##运行 ldconfig,加载所有共享链接库
cp -a ftp /var/www/html/pureftp
make && make install
cp configuration-file/pure-config.pl /usr/local/pureftpd/sbin/
chmod +x /usr/local/pureftpd/sbin/pure-config.pl
cp configuration-file/pure-ftpd.conf /etc
make /ftproot
生成pure-Ftp服务管理脚本
编辑contrib子目录里面的redhat.int文件
fullpath=/usr/local/sbin/$prog
改为
fullpath=/usr/local/pureftpd/sbin/$prog
pureftpwho=/usr/local/sbin/pure-ftpwho
改为
pureftpwho=/usr/local/pureftpd/sbin/pure-ftpwho
cp contrib/redhat.init /etc/init.d/pure-ftpd
chmod +x /etc/init.d/pure-ftpd
chkconfig –add pure-ftpd
安装user mamager for pure-ftpd进行Web管理pure-ftp
tar -xzvf ftp_v2.1.tar.gz
cp -a ftp /var/www/html/pureftp
在浏览器输入。IP/pureftp/install.php
一步一步的创建!!
Touch /etc/pureftp-mysql.conf
把下面复制到那个文件
############################################################################
# #
# PureFTPd MySQL configuration file. #
# Generated by the installation wizard for the ‘User manager for PureFTPd‘ #
# See http://machiel.generaal.net for more info #
# or read the README.MySQL for explanations of the syntax. #
# #
############################################################################
# Optional : MySQL server name or IP. Don‘t define this for unix sockets.
MYSQLServer 127.0.0.1
# Optional : MySQL port. Don‘t define this if a local unix socket is used.
# MYSQLPort 3306
# Optional : define the location of mysql.sock if the server runs on this host.
MYSQLSocket /tmp/mysql.sock
# Mandatory : user to bind the server as.
MYSQLUser ftp
# Mandatory : user password. You must have a password.
MYSQLPassword tmppasswd
# Mandatory : database to open.
MYSQLDatabase ftpusers
# Mandatory : how passwords are stored
# Valid values are : "cleartext", "crypt", "md5" and "password"
# ("password" = MySQL password() function)
# You can also use "any" to try "crypt", "md5" *and* "password"
MYSQLCrypt md5
# In the following directives, parts of the strings are replaced at
# run-time before performing queries :
#
# \L is replaced by the login of the user trying to authenticate.
# \I is replaced by the IP address the user connected to.
# \P is replaced by the port number the user connected to.
# \R is replaced by the IP address the user connected from.
# \D is replaced by the remote IP address, as a long decimal number.
#
# Very complex queries can be performed using these substitution strings,
# especially for virtual hosting.
# Query to execute in order to fetch the password
MYSQLGetPW SELECT Password FROM users WHERE User="\L" AND Status="1" AND (Ipaddress = "*" OR Ipaddress LIKE "\R")
# Query to execute in order to fetch the system user name or uid
MYSQLGetUID SELECT Uid FROM users WHERE User="\L" AND Status="1" AND (Ipaddress = "*" OR Ipaddress LIKE "\R")
# Optional : default UID - if set this overrides MYSQLGetUID
#MYSQLDefaultUID 1000
# Query to execute in order to fetch the system user group or gid
MYSQLGetGID SELECT Gid FROM users WHERE User="\L" AND Status="1" AND (Ipaddress = "*" OR Ipaddress LIKE "\R")
# Optional : default GID - if set this overrides MYSQLGetGID
#MYSQLDefaultGID 1000
# Query to execute in order to fetch the home directory
MYSQLGetDir SELECT Dir FROM users WHERE User="\L" AND Status="1" AND (Ipaddress = "*" OR Ipaddress LIKE "\R")
# Optional : query to get the maximal number of files
# Pure-FTPd must have been compiled with virtual quotas support.
MySQLGetQTAFS SELECT QuotaFiles FROM users WHERE User="\L" AND Status="1" AND (Ipaddress = "*" OR Ipaddress LIKE "\R")
# Optional : query to get the maximal disk usage (virtual quotas)
# The number should be in Megabytes.
# Pure-FTPd must have been compiled with virtual quotas support.
MySQLGetQTASZ SELECT QuotaSize FROM users WHERE User="\L" AND Status="1" AND (Ipaddress = "*" OR Ipaddress LIKE "\R")
# Optional : ratios. The server has to be compiled with ratio support.
MySQLGetRatioUL SELECT ULRatio FROM users WHERE User="\L" AND Status="1" AND (Ipaddress = "*" OR Ipaddress LIKE "\R")
MySQLGetRatioDL SELECT DLRatio FROM users WHERE User="\L" AND Status="1" AND (Ipaddress = "*" OR Ipaddress LIKE "\R")
# Optional : bandwidth throttling.
# The server has to be compiled with throttling support.
# Values are in KB/s .
MySQLGetBandwidthUL SELECT ULBandwidth FROM users WHERE User="\L" AND Status="1" AND (Ipaddress = "*" OR Ipaddress LIKE "\R")
MySQLGetBandwidthDL SELECT DLBandwidth FROM users WHERE User="\L" AND Status="1" AND (Ipaddress = "*" OR Ipaddress LIKE "\R")
# Enable ~ expansion. NEVER ENABLE THIS BLINDLY UNLESS :
# 1) You know what you are doing.
# 2) Real and virtual users match.
# MySQLForceTildeExpansion 1
# If you upgraded your tables to transactionnal tables (Gemini,
# BerkeleyDB, Innobase...), you can enable SQL transactions to
# avoid races. Leave this commented if you are using the
# traditionnal MyIsam databases or old (< 3.23.x) MySQL versions.
# MySQLTransactions On
在/etc/pure-ftp.conf
加一句
MySQLConfigFile /etc/pureftpd-mysql.conf
Service pure-ftpd start
标签:
原文地址:http://www.cnblogs.com/Jerry-blog/p/5044753.html