In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the FTP service Proftpd+mysql+quota example analysis, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand.
1 download related software
1.1 download proftpd
1.2 download MySQL
1.3download proftpd-mod-quotatab
2 installation
2.1 decompress proftpd-1.2.9rc1.tar.gz
2.2 decompress proftpd-mod-quotatab-1.2.10.tar.gz
2.3 install MySQL
2.4 compile and install proftpd and proftpd-mod-quotatab
3 configuration
3.1 configure the proftpd.conf file
3.1.1 set disk quota
3.1.2 specify the database information used by the disk quota module
3.1.3 configure FTP users to authenticate MySQL database
4 create FTP system users and groups
5 establish FTP user authentication related table
6 establish a disk quota data table
7 data table data initialization
8 run proftpd
9 configure proftpd execution script
10 FAQ
11 other questions
1 download related software
1.1 download proftpd
The proftpd-1.2.9rc1 version of for Linux can be downloaded at the following address:
Http://www.proftpd.org/download.html
The above address is a list of FTP download sites. Choose one of your own.
1.2 download MySQL
MySQL can be downloaded from http://www.mysql.com. Generally speaking, MySQL has been installed by default in every Linux distribution. You can check it with the following command:
Rpm-qa | grep MySQL
If not, please find it on your own Linux installation CD and install it. It will start automatically after installation. You can check it with the following command:
Ps-ef | grep mysql
If you see the corresponding process, it means that MySQL is already running, otherwise, start it yourself:
/ etc/rc.d/init.d/mysql start
1.3download proftpd-mod-quotatab
The following is the download address of proftpd-mod-quotatab:
Http://www.castaglia.org/proftpd/modules/proftpd-mod-quotatab-1.2.10.tar.gz
2 installation
2.1 decompress proftpd-1.2.9rc1.tar.gz
Assuming that the downloaded proftpd-1.2.9rc1.tar.gz file is in the / root directory, enter this directory first, and then execute:
Tar-xzvf proftpd-1.2.9rc1.tar.gz
2.2 decompress proftpd-mod-quotatab-1.2.10.tar.gz
Tar-xzvf proftpd-mod-quotatab-1.2.10.tar.gz
2.3 install MySQL
Suppose the rpm package name of MySQL is MySQL-3.23.56-i386.rpm
Rpm-ivh MySQL-3.23.56-i386.rpm
2.4 compile and install proftpd and proftpd-mod-quotatab
First, enter the extracted proftpd-mod-quotatab directory, copy all the files in this directory to the modules directory in the extracted proftpd directory, and then go to the contrib directory to edit the mod_sql_mysql.c file:
Vi mod_sql_mysql.c
Find the line # include and change mysql.h to the path where this file is located on your system, such as / usr/include/mysql/mysql.h
Then execute in the unzipped proftpd directory:
. / configure-prefix=/usr/local/proftpd-with-modules=mod_sql:mod_sql_mysql:mod_quotatab:mod_quotatab_sql-with-includes=/usr/include/mysql-with-libraries=/usr/lib/mysql
Note that according to your own Linux system, please find the corresponding include and lib directories of MySQL. The relevant paths in the above examples are the default of most Linux systems. If your MySQL is installed through source code compilation, these two directories are generally under the installation path.
If there are no errors in configure, then you can make;make install.
Make
Make install
When finished, a proftpd directory will be generated under the / usr/local directory:
Cd / usr/local/proftpd
Ls will see five directories of bin etc man sbin var. Executing sbin/proftpd will start the proftpd service, but you are still using the system user. Please continue to see the following.
3 configuration
3.1 configure the proftpd.conf file
Edit the / usr/local/proftpd/etc/proftpd.conf file:
3.1.1 set disk quota
# set disk quota
QuotaDirectoryTally on
# set the unit of disk capacity display
QuotaDisplayUnits "Kb"
# turn on the disk quota engine
QuotaEngine on
# set disk quota log file
QuotaLog "/ usr/local/proftpd/var/quota"
# allow disk quota information to be displayed. After ftp login, execute quote site quota command to check current disk usage
QuotaShowQuotas on
3.1.2 specify the database information used by the disk quota module
Add the following configuration to the proftpd.conf file:
SQLNamedQuery get-quota-limit SELECT "name, quota_type, per_session, limit_type, bytes_in_avail,\"
Bytes_out_avail, bytes_xfer_avail, files_in_avail, files_out_avail, files_xfer_avail FROM quotalimits\
WHERE name ='% {0} 'AND quota_type ='% {1}'"
SQLNamedQuery get-quota-tally SELECT "name, quota_type, bytes_in_used, bytes_out_used,\"
Bytes_xfer_used, files_in_used, files_out_used, files_xfer_used FROM quotatallies\
WHERE name ='% {0} 'AND quota_type ='% {1}'"
SQLNamedQuery update-quota-tally UPDATE "bytes_in_used = bytes_in_used +% {0},\
Bytes_out_used = bytes_out_used +% {1}, bytes_xfer_used = bytes_xfer_used +% {2},\
Files_in_used = files_in_used +% {3}, files_out_used = files_out_used +% {4},\
Files_xfer_used = files_xfer_used +% {5}\
WHERE name ='% {6} 'AND quota_type ='% {7}'"quotatallies
SQLNamedQuery insert-quota-tally INSERT "{0},% {1},% {2},% {3},% {4},% {5},% {6},% {7}" quotatallies
QuotaLimitTable sql:/get-quota-limit
QuotaTallyTable sql:/get-quota-tally/update-quota-tally/insert-quota-tally
3.1.3 configure FTP users to authenticate MySQL database
Add the following configuration to the proftpd.conf file:
SQLConnectInfo databaseName@hostName:port userName password
# databaseName is the name of the MySQL database created for proftpd
# hostName is the name or ip address of the server where the MySQL database is located
# port is the port used by the MySQL service
# userName is the user name of the database
# password is the database user password
SQLAuthTypes Backend Plaintext
# Backend indicates that the user authentication method is the authentication method of MySQL database
# Plaintext indicates the plaintext authentication method, and the one at the top of the list is the one used.
SQLUserInfo ftpUser userid passwd uid gid homedir shell
# specify the name of the ftp user data table and the field name in it. The table name can be defined by itself, and the field name remains unchanged.
SQLGroupInfo ftpGroup groupname gid members
# specify the name of the ftp user group data table and the field name in it. This data table is optional and the field name should not be changed.
RequireValidShell off
# specify whether a system must be specified for FTP users: shell,off means not specified, on means it must be specified. Off should be specified for system security.
SQLAuthenticate users groups usersetfast groupsetfast
# check the data sheet
SQLHomedirOnDemand on
# if the user's home directory does not exist, the system creates a new directory based on the user's value in the homedir field in the user data table
4 create FTP system users and groups
Create a FTP user and group, and all other FTP users will actually FTP through this system user:
Groupadd-g 2003 ftpGroup
Useradd-u 2003-g ftpGroup-d / home ftpUser
Above, a ftp group named ftpGroup is established, the group id is 2003; a ftp user is established, the user id is 2003, and join the ftpGroup group, and the user's home directory is / home
Then modify the owner and access permissions of / home:
Chown-R ftpUser.ftpGroup / home
Chmod 644 / home
Please check the relevant documents for the specific meaning of 644.
Then modify the proftpd.conf file, find User and Group, specify User as ftpUser,Group and ftpGroup, and replace the original default value, otherwise, if there are no users and groups specified by the original default value in the system, proftpd cannot be started successfully.
5 establish FTP user authentication related table
Mysql-u root
Use mysql
Add a mysql user: ftp
Add a database: proftpd
Please refer to the MYSQL manual for specific instructions.
After building the user and database, log in to MYSQL as the newly created user:
Mysql-u ftp
Use proftpd
Create table ftpUser (userid TEXT NOT NULL,passwd TEXT NOT NULL,uid INT NOT NULL,gid INT NOT NULL,homedir TEXT,shell TEXT)
Userid is the user name, passwd is the user's password, uid is the user's id,gid, id,homedir is the user's home directory, and shell is the user's system shell.
Create table ftpGroup (groupname TEXT NOT NULL,gid SMALLINT NOT NULL,members TEXT NOT NULL)
Groupname is the group name, gid is the group id,members is a member of the group, and when there are multiple members, they are separated by commas.
The data tables for FTP users and user groups are established above.
6 establish a disk quota data table
CREATE TABLE quotalimits (
Name VARCHAR (30)
Quota_type ENUM ("user", "group", "class", "all") NOT NULL
Per_session ENUM ("false", "true") NOT NULL
Limit_type ENUM ("soft", "hard") NOT NULL
Bytes_in_avail FLOAT NOT NULL
Bytes_out_avail FLOAT NOT NULL
Bytes_xfer_avail FLOAT NOT NULL
Files_in_avail INT UNSIGNED NOT NULL
Files_out_avail INT UNSIGNED NOT NULL
Files_xfer_avail INT UNSIGNED NOT NULL
);
CREATE TABLE quotatallies (
Name VARCHAR (30) NOT NULL
Quota_type ENUM ("user", "group", "class", "all") NOT NULL
Bytes_in_used FLOAT NOT NULL
Bytes_out_used FLOAT NOT NULL
Bytes_xfer_used FLOAT NOT NULL
Files_in_used INT UNSIGNED NOT NULL
Files_out_used INT UNSIGNED NOT NULL
Files_xfer_used INT UNSIGNED NOT NULL
);
The above quotalimits table is the disk quota configuration information of FTP users, and the quotatallies table stores the information of users' disk quota changes.
The quotatallies table does not need to be modified and is automatically recorded by the program.
The following is the meaning of the fields in the quotalimits table:
Identification of quota_type disk quota
Number of bytes uploaded to bytes_in_avail, which is the capacity of FTP user space
Number of bytes downloaded by bytes_out_avail
Total number of bytes of files that can be transferred by bytes_xfer_avail (upload and download traffic)
Total number of files that files_in_avail can upload
The total number of files that files_out_avail can download from the server
Total number of files that can be transferred by files_xfer_avail (upload and download)
7 data table data initialization
After the table is all built, you can create a FTP user. Insert a record in the ftpUser table as follows:
INSERT INTO ftpUser (userid, passwd, uid, gid, homedir, shell) values ('shine', password (' yourpassword'), '2003,' 2003,'/ home/shine',')
A new FTP user is created above. The user name is shine and the password is yourpassword. You can see that the password is encrypted with the system function password of mysql. The user id and group id are both 2003. Please fill in here. I entered the same id as the system user ftpUser and system group ftpGroup. I don't know if there will be a problem. / home/shine is the user's home directory, and the user shell is empty.
If you want to apply more functions and set up a group's datasheet, you should also add records to it, but be sure to separate multiple members with commas in the members field.
INSERT INTO ftpGroup VALUES ('ftpGroup', 2003,' ftpUser')
Let's establish the initial user disk quota information:
The established shine account is given a space of 50m, and a maximum of 500m files can be uploaded. The file transfer traffic is 512k. A total of 2000 files can only be transferred. Insert records are as follows:
INSERT INTO quotalimits (name,quota_type,per_session,limit_type,bytes_in_avail,bytes_out_avail
Bytes_xfer_avail,files_in_avail,files_out_avail,files_xfer_avail) VALUES ('shine',' user', 'true',' soft', '51200000, 51200000)
8 run proftpd
Execute the following command to start the proftpd service:
/ usr/local/proftpd/sbin/proftpd
Open a console to enter:
Ftp ftpHostName
Enter user name: shine
Enter user password: yourpassword
Execute after successful login:
Quote site quota
You can see the disk usage of this user.
9 configure proftpd execution script
Cd / usr/local/proftpd/bin
Vi proftpd
Enter the following:
#! / bin/sh
# ProFTPD files
FTPD_BIN=/usr/local/proftpd/sbin/proftpd
FTPD_CONF=/usr/local/proftpd/etc/proftpd.conf
PIDFILE=/usr/local/proftpd/var/proftpd.pid
# If PIDFILE exists, does it point to a proftpd process?
If [- f $PIDFILE]; then
Pid= `cat $PIDFILE`
Fi
If [!-x $FTPD_BIN]; then
Echo "$0: $FTPD_BIN: cannot execute"
Exit 1
Fi
Case $1 in
Start)
If [- n "$pid"]; then
Echo "$0: proftpd [PID $pid] already running"
Exit
Fi
If [- r $FTPD_CONF]; then
Echo "Starting proftpd..."
$FTPD_BIN-c $FTPD_CONF
Else
Echo "$0: cannot start proftpd-- $FTPD_CONF missing"
Fi
Stop)
If [- n "$pid"]; then
Echo "Stopping proftpd..."
Kill-TERM $pid
Else
Echo "$0: proftpd not running"
Exit 1
Fi
Restart)
If [- n "$pid"]; then
Echo "Rehashing proftpd configuration"
Kill-HUP $pid
Else
Echo "$0: proftpd not running"
Exit 1
Fi
*)
Echo "usage: $0 {start | stop | restart}"
Exit 1
Esac
Exit 0
Save and exit.
Chmod + x proftpd
Modify this script to be executable.
Ln-s. / proftpd / etc/rc.d/init.d/proftpd
Make a soft link to the proftpd script file in the / etc/rc.d/init.d/ directory.
Cd / etc/rc.d/rc0.d
Ln-s.. / init.d/proftpd. / K15proftpd
Cd.. / rc1.d
Ln-s. / init.d/proftpd / K15proftpd
Cd.. / rc2.d
Ln-s. / init.d/proftpd / K15proftpd
Cd.. / rc3.d
Ln-s. / init.d/proftpd / S91proftpd # pay attention to the number after S, and if there is a mysql-related linked file in this directory, make sure that this number is larger than the number after S in that file! In this way, proftpd will not start until after the mysql database service is started, which is a good startup order, and of course there is nothing wrong with it.
Cd.. / rc4.d
Ln-s. / init.d/proftpd / S91proftpd
Cd.. / rc5.d
Ln-s. / init.d/proftpd / S91proftpd
Cd.. / rc6.d
Ln-s. / init.d/proftpd / K15proftpd
After the above settings, the proftpd service will start automatically every time the system is powered on and will stop automatically when the system is turned off.
Of course, it is not necessary to add a link to every rc directory, in fact, you only need to add it to the rc directory where the startup task is performed, such as rc3.d,rc4.d,rc5.d, in which rc4.d is not necessary, and rc3.d runs automatically at 03:00 when the system enters the runtime level. Anyway, there should be a link to proftpd here. Runlevel 3 is the level at which the system starts normally. Runlevel 4 is reserved for user-defined runlevels, so regardless of it, runlevel 5 starts X-Window, but in general, runlevel 3 is entered first, and then runlevel 5 is run, so there is no need to establish a link to proftpd in the rc5.d directory, while runlevel 6 is a system restart, needless to say.
A digression:
Want to switch system runlevel executable: init number,number is a number representing runlevel, for example:
Init 5 is equivalent to startx
Init 6 is equivalent to reboot
Other operation levels are not introduced here one by one, interested friends can consult the relevant information.
Thank you for reading this article carefully. I hope the article "sample Analysis of FTP Services Proftpd+mysql+quota" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.