Pureftpd+mysql+php_manager configuration method to implement disk quotas for virtual users _FTP server

Source: Internet
Author: User
Tags anonymous crypt ldap local time md5 create database server port
In the installation pureftpdBefore, you should do the following preparation work:
1. Install the FreeBSD4.9 system.
2. Customize the kernel, add "options QUOTA" in the kernel to achieve user quota support (note: How other *nix system to achieve, please your own search implementation. )
3. Install the apache+php platform, because we need to use Php_manager to achieve user online management. (Note: There are a lot of tutorials on the web of this installation, which can be installed directly in the FreeBSD under the Ports method.) )
After doing the above preparation, we can begin to enter the real installation process.
(Note: All of the following installations are installed in ports manner)
First, installation Mysql
I installed the MysqlIt's version 4.0, so if you have the latest, you can try it.

# Cd/usr/ports/databases/mysql40-server
# Make install clean

Generate startup scripts after installation in/usr/local/etc/rc.d/ MySQL-server.sh

You can run the following command to see MysqlWhether the service has started.

# ls | Grep MySQL

If there is a return message, it means MysqlAlready started, if not started, run the following command.

# CD/USR/LOCAL/ETC/RC.D
# ./ MySQL-server.sh start

If you want to stop MysqlService.

#/usr/local/etc/rc.d/ MySQL-server.sh stop

After confirming that the service is started, let's test that the database is running properly:
(Note: By default MysqlThe user is root, the password is blank, so please log in now MysqlTo modify the root user's password)

# MySQL

The following representation appears to be working correctly.

Welcome to the MySQLMonitor. Commands End With; or \g.
Your MySQLConnection ID is to server version:4.0.18
Type ' help, ' or ' \h ' for help. Type ' \c ' to clear the buffer.
MySQL>
Enter Exit exit Mysql

For MysqlThe root user set a password 123456

# mysqladmin-u root password ' 123456 '

When you are finished, we will test if the password is valid.

# MySQL-U root-p
Enter Password:

The prompt password appears, enter the correct password and return.
If the following occurs, the setting is successful.
Welcome to the MySQLMonitor. Commands End With; or \g.
Your MySQLConnection ID is to server version:4.0.18
Type ' help, ' or ' \h ' for help. Type ' \c ' to clear the buffer.
MySQL>

If the following occurs, the setting fails. (If so, you are miserable, haha)

ERROR 1045:access denied for user: ' Root@localhost ' (Using password:yes)


Second, the installation pureftpd
1. Below we begin to install pureftpd, and is also installed in a FreeBSD ports manner.

# CD/USR/PORTS/FTP/PURE-FTPD
# make with_mysql=1 \ MYSQLDatabase support
With_lang=simplified-chinese \ Hint text is Simplified Chinese
configure_args= \
'--prefix=/usr/local/ pureftpd\ installation Directory
--WITH-PARANOIDMSG//Um ..... I don't know what to say. It's a message for a specific person.
--WITH-WELCOMEMSG \//Support login information display, I can't do it anyway, haha
--with-uploadscript \//When a file is fully uploaded, automatically calls a script to the file
Process. Of course. You write this script yourself.
--with-largefile \//supports downloading more than 2G of files.
--with-cookie \//user stops to see the stuff. Similar to the pit-stop screen.
--with-virtualchroot \//Safe chroot.
--with-virtualhosts \//VirtualHost with HTTP.
--with-virtualroot \//Virtual root support
--with-diraliases \//With the link function above serv-u.
--with-quotas \//Use quota. (Quota under non-system)
--with-sysquotas \//allow use of operating system quota (disk quota)
--with-ratios \//up/down ratio support.
--with-ftpwho \//Use the pure-ftpwho command to view online users.
--with-everything \//All functions are in full. (Do It yourself)
--with-throttling '///bandwidth can be set.
Install clean


Once installed, a/usr/local directory is generated in the pureftpdDirectory, we are going to use the files in this directory.

2. Below we begin to configure the pure-ftpd.conf file
Here I use the default values, only to modify the content below to support MYSQL。 Note pureftpdCan support LDAP at the same time, MySQL, PGSQL,PUREDB Certification)

# MySQLConfiguration file (for a. MySQL)
mysqlconfigfile/usr/local/ pureftpd/etc/ pureftpd- MySQL. conf

