Pureftpd和mysql如何架设FTP服务器

79次阅读
没有评论

共计 3883 个字符,预计需要花费 10 分钟才能阅读完成。

这篇文章主要介绍 Pureftpd 和 mysql 如何架设 FTP 服务器,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

下载 mysql5.1.31 rpm 文件和 pure-ftpd 源码包

安装 mysql5.1.31 共享包

rpm -ivh MySQL-shared-community-5.1.31-0.rhel5.i386.rpm

编译安装 pure-ftpd

#./configure  ndash;prefix=/usr/local/pureftpd  ndash;with-mysql  ndash;with-paranoidmsg  ndash;with-welcomemsg  ndash;with-uploadscript  ndash;with-cookie  ndash;with-virtualchroot  ndash;with-virtualhosts  ndash;with-virtualroot  ndash;with-diraliases  ndash;with-quotas  ndash;with-sysquotas  ndash;with-ratios  ndash;with-ftpwho  ndash;with-throttling #make #make check #make install

配置 pure-ftpd

#cd configuration-file #chmod u+x pure-config.pl #cp pure-config.pl /usr/local/sbin/ #cp pure-ftpd.conf /usr/local/etc/ vi /usr/local/etc/pure-ftpd.conf

确认以下三项

ChrootEveryone yes

MySQLConfigFile /etc/pureftpd-mysql.conf

CreateHomeDir yes

为 puer-ftpd 创建 mysql 数据库和用户

CREATE DATABASE pureftpd;

GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON pureftpd.* TO lsquo;pureftpd rsquo;@ localhost rsquo; IDENTIFIED BY lsquo;password rsquo;;

FLUSH PRIVILEGES;

USE pureftpd;

CREATE TABLE ftpd (

User varchar(16) NOT NULL default”,

status enum(rsquo;0 prime;, rsquo;1 prime;) NOT NULL default rsquo;0 prime;,

Password varchar(64) NOT NULL default”,

Uid varchar(11) NOT NULL default lsquo;-1 prime;,

Gid varchar(11) NOT NULL default lsquo;-1 prime;,

Dir varchar(128) NOT NULL default”,

ULBandwidth smallint(5) NOT NULL default rsquo;0 prime;,

DLBandwidth smallint(5) NOT NULL default rsquo;0 prime;,

comment tinytext NOT NULL,

ipaccess varchar(15) NOT NULL default lsquo;* rsquo;,

QuotaSize smallint(5) NOT NULL default rsquo;0 prime;,

QuotaFiles int(11) NOT NULL default 0,

PRIMARY KEY (User),

UNIQUE KEY User (User)

) TYPE=MyISAM;

配置 pureftpd-mysql.conf

vi /etc/pureftpd-mysql.conf

录入

MYSQLSocket /tmp/mysql.sock

#MYSQLServer localhost

#MYSQLPort 3306

MYSQLUser pureftpd

MYSQLPassword password

MYSQLDatabase pureftpd

#MYSQLCrypt md5, cleartext, crypt() or password() ndash; md5 is VERY RECOMMENDABLE uppon cleartext

MYSQLCrypt md5

MYSQLGetPW SELECT Password FROM ftpd WHERE User=”L”AND status=”1 Prime; AND (ipaccess =“*”OR ipaccess LIKE“R”)

MYSQLGetUID SELECT Uid FROM ftpd WHERE User=”L”AND status=”1 Prime; AND (ipaccess =“*”OR ipaccess LIKE“R”)

MYSQLGetGID SELECT Gid FROM ftpd WHERE User=”L”AND status=”1 Prime; AND (ipaccess =“*”OR ipaccess LIKE“R”)

MYSQLGetDir SELECT Dir FROM ftpd WHERE User=”L”AND status=”1 Prime; AND (ipaccess =“*”OR ipaccess LIKE“R”)

MySQLGetBandwidthUL SELECT ULBandwidth FROM ftpd WHERE User=”L”AND status=”1 Prime; AND (ipaccess =“*”OR ipaccess LIKE“R”)

MySQLGetBandwidthDL SELECT DLBandwidth FROM ftpd WHERE User=”L”AND status=”1 Prime; AND (ipaccess =“*”OR ipaccess LIKE“R”)

MySQLGetQTASZ SELECT QuotaSize FROM ftpd WHERE User=”L”AND status=”1 Prime; AND (ipaccess =“*”OR ipaccess LIKE“R”)

MySQLGetQTAFS SELECT QuotaFiles FROM ftpd WHERE User=”L”AND status=”1 Prime; AND (ipaccess =“*”OR ipaccess LIKE“R”)

各参数注释

User:用户名

status:状态 1 为激活状态 0 为非激活状态

Password:密码

Uid:用户系统 ID 号

GID:用户组 ID 号

ULBandwidth:上传 *** 带宽 单位 KB/S

DLBandwidth:下载 *** 带宽 单位 KB/S

comment:注释

ipaccess:允许访问 IP 地址

QuotaSize:磁盘配额总大小 单位 MB

QuotaFiles:允许存放的文件数目个数 0 为不限制

关掉进程

killall pure-ftpd

启动服务

/usr/local/sbin/pure-config.pl /usr/local/etc/pure-ftpd.conf

为 ftp 添加用户

USE pureftpd;

INSERT INTO `ftpd` (`User`, `status`, `Password`, `Uid`, `Gid`, `Dir`, `ULBandwidth`, `DLBandwidth`, `comment`, `ipaccess`, `QuotaSize`, `QuotaFiles`) VALUES (lsquo;test rsquo;, rsquo;1 prime;, MD5( lsquo;test rsquo;), rsquo;60031 prime;, rsquo;60031 prime;, lsquo;/home/test rsquo;, rsquo;128 prime;, rsquo;56 prime;,”, lsquo;* rsquo;, rsquo;100 prime;, rsquo;0 prime;);

即可用数据库里的用户和密码登陆 ftp

将 pureftpd 加载为系统服务

vi /etc/init.d/pureftpd

录入

#!/bin/bash # chkconfig: 35 95 1 # description: script to start/stop pureftpd

case $1 in

start)

/usr/local/sbin/pure-config.pl /usr/local/etc/pure-ftpd.conf

;;

stop)

killall pure-ftpd

;;

*)

echo“Usage: $0 (start|stop)”

;;

esac

更改权限

# chmod 775 pureftpd

加入自动启动

# chkconfig ndash;add pureftpd

查看自动启动设置

# chkconfig ndash;list pureftpd

pureftpd 0:off 1:off 2:off 3:on 4:off 5:on 6:off

以后可以用以下命令启动和停止脚本

# service pureftpd start 启动

# service pureftpd stop 停止

启动和停止 mysql 服务

#service mysql start

#service mysql stop

若无法上传文件,设置 ftp 文件夹权限

chmod -R 777 /data0/htdocs

以上是“Pureftpd 和 mysql 如何架设 FTP 服务器”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注丸趣 TV 行业资讯频道!

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-08-25发表,共计3883字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)