Mysql authentication and quota, speed limit, and other configurations of pureftpd
Source: Internet
Author: User
For mysql authentication of pureftpd and configurations such as quota and speed limit-Linux general technology-Linux technology and application information, see the following for details. 1. Download related programs
Wget Http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.21.tar.gz
Ii. Compile and install pureftp Tar zxvf pure-ftpd-1.0.21.tar.gz-C/usr/local/src/
Cd/Usr/local/src/pure-ftpd-1.0.21/
1, Improvements before Compilation
(1) IE pop-up login interface Vi src/ftpd. c
If (broken_client_compat! = 0 ){
Addreply (331, MSG_USER_ OK, username );
Return;
} Else {
//Die (530, LOG_DEBUG, MSG_NO_ANONYMOUS_LOGIN );//
Comment out this line Addreply(331, MSG_USER_ OK, account );//
Change to this line }
The above issues can be solved as follows: Pure-ftpd is a very good ftp server, but when IE is used to directly enter the FTP directory, if the system does not provide anonymous logon, the IE login interface will not pop up, instead, the warning dialog box that does not provide anonymous logon is displayed. In this case, how can I enable IE to directly pop up the logon dialog box? By analyzing the conversation process between IE and pure-ftpd, we can find that the original simple change can be implemented.
(2) correctly display the disk quota Vi./src/quotas. c
There is a statement in row 71st:
//* Bufpnt = 0;
This statement clears the second space used in the. ftpquota file in the root directory of the user to 0 and comment out the statement.
There is a statement in row 73rd:
Old_quota.size = quota-> size = strtoull (bufpnt + 1, NULL, 10 );
An error occurred while reading and passing the value to quota-> size. It should not be bufpnt + 1,
Buf + 1, Or
Bufpnt.
The above issues can be solved as follows: The disadvantage of a PureFTPd is that although the disk quota has been used, the following situations may occur. After the connection, you can only view the limited number of files and the disk space used cannot be displayed normally.
Of course, the disk quota information is still not displayed during webpage upload, but can be normally displayed using the command line or FTP tool.
2, Compilation and installation (the key point is to determine whether the new FTP User can be successfully managed through "User manager for PureFTP) ./Configure \-- Prefix =/usr/local/pureftpd -- with-mysql =/usr/local/mysql \-- With-mysql-lib =/usr/local/mysql/lib -- with-mysql-include =/usr/local/mysql/include \-- With-pam -- with-puredb -- with-quotas -- with-throttling -- with-ratios \-- With-uploadscript -- with-virtualhosts -- with-virtualchroot -- with-cookie \-- With-welcomemsg -- with-paranoidmsg -- with-ftpwho -- with-diraliases \-- Without-inetd -- sysconfdir =/usr/local/etc -- with-peruserlimits\
Make install-stripNote: If you do not use -- with-peruserlimits, you cannot limit the number of connections for each user. If not-- With-throttlingThe speed limit cannot be reached. If you do not use -- with-quotas, the disk quota is no longer available. -- With-language = simplified-chineseNo. Otherwise, the server logs are garbled.-- With-altlog is unnecessary, but syslogd is used to process logs.
3. Generate dedicated users and passwords for the pureftp System 1Generate dedicated users for the pureftp System
Chmod+ X/usr/local/sbin/pure-config.pl 2Create a dedicated user and password for the pureftp Database
/Usr/local/mysql/bin/mysql-u root? Pmysqlpasswd
Mysql>
Grant select, INSERT, UPDATE, DELETE, CREATE, drop on ftpusers. * TO 'pureftpd' @ 'localhost' identified by 'ftpasswd '; Database Name: ftpusers
User is pureftpd
The password is ftppasswd.
The database name ftpusers should not be changed, because the ftpusers database name is automatically created through the program later.
4. PassFtp_v2.1.tar.gzProgram from the browser to install the database and web interface management program Cd/Usr/local/src/
Tar zxvf ftp_v2.1.tar.gz Cp-rf ftp/usr/local/apache2/htdocs/ftpadmin
Because the installation requires that ftpadmin/be assigned 777 permissions first Chmod ? R 777/usr/local/apache2/htdocs/ftpadmin
Install the required database in the browser
Http://ip.ftpadmin/install.php
1. check whether all of them comply with the installation requirements. If they do not comply with the requirements, modify them and refresh them to see if they comply with the requirements.
2. Input
Database
Root permission and password
New database creation
3. Input
Pureftpd
Ftppasswd
Ftpusers
Corresponding to the User Password Database respectively (do not use the root database user and password for Management)
4. Change
FTP Address
, Default user ID
2001
, Default group ID
2001 check Quota support and Ratio support
5. Change the administrator password for managing pureftpd through a browser
At the same time, you can create a new super user
6. Follow the prompts to create and create
Pure-ftpd.confAnd pureftpd-mysql.conf
5. Create pure-ftpd.conf and pureftpd-mysql.conf configuration files Cd/usr/local/src/pure-ftpd-1.0.21/
Users who do not have a uniform apache operation need to read the above two files, so they can modify the attribute and read the attribute. 1. pure-ftpd.conf Configuration Vi/usr/local/etc/pure-ftpd.conf
CreateHomeDir yes NoAnonymous yes DisplayDotFiles no MaxClientsNumber 200
(We recommend that you do not activate FXP for authenticated users)AllowUserFXP no (We recommend that you Configure the server to support PASV mode. Otherwise, clients after nat cannot connect to pureftp in PORT mode)PassivePortRange 30000 50000 ForcePassiveIP *. * (Internet address) Shield quota files DisplayDotFiles no Yes. The ftpquota file is not displayed to the user.
Set the idle time to 5 minutes.MaxIdleTime 5
Shield Anonymous UsersNoAnonymous Yes Set the maximum number of concurrent users PerUserLimits 20:20Sets the maximum number of concurrent connections. The command takes effect only after the -- with-peruserlimits compilation option is added. by default, means that the same authenticated user can have up to three processes active at the same time. In actual applications, this process is too small. In particular, if you use win ie to log on, two processes are required, therefore, it is recommended that the configuration be larger. I configured 20: 20 Host Name not resolved DontResolve yesThe host name is not parsed in the log file. If the log is not so detailed, it uses less bandwidth. Permission of the created file (Umask parameter)By default, Umask 133: 022 is used. The first one is the file followed by a folder. The real file attributes must be reversed. If the default Umask attribute is used, the file attribute created by the user is 644, And the folder attribute is 755. Therefore, do not change the default value of the system.2. pureftpd-mysql.conf Configuration Vi/usr/local/etc/pureftpd-mysql.conf MYSQLSocket/Tmp/mysql. sock MYSQLUserPureftpd MYSQLPasswordFtppasswdMYSQLDatabaseFtpusersMYSQLCryptMd5MYSQLGetPW SELECT Password FROM users WHERE User = "\ L" AND Status = "1" AND (Ipaddress = "*" OR Ipaddress LIKE "\ R ")MYSQLGetUID SELECT Uid FROM users WHERE User = "\ L" AND Status = "1" AND (Ipaddress = "*" OR Ipaddress LIKE "\ R ") MYSQLGetGID SELECT Gid FROM users WHERE User = "\ L" AND Status = "1" AND (Ipaddress = "*" OR Ipaddress LIKE "\ R ") MYSQLGetDir SELECT Dir FROM users WHERE User = "\ L" AND Status = "1" AND (Ipaddress = "*" OR Ipaddress LIKE "\ R ") MySQLGetQTAFS SELECT QuotaFiles FROM users WHERE User = "\ L" AND Status = "1" AND (Ipaddress = "*" OR Ipaddress LIKE "\ R ") MySQLGetQTASZ SELECT QuotaSize FROM users WHERE User = "\ L" AND Status = "1" AND (Ipaddress = "*" OR Ipaddress LIKE "\ R ") MySQLGetRatioULSELECT ULRatio FROM users WHERE User = "\ L" AND Status = "1" AND (Ipaddress = "*" OR Ipaddress LIKE "\ R ") MySQLGetRatioDLSELECT DLRatio FROM users WHERE User = "\ L" AND Status = "1" AND (Ipaddress = "*" OR Ipaddress LIKE "\ R ") MySQLGetBandwidthULSELECT ULBandwidth FROM users WHERE User = "\ L" AND Status = "1" AND (Ipaddress = "*" OR Ipaddress LIKE "\ R ") MySQLGetBandwidthDLSELECT DLBandwidth FROM users WHERE User = "\ L" AND Status = "1" AND (Ipaddress = "*" OR Ipaddress LIKE "\ R ")
6. Create a server execution file for pureftpd
Vi/etc/rc. d/init. d/pure-ftpd
Start the pureftpd Service /Etc/rc. d/init. d/pure-ftpd start
Disable Service KillallPure-ftpd
Ps-Aux | grep pureftp
VII. Set pureftp logs Vi/etc/syslog. conf Ftp. */var/log/pureftpd Mkdir/Var/log/pureftpd Touch/var/log/pureftpd ChownFtpuser. ftpgroup/var/log/pureftpd Killall-HUP syslogd Vi/usr/local/etc/pure-ftpd.conf SyslogFacilityFtp VerboseLogYes /Etc/init. d/pure-ftpd restart
Note: if it is set to VerboseLog yes, all user operations are recorded (including file upload and download) (I personally think this is not set, it is too cumbersome, and there are too many logs)
8. Set browser Management Interface Optimization 1Security considerationsFor security issues, we recommend that you change the ftpadmin directory owner to the default user of ftpuser. ftpgroup, and grant the general user the permission of 5 Chown-R ftpuser. ftpgroup ../ftpadmin/ Chmod ? R 755/usr/local/apache2/htdocs/ftpadmin
In this way, the security is better. Pay attention to the following two points: 1, Use ftp: // IP in the browser Permission: ftpuser. ftpgroup 2In http: // ip/ftpadmin, you can view the entire system directory. This permission is the default user permission of apache. 2Set browser Management Interface OptimizationVi/usr/local/apache2/htdocs/ftpadmin/index. php
569th rows $ Dir = "/Home/ftp ";
$ Status = "1 "; $ Quotafiles = "0 "; (File limit, 0 is unlimited)
745th rows shielded // Echo ("Value = \ "$ dir \"> \ n ");
In this way, you can manually enter and set the root directory of each ftp user during management. Otherwise, you have to select the root directory from the browser interface, which is depressing! Note 1: In the personal user directory, the. ftpquota mainly writes the number of users used. Not set. Based on the above configuration: Automatic Directory Creation, Status Bar Setting, speed limit (up and down) and disk capacity limit are all OK !!
3Modify the traditional Chinese language environment to the simplified language environment
$ Translate [94] = "speed limit for downloading an object (unit: KB/s )";
$ Translate [95] = "Limit the maximum number of files that can be stored by this account. ";
$ Translate [96] = "Limit the maximum (maximum) space that this account can store. (Unit: Mb )";
$ Translate [97] = "for example, <> indicates that at least 4 Mb of data can be uploaded before 8 Mb of data can be downloaded. <0: 0>? T is to disable the upper/lower transfer ratio limit ";
$ Translate [98] = "limit that this account can only be used by a specific IP Address Source, or anywhere (*)";
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.