3. Detailed configuration file (excerpt from the online Chen Jingfeng "PURE-FTPD + LDAP + MySQL+ pgsql + virtual-users + Quota to ")
Chrooteveryone Yes
Chroot each user, equivalent to the defaultroot~ in proftpd, can restrict the user's activity in one place and enhance the security of the server. Use of WU-FTPD should know what CD/what will happen!
Trustedgid 50
#以上两者要一起用
Brokenclientscompatibility No
Maxclientsnumber 50
#最大链接数
Daemonize Yes
#Fork in background run in the background in daemon mode
Maxclientsperip 5
#每个ip最多链接数, it's better to set a small point.
Verboselog No
#是否要把所有client端的指令都log下来
Displaydotfiles No
#显示开头的文件
AnonymousOnly No
#是否只让匿名登录
Noanonymous No
#不开放匿名登入
Syslogfacility FTP
#应该是对日志做一下过滤 (auth, Authpriv, daemon, FTP, security, user, local*) allows logs to record only the information you want
Dontresolve Yes
#不反向解释客户端的ip
MaxIdleTime 5
#最大闲置時間
#LDAPConfigFile/usr/local/ pureftpd/etc/ pureftpd-ldap.conf
#使用LDAP认证,
mysqlconfigfile/usr/local/ pureftpd/etc/ pureftpd- MySQL. conf
#使用 MySQLCertification
#PGSQLConfigFile/usr/local/ pureftpd/etc/ pureftpd-pgsql.conf
#使用PGSQL认证
#PureDB/ftp/etc/ pureftpd. pdb
#使用者资料的DB存放地点 [As I was using pureftpdBuilt-in db. Intrinsic to this option]
#ExtAuth/var/run/ftpd.sock
#pure-AUTHD socket Path (see README for details). Authentication-modules)
#PAMAuthentication Yes
#开启PAM认证
#UnixAuthentication Yes
#如果你想要有简单的Unix (/ETC/PASSWD) certification
fortunesfile/usr/local/ pureftpd/etc/.welcome
#显示的欢迎信息文件, you can create the file, enter some text, and then you restart your FTP service, there will be an unexpected discovery.
Limitrecursion 2000 8
#ls最多列出3000个文件. The deepest 8 floors
Anonymouscancreatedirs No
#匿名用户可以创建目录
Maxload 4
#当system load exceeds 4. Users will no longer be able to download
PassivePortRange 30000 50000
#被动连接应答范围
Forcepassiveip 192.168.0.1
#不会译: (
Anonymousratio 1 10
#Anonymous连接上传/Download ratio
Userratio 1 10
#用户上传/Download ratio (Note: If LDAP is used, MySQL, pgsql,pam do not enable this feature, otherwise you set up in LDAP and other ratio without the school)
Antiwarez No
#上传的文件不能被下载 (Owner is FTP). Wait until local admin confirms
Bind 127.0.0.1,8021
#要绑定和ip/port, there are two FTP servers in your system so one of your FTP will use a different port.
#格式-> 127.0.0.1,21 If you write only the port table all Ip,port
Anonymousbandwidth 8
#Anonymous bandwidth, Unit kb/s
Userbandwidth 8
#用户带宽, Unit kb/s
Umask 133:022
#上传文件的Umask. (<umask for Files>:<umask for dirs>)
Minuid 1000
# UID At least how many to log in
ALLOWUSERFXP Yes
#支不支持FXP
ALLOWANONYMOUSFXP No
#Anonymous支不支持FXP
Prohibitdotfileswrite No
Prohibitdotfilesread No
#(”.”) The beginning of the file can be read/written, UNIX like the point at the beginning of the file is hidden file ls–a to list
# pureftpdQuota mode produces the ". Ftpquota" file.
Autorename No
#上传文件若有相同文件名自动改名 (File.1,file.2 ...)
Anonymouscantupload No
#匿名用户上传文件
Trustedip 10.1.1.1
#锁IP.
Logpid
#Log文件添加PID
Altlog stats:/ftp/etc/log/ pureftpd. log
#log存放地点, there are several commonly used formats for note logs
#clf similar to the Apache format, stats UNIX log format, the standard format for the International consortium, may be HTML format
Nochmod Yes
#不给Chmod指令的权限
Keepallfiles No
#使用者可续传. But cannot erase files
Createhomedir Yes
#如果user的home不存在自动建立 (I set this to Yes)
Quota 1000:10
#Quota < files >:< capacity megabytes >,ftp limit 10M space, you can upload 1000 files (note: If LDAP is used, MySQL, pgsql,pam do not enable this feature, otherwise you set up in LDAP and other quota without the school)
Pidfile/ftp/etc/log/pure-ftpd.pid
#记录pure-ftpd pid File
Calluploadscript Yes
#呼叫UploadScript
Maxdiskusage 99
#当硬盘使用率到多少時将停止上传
Norename Yes
#用户不能重命名文件名
Customerproof Yes
Peruserlimits 3:20
#< each account can be logged up to several times: Anonymous can log in at most times >

