centos 6.5 安装pure-ftpd + mysql
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos 6.5 安装pure-ftpd + mysql相关的知识,希望对你有一定的参考价值。
centos 6.5 安装pure-ftpd + mysql
一、自己到官网下载pure-ftp的tar.gz 的包,数据库我之前安装好了,这里就不写了,不会的自己百度
[email protected]:[/home/soft] % ll
[email protected]:[/home/soft] % tar xf pure-ftpd-1.0.41.tar.gz
二、编译安装
[email protected]:[/home/soft] % cd pure-ftpd-1.0.41 [email protected]:[/home/soft/pure-ftpd-1.0.41] % ldconfig [email protected]:[/home/soft/pure-ftpd-1.0.41] % ./configure --prefix=/home/pureftpd 安装路径根据自己服务器的情况指定) --with-mysql=/home/server/mysql --with-quotas --with-cookie --with-virtualhosts --with-virtualchroot --with-diraliases --with-sysquotas --with-ratios --with-altlog --with-paranoidmsg --with-shadow --with-welcomemsg --with-throttling --with-uploadscript --with-language=simplified-chinese
./configure --help 参数详解自己去看下上边的意思。
[email protected]:[/home/soft/pure-ftpd-1.0.41] % make && make install
三、设置配置文件
[email protected]:[/home/soft/pure-ftpd-1.0.41] %chmod 755 configuration-file/pure-config.pl [email protected]:[/home/soft/pure-ftpd-1.0.41] %chmod 755 configuration-file/pure-config.py [email protected]:[/home/soft/pure-ftpd-1.0.41] %cp configuration-file/pure-config.pl /home/pureftpd/sbin/ [email protected]:[/home/soft/pure-ftpd-1.0.41] %cp configuration-file/pure-config.py /home/pureftpd/sbin/
安装完后安装目录没有-- etc --的目录,需要自己手动创建。
[email protected]:[/home/soft/pure-ftpd-1.0.41] %mkdir /home/pureftpd/etc [email protected]:[/home/soft/pure-ftpd-1.0.41] %cp pureftpd-mysql.conf pureftpd-ldap.conf /home/pureftpd/etc/ [email protected]:[/home/soft/pure-ftpd-1.0.41] %cp configuration-file/pure-ftpd.conf /home/pureftpd/etc/
1、切换到安装目录【etc】目录
[email protected]:[/home/soft/pure-ftpd-1.0.41] %cd /home/pureftpd/etc/ [email protected]:[/home/pureftpd/etc/]%ls
[email protected]:[/home/pureftpd/]%ls
2、设置配置文件
[email protected]:[/home/pureftpd/etc/]%cp pure-ftpd.conf pure-ftpd.confbak [email protected]:[/home/pureftpd/etc/]%cp pureftpd-mysql.conf pureftpd-mysql.confbak [email protected]:[/home/pureftpd/etc/]%:>pure-ftpd.conf(清空配置文件内容) [email protected]:[/home/pureftpd/etc/]%vim pure-ftpd.conf(加入如下) [email protected]:[/home/pureftpd/etc/]% cat pure-ftpd.conf(具体参数自己百度,这里不说了)
Bind 21 ChrootEveryone yes BrokenClientsCompatibility no MaxClientsNumber 50 Daemonize yes MaxClientsPerIP 8 VerboseLog no DisplayDotFiles yes AnonymousOnly no NoAnonymous yes SyslogFacility ftp DontResolve yes MaxIdleTime 15 LimitRecursion 10000 8 AnonymousCanCreateDirs no MaxLoad 4 AntiWarez yes Umask 133:022 MinUID 500 AllowUserFXP no AllowAnonymousFXP no ProhibitDotFilesWrite no ProhibitDotFilesRead no AutoRename no AnonymousCantUpload no MaxDiskUsage 99 CustomerProof yes AllowOverwrite on AllowStoreRestart on UnixAuthentication yes PassivePortRange 20000 20500 MySQLConfigFile /home/pureftpd/etc/pureftpd-mysql.conf(这里是地指向pure-ftpd 的数据库文件)
[email protected]:[/home/pureftpd/etc/]%:> pureftpd-mysql.conf(清空配置文件内容)
[email protected]:[/home/pureftpd/etc/]%vim pureftpd-mysql.conf
(加入如下,我的数据库的配置文件就不拿出来,这个是网上的,但配置是一样的,只不过是数据库和表不同。)
MYSQLSocket /var/lib/mysql/mysql.sock # mysql.sock文件 MYSQLUser ftpuser # mysql用户名 MYSQLPassword ftppass # mysql密码 MYSQLDatabase ftpname # mysql数据库名 MYSQLCrypt md5 #加密方式,这里用md5加密 MYSQLGetPW SELECT Password FROM users WHEREUser="\L" AND Status="1" AND (Ipaddress = "*" ORIpaddress LIKE "\R") MYSQLGetUID SELECT Uid FROM users WHEREUser="\L" AND Status="1" AND (Ipaddress = "*" ORIpaddress LIKE "\R") MYSQLGetGID SELECT Gid FROM users WHEREUser="\L" AND Status="1" AND (Ipaddress = "*" ORIpaddress LIKE "\R") MYSQLGetDir SELECT Dir FROM users WHEREUser="\L" AND Status="1" AND (Ipaddress = "*" ORIpaddress LIKE "\R") MySQLGetQTAFS SELECT QuotaFiles FROM users WHERE User="\L"AND Status="1" AND (Ipaddress = "*" OR Ipaddress LIKE"\R") MySQLGetQTASZ SELECT QuotaSize FROM users WHEREUser="\L" AND Status="1" AND (Ipaddress = "*" ORIpaddress LIKE "\R") MySQLGetRatioUL SELECT ULRatio FROM usersWHERE User="\L" AND Status="1" AND (Ipaddress ="*" OR Ipaddress LIKE "\R") MySQLGetRatioDL SELECT DLRatio FROM usersWHERE User="\L" AND Status="1" AND (Ipaddress ="*" OR Ipaddress LIKE "\R") MySQLGetBandwidthUL SELECT ULBandwidth FROMusers WHERE User="\L" AND Status="1" AND (Ipaddress ="*" OR Ipaddress LIKE "\R") MySQLGetBandwidthDL SELECT DLBandwidth FROMusers WHERE User="\L" AND Status="1" AND (Ipaddress ="*" OR Ipaddress LIKE "\R")
这里重点说下;这个配置文件是你数据库的对应的数据库和表的内容,不要安照网上的复制,根据自己数据库建立的数据库和表做相应的配置。
三、配置启动参数(一定要这步,不然启动会报错)
[email protected]:[/home/pureftpd/etc/]%vim /etc/init.d/pureftpd (加如下内容)
#!/bin/bash /home/pureftpd/sbin/pure-config.pl /home/pureftpd/etc/pure-ftpd.conf :wq
[email protected]:[/home/pureftpd/etc/]%ln -s /home/pureftpd/sbin/pure-ftpd /usr/sbin/
四、查看启动参数
[email protected]:[/home/pureftpd/etc/]%/etc/init.d/pureftpd
Running: /usr/sbin/pure-ftpd -A -c50 -B -C8-D -fftp -H -I15 -lmysql:/etc/pureftpd-mysql.conf -L2000:8 -m4 -s -U133:022-u100 -j -k99 –Z
看到以上内容,说明启动成功
[email protected]:[/home/pureftpd/etc/]%ss -lanp | grep 21
[email protected]:[/home/pureftpd/etc/]%ps -ef | grep pure-ftpd
root 98428 1 0 Mar14 ? 00:00:00 pure-ftpd (SERVER) 看到这里说明成功 root 108211 108009 0 11:34 pts/1 00:00:00 grep pure-ftpd
五、配置虚拟用户作为数据库映射和ftp目录
[email protected]:[/home/pureftpd/etc/]%groupadd ftpgroup -g 1000
[email protected]:[/home/pureftpd/etc/]%useradd ftpuser(创建的帐号)-g ftpgroup -u 1000 -d /dev/null -s /sbin/nologin
[email protected]:[/home/pureftpd/etc/]%mkdir /home/ftpdir
[email protected]:[/home/pureftpd/etc/]%chmod -R 755 /home/ftpdir/
六、数据库设置
[email protected]:[/home/pureftpd/etc/]%mysql -uroot -p (进入数据库)
mysql> CREATE DATABASE ftpdb; mysql> GRANT ALL ON ftpdb.* TO ‘pureftpd‘@‘localhost‘ IDENTIFIED BY ‘对应的密码‘; mysql>GRANT ALL ON ftpdb.* TO ‘pureftpd‘@‘localhost.localdomain‘ IDENTIFIED BY ‘对应的密码‘; mysql>FLUSH PRIVILEGES; mysql> USE ftpdb; mysql> CREATE TABLE tp ( User varchar(16) NOT NULL default ‘‘, status enum(‘0‘,‘1‘) NOT NULL default ‘0‘, Password varchar(64) NOT NULL default ‘‘, Uid varchar(11) NOT NULL default ‘-1‘, Gid varchar(11) NOT NULL default ‘-1‘, Dir varchar(128) NOT NULL default ‘‘, ULBandwidth smallint(5) NOT NULL default ‘0‘, DLBandwidth smallint(5) NOT NULL default ‘0‘, comment tinytext NOT NULL, ipaccess varchar(15) NOT NULL default ‘*‘, QuotaSize smallint(5) NOT NULL default ‘0‘, QuotaFiles int(11) NOT NULL default 0, PRIMARY KEY (User), UNIQUE KEY User (User) ) TYPE=MyISAM; mysql>INSERT INTO `tp` (`User`, `status`, `Password`, `Uid`, `Gid`, `Dir`, `ULBandwidth`, `DLBandwidth`, `comment`, `ipaccess`, `QuotaSize`, `QuotaFiles`) VALUES (‘ftpuser‘, ‘1‘, MD5(‘secret‘), ‘2001‘, ‘2001‘, ‘/home/ftpdir‘, ‘0‘, ‘0‘, ‘‘, ‘*‘, ‘0‘, ‘0‘); (这步是向数据库中加入ftp帐号和密码) mysql>exit; 退出数据库
表格说明:
User:帐号名;status:0 表示帐号被禁用,无法登录服务器; Password:密码,使用MD5加密; Uid:前面创建的ftpuser帐户号,我们填写的是2001; Gid:前面创建的ftpgroup组号,我们填写的是2001; Dir:虚拟用户的个人目录路径,将在/home下创建(第一次登录); ULBandwidth:上传文件限制速度,KB/s,0为不限制; DLBandwidth:下载文件限制速度,KB/s,0为不限制; comment:备注信息; ipaccess:* 表示任意IP都可以访问此ftp服务器,输入具体IP地址可以只允许此IP连接服务器; QuotaSize:用户磁盘空间分配,单位:MB,0表示不加限制; QuotaFiles:用户可以保存的文件数量限制,0表示不加限制。
七、防火墙设置
[email protected]:[/home/pureftpd/etc/]% vim /etc/sysconfig/iptables
[email protected]:[/home/pureftpd/etc/]%cat /etc/sysconfig/iptables
[email protected]:[/home/pureftpd/etc/]%service iptables restart
至此完全配置完成。
八、测试ftp服务器
服务器ftp目录文件
[email protected]:[/home/pureftpd/etc/]% ll /home/ftpdir
total 18020 -rwxrwxrwx 1 ftpuser ftpgroup 18451420 Mar 10 14:39 xyj3and_60005.apk
客户端连接测试
本文出自 “昙花一现!” 博客,请务必保留此出处http://2475296.blog.51cto.com/2465296/1906801
以上是关于centos 6.5 安装pure-ftpd + mysql的主要内容,如果未能解决你的问题,请参考以下文章
CentOS7.2 FTP(pure-ftpd-1.0.43)安装
安装CENTOS 6.5 32位(CentOS-6.5-i386)+postfix+dovecot+openwebmail passwd验证的邮件系统