Gentoo installation configuration pure-ftpd combined with Mysql permission verification full process bitsCN.com
Gentoo installation configuration pure-ftpd combined with Mysql permission verification
1. install the pure-ftpd server
# Echo 'net-ftp/pure-ftpd mysql'>/etc/portage/package. use
Gentoo automatically installs mysql on the local machine.
# Emerge pure-ftpd
Configure the mysql database root password and install the initialization directory.
The root password I configured is root. if it is set to another one, the following Password also needs to be changed.
# Ebuild/var/db/pkg/dev-db/mysql-5.5.28/mysql-5.5.28.ebuild config
Modify the content of the client segment to the following, so that we can access the mysql database.
# Vim/etc/mysql/my. cnf
[Client]
User = root
Password = root
Host = 127.0.0.1
Port = 3306
Socket =/var/run/mysqld. sock
[Mysqld]
Servers-id = 220
Skip-name-resolve
#/Etc/init. d/mysql start
2. create a database and table in Mysql to store user permissions.
Www.bitsCN.com
# Mysql-A (the user and password in my. cnf are configured here)
Mysql> create database if not exists pureftpd;
Mysql> USE pureftpd;
Mysql>
Create table if not exists 'ftpd '(
'User' varchar (16) not null default ''comment 'username ',
'Status' enum ('0', '1') not null default '0' comment' available status: 0-unavailable; 1-in use ',
'Password' varchar (64) not null default ''comment 'password ',
'Uid' varchar (11) not null default'-1 'comment' user ID ',
'Gid' varchar (11) not null default'-1 'comment' group ID ',
'Dir' varchar (128) not null default ''comment' permission path ',
'Ulbandwidth' smallint (5) not null default '0' comment' Upload bandwidth ',
'Dlbandwidth' smallint (5) not null default '0' comment' download bandwidth ',
'Comment' tinytext not null comment' comment ',
'Ipaccess' varchar (15) not null default '* 'comment' IP Address ',
'Quotasize 'smallint (5) not null default '0' comment' size quota ',
'Quotafiles' int (11) not null default '0' comment' file type quota ',
Primary key ('user ')
) ENGINE = MyISAM default charset = gbk COMMENT = 'ftp username and password table ';
Mysql> add the user ftpduser so that it has the select permission on the databases under pureftpd.
Grant select on pureftpd. * to ftpduser @ '%' identified by 'ftpdpassword ';
Mysql> add a test data and log on later
Insert into 'ftpd' ('user', 'status', 'password', 'uid', 'gid', 'dir', 'ulbandwidth', 'dlbandwidth ', 'comment', 'ipaccess', 'quotasize ', 'quotafiles') VALUES ('testuser', '1', md5 ('testpassword'), '123 ', '81 ','/var/www ', 0, 0, 'note',' * ', 0, 0 );
3. modify the configuration file and use MYSQL for permission verification
# Vim/etc/conf. d/pure-ftpd
IS_CONFIGURED = "yes"
SERVER = "-S 10.36.32.220, 21"
MAX_CONN = "-c 50"
MAX_CONN_IP = "-C 20"
AUTH = "-l mysql:/etc/pureftpd-mysql.conf"
MISC_OTHER = "-A-H-x-j-R-Z-E-p 50001: 59999-O clf:/var/log/pureftpd. log"
# Mkdir-p/var/log/pureftpd/
The MYSQL configuration here is similar to that of MYSQL connected to PHP. Note that MYSQLCrypt refers to the encryption of user passwords.
# Vim/etc/pureftpd-mysql.conf
MYSQLServer 127.0.0.1
MYSQLPort 3306
MYSQLUser ftpduser
MYSQLPassword ftpdpassword
MYSQLDatabase pureftpd
MYSQLCrypt md5
MYSQLGetPW SELECT Password FROM ftpd WHERE User = "/L" AND status = "1" AND (ipaccess = "*" OR ipaccess LIKE "/R ")
MYSQLGetUID SELECT Uid FROM ftpd WHERE User = "/L" AND status = "1" AND (ipaccess = "*" OR ipaccess LIKE "/R ")
MYSQLGetGID SELECT Gid FROM ftpd WHERE User = "/L" AND status = "1" AND (ipaccess = "*" OR ipaccess LIKE "/R ")
MYSQLGetDir SELECT Dir FROM ftpd WHERE User = "/L" AND status = "1" AND (ipaccess = "*" OR ipaccess LIKE "/R ")
MySQLGetBandwidthUL SELECT ULBandwidth FROM ftpd WHERE User = "/L" AND status = "1" AND (ipaccess = "*" OR ipaccess LIKE "/R ")
MySQLGetBandwidthDL SELECT DLBandwidth FROM ftpd WHERE User = "/L" AND status = "1" AND (ipaccess = "*" OR ipaccess LIKE "/R ")
MySQLGetQTASZ SELECT QuotaSize FROM ftpd WHERE User = "/L" AND status = "1" AND (ipaccess = "*" OR ipaccess LIKE "/R ")
MySQLGetQTAFS SELECT QuotaFiles FROM ftpd WHERE User = "/L" AND status = "1" AND (ipaccess = "*" OR ipaccess LIKE "/R ")
4. add the nfsuser user and modify the permissions of the web Directory. if not, create the user first.
# Groupadd apache; useradd nfsuser-u 1002-g apache-d/dev/null-s/sbin/nologin
# Mkdir-p/var/www
# Chown-R nfsuser: apache/var/www
5. start pureftpd and test the connection with the client
#/Etc/init. d/pure-ftpd start
BitsCN.com