4. Create MysqlFTP Virtual User Management database in a database ftpusers
Save the following as a script. MySQLFile

INSERT into MySQL. User (Host, user, Password, Select_priv, Insert_priv, Update
_priv, Delete_priv, Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Proces
S_priv, File_priv, Grant_priv, References_priv, Index_priv, Alter_priv) VALUES
(' 127.0.0.1 ', ' ftp ', PASSWORD (' 123456 '), ' y ', ' y ', ' y ', ' y ', ' n ', ' n ', ', ' n ', ' n ', ' n ', ' n ', ', ' ', ', '
', ' n ', ' n ', ' n ', ' n ';

FLUSH privileges;

CREATE DATABASE ftpusers;

Use Ftpusers;

CREATE TABLE Admin (
Username varchar () not NULL default ',
Password char () binary not NULL default ',
PRIMARY KEY (Username)
) Type=myisam;

INSERT into admin VALUES (' Administrator ', MD5 (' 123456 '));

CREATE TABLE Users (
User char not NULL default ',
Password char () binary not NULL default ',
Uid Int (one) not NULL default ' 2000 ',
Gid Int (one) not NULL default ' 2000 ',
Dir Char (128) Not NULL default ',
Quotafiles Int (a) not NULL default ' 500 ',
quotasize Int (a) not NULL default ' 30 ',
Ulbandwidth Int (a) not NULL default ' 80 ',
Dlbandwidth Int (a) not NULL default ' 80 ',
Status enum (' 0 ', ' 1 ') not NULL default ' 1 ',
ipaccess varchar NOT NULL default ' * ',
Comment Tinytext not NULL,
PRIMARY KEY (User),
UNIQUE KEY User (user)
) Type=myisam;

INSERT into ' users ' VALUES (' Kevin ', MD5 (' 123456 '), 1001,2000, '/home/kevin ', 500, 30,
80,5);

First in MysqlDatabase to establish a database with operational permissions of the user FTP, the password is 123456.
Then create a new database ftpusers, and new two tables Admin and users, add the Admin user account to the Admin table, add the new FTP user Kevin to the users table, and the password is 123456.

Then we run the following command to build the database ftpusers.

# MySQL-U root-ppassword < script. MySQL
Note that-P is the password, and there are no spaces in the password that you entered later.

5. Modify/usr/local/ pureftpd/etc/ pureftpd- MySQL. conf configuration file
The contents are as follows:

MySQLServer 127.0.0.1
# MYSQLIP of the server
Mysqlport 3306
# MYSQLPort number
mysqlsocket/var/lib/ MySQL/ MySQL. Sock
#使用UNIX. Sock Local Area Connection
Note: MySQLServer and Mysqlsocket Choose one

Mysqluser FTP
#MYSQLUser Data User Name
Mysqlpassword 123456
# MYSQLPassword for database user
Mysqldatabase ftpusers
#FTP数据数据库
Mysqlcrypt MD5
#密码加密方式 "Cleartext", "Crypt", "MD5" and "password"
# cleartext plaintext, Crypt,md5,password is the backend password (' your-passwd ') function ( MYSQLThe password () function used by the database
MYSQLGETPW Select Password from Users WHERE user= "\l"
# password field, I use the password in the Users table as the password field
Mysqlgetuid Select Uid from Users WHERE user= "\l"
#UID用户ID字段
Mysqldefaultuid 1000
#默认的UID (Note: How to turn this option on, Mysqlgetuid will be out of effect)
Mysqlgetgid SELECT Gid from users WHERE user= "\l"
#GID组ID字段
Mysqldefaultgid 1000
#默认的GID (Note: How to turn this option on, Mysqlgetgid will be out of effect)
Mysqlgetdir Select Dir from Users WHERE user= "\l"
#FTP用户目录如/home/web/www-9812-net
Mysqlgetqtafs Select Quotafiles from Users WHERE user= "\l"
#磁盘限额, number of files limited. such as 1000, allow users to upload 1000 files
Mysqlgetqtasz Select Quotasize from Users WHERE user= "\l"
#磁盘限额, FTP User space limit (in m), for example: 100M
Mysqlgetratioul Select Ulratio from Users WHERE user= "\l"
Mysqlgetratiodl Select Dlratio from Users WHERE user= "\l"
#上传/Download ratio. Mysqlgetratioul for upload ratio, Mysqlgetratiodl download ratio. such as: 1:5
Mysqlgetbandwidthul Select Ulbandwidth from Users WHERE user= "\l"
MYSQLGETBANDWIDTHDL Select Dlbandwidth from Users WHERE user= "\l"
#下传/Download bandwidth (unit kb/s). Mysqlgetbandwidthul upload bandwidth, mysqlgetbandwidthdl download bandwidth. such as upload 500kb/s, download 50kb/s
Mysqlforcetildeexpansion 1
Mysqltransactions on
#不会翻译


After modifying the configuration file, we continue.

6. Run pureftpd
In order to achieve anonymous logon, you need to add an FTP user to the system.

With FTP. You have to have an account, of course.
#vipw
FTP:*:2000:2000::0:0:FTP:/HOME/FTP:
/sbin/nologin
#vi/etc/group
ftpusers:*:2000:

After the operation, we add an FTP account to belong to the Ftpusers group, the user ID and group ID are 2000

Start pureftpd
#/usr/local/ pureftpd/bin/pure-config.pl.. /etc/pure-ftpd.conf

In order to facilitate the management of FTP services in the future, I created a new one in/USR/LOCAL/ETC/RC.D. pureftpd. sh file.

# VI pureftpd. sh

#!/bin/sh

Case "$" in
Start
[-x/usr/local/ pureftpd/ETC/PURE-FTPD.CONF] &&
/usr/local/ pureftpd/bin/pure-config.pl/usr/local/ pureftpd/etc/pure-ftpd.c
onf >/dev/null && \
Echo-n ' Pure-ftp '


Stop
Killall pure-ftpd >/dev/null && \
Echo-n ' Pure-ftp '


*)
echo "Usage: ' basename $ ' {start | Stop} ">&2

Esac

Exit 0

Set executable permissions for this file

# chmod U+x pureftpd. sh

You can start with the following command later pureftpdService

#/usr/local/etc/rc.d/ pureftpd. SH Start

Stop with the following command pureftpdService

#/usr/local/etc/rc.d/ pureftpd. SH Stop

Test the FTP is OK.
# FTP Your IP
Connected to 127.0.0.1.
----------Welcome to PURE-FTPD----------
220-You are the 1th user, up to 50 connections
220-It is 09:02 local time. Server port: 21.
220 no activity within 15 minutes, you will be disconnected.
Name (127.0.0.1:kevin): Kevin
Password:
230-User Kevin has permissions for the following groups: Ftpusers
230-This server supports FXP transmission
230-ok. The currently restricted directory is/
Remote system type is UNIX.
Using binary mode to transfer files.
Ftp>

Congratulations, your FTP service is working properly.

Third, the use of Php_manager for user management

Download the latest Php_manager software

# tar ZXVF ftp_v1.3.1.tar.gz
# MV Ftp_v1.3.1/www/path/data/ftp
# cd/www/path/data/ftp
# VI config.php
modifying config.php configuration Files

$LANG = $ZH _cn; The language of your Php_manager
$DBHost = "localhost"; Yours MysqlHost of the server
$DBLogin = "ftp"; Users who log on to the database
$DBPassword = "123456"; User password for login to database
$DBDatabase = "Ftpusers"; The name of the database that implements the virtual user management
$FTPAddress = "61.132.35.21:21"; The IP address and port number of your FTP service

Then use the Web page way to log on to administration.

http://Your server domain/ftp

Admin is administrator, password is 123456, this can be modified when the database is built.
After entering all Chinese, don't I write more.
Wish you all a happy!

I have changed the Php_manager to support the Chinese language, is now handed up for everyone to use.

http://www.linuxsir.org/bbs/attachment.php?s=&postid=578136

For installation methods under other systems, refer to Chen Jingfeng's PURE-FTPD + LDAP + MySQL+ pgsql + virtual-users + Quota "
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.