已经安装好mysql数据库,准备提供ftp服务:
[root@hz tools]# wget http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.36.tar.gz
[root@hz tools]# tar zxf pure-ftpd-1.0.36.tar.gz
[root@hz tools]# cd pure-ftpd-1.0.36
[root@hz pure-ftpd-1.0.36]# ./configure --prefix=/byrd/server/pure-ftpd-thr-1.0.32.1 --with-mysql=/usr/local/mysql/
[root@hz pure-ftpd-1.0.36]# make && make install
[root@hz pure-ftpd-1.0.36]# mkdir /byrd/server/pure-ftpd-thr-1.0.32.1/etc
[root@hz pure-ftpd-1.0.36]# cp pureftpd-mysql.conf /byrd/server/pure-ftpd-thr-1.0.32.1/etc
[root@hz pure-ftpd-1.0.36]# cp configuration-file/pure-config.pl /byrd/server/pure-ftpd-thr-1.0.32.1/sbin
[root@hz pure-ftpd-1.0.36]# chmod +x /byrd/server/pure-ftpd-thr-1.0.32.1/sbin/pure-config.pl
[root@hz pure-ftpd-1.0.36]# cp configuration-file/pure-ftpd.conf /byrd/server/pure-ftpd-thr-1.0.32.1/etc/
[root@hz pure-ftpd-1.0.36]# cp contrib/redhat.init /byrd/server/pure-ftpd-thr-1.0.32.1/sbin/service
[root@hz pure-ftpd-1.0.36]# chmod +x /byrd/server/pure-ftpd-thr-1.0.32.1/sbin/service
[root@hz pure-ftpd-1.0.36]# cd /byrd/server/pure-ftpd-thr-1.0.32.1/
[root@hz pure-ftpd-thr-1.0.32.1]# cp sbin/service sbin/service.backup
[root@hz pure-ftpd-thr-1.0.32.1]# cp etc/pure-ftpd.conf etc/pure-ftpd.conf.backup
[root@hz pure-ftpd-thr-1.0.32.1]# cp etc/pureftpd-mysql.conf etc/pureftpd-mysql.conf.backup
[root@hz pure-ftpd-thr-1.0.32.1]# cp sbin/pure-config.pl sbin/pure-config.pl.backup
[root@hz pure-ftpd-thr-1.0.32.1]# sed -i 's#fullpath=/usr/local/sbin/$prog#fullpath=/byrd/server/pure-ftpd-thr-1.0.32.1/sbin/$prog#g' sbin/service
[root@hz pure-ftpd-thr-1.0.32.1]# sed -i 's#pureftpwho=/usr/local/sbin/pure-ftpwho#pureftpwho=/byrd/server/pure-ftpd-thr-1.0.32.1/sbin/pure-ftpwho#g' sbin/service
[root@hz pure-ftpd-thr-1.0.32.1]# sed -i 's#$fullpath /etc/pure-ftpd.conf --daemonize#$fullpath /byrd/server/pure-ftpd-thr-1.0.32.1/etc/pure-ftpd.conf --daemonize#g' sbin/service
[root@hz pure-ftpd-thr-1.0.32.1]# sed -i 's#NoAnonymous no#NoAnonymous yes#g' etc/pure-ftpd.conf
[root@hz pure-ftpd-thr-1.0.32.1]# sed -i 's#\# MySQLConfigFile /etc/pureftpd-mysql.conf#MySQLConfigFile etc/pureftpd-mysql.conf#g' etc/pure-ftpd.conf
####################################################################################
修改sbin/pure-config.pl
在/usr/sbin/pure-ftpd后面添加一行/byrd/server/pure-ftpd-thr-1.0.32.1/sbin/pure-ftpd
####################################################################################
mysql> create database ftp default character set utf8 collate utf8_general_ci;
mysql> create user 'ftp'@'localhost' identified by 'admin';
mysql> grant all on ftp.* to 'ftp'@'localhost' identified by 'admin';
mysql> flush privileges;
[root@hz pure-ftpd-thr-1.0.32.1]# cat mysql.sql
CREATE TABLE IF NOT EXISTS `users` (
`User` varchar(16) NOT NULL,
`Password` varchar(64) NOT NULL,
`Uid` int(11) NOT NULL DEFAULT '-1',
`Gid` int(11) NOT NULL DEFAULT '-1',
`Dir` varchar(128) NOT NULL,
PRIMARY KEY (`User`)
) ENGINE=Aria DEFAULT CHARSET=utf8 COMMENT='FTP Users';
[root@hz pure-ftpd-thr-1.0.32.1]# mysql -uftp -p
mysql> use ftp;
Database changed
mysql> SELECT database();
+------------+
| database() |
+------------+
| ftp |
+------------+
1 row in set (0.00 sec)
[root@hz pure-ftpd-thr-1.0.32.1]# /usr/local/mysql/bin/mysql -uftp -p'admin' ftp < ./mysql.sql
mysql> show tables;
+---------------+
| Tables_in_ftp |
+---------------+
| users |
+---------------+
1 row in set (0.00 sec)
mysql> desc users;
+----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+-------+
| User | varchar(16) | NO | PRI | NULL | |
| Password | varchar(64) | NO | | NULL | |
| Uid | int(11) | NO | | -1 | |
| Gid | int(11) | NO | | -1 | |
| Dir | varchar(128) | NO | | NULL | |
+----------+--------------+------+-----+---------+-------+
5 rows in set (0.00 sec)
mysql> INSERT INTO `users` (`User`, `Password`, `Uid`, `Gid`, `Dir`) VALUES
-> ('byrd', 'byrd', 777, 777, '/home/web');
mysql> select * from users;
+--------+----------+-----+-----+-----------+
| User | Password | Uid | Gid | Dir |
+--------+----------+-----+-----+-----------+
| byrd | byrd | 777 | 777 | /home/web |
+--------+----------+-----+-----+-----------+
1 row in set (0.00 sec)
[root@hz pure-ftpd-thr-1.0.32.1]# sed -i 's#MYSQLUser root#MYSQLUser ftp#g' etc/pureftpd-mysql.conf
[root@hz pure-ftpd-thr-1.0.32.1]# sed -i 's#MYSQLPassword rootpw#MYSQLPassword admin#g' etc/pureftpd-mysql.conf
[root@hz pure-ftpd-thr-1.0.32.1]# sed -i 's#MYSQLDatabase pureftpd#MYSQLDatabase ftp#g' etc/pureftpd-mysql.conf
[root@hz pure-ftpd-thr-1.0.32.1]# iptables -I INPUT -p tcp --dport 20 -j ACCEPT
[root@hz pure-ftpd-thr-1.0.32.1]# iptables -I INPUT -p tcp --dport 21 -j ACCEPT
[root@hz pure-ftpd-thr-1.0.32.1]# iptables -I INPUT -p tcp --dport 10000:50000 -j ACCEPT
[root@hz pure-ftpd-thr-1.0.32.1]# iptables-save
[root@hz pure-ftpd-thr-1.0.32.1]# /byrd/server/pure-ftpd-thr-1.0.32.1/sbin/service start
[root@hz pure-ftpd-thr-1.0.32.1]# /byrd/server/pure-ftpd-thr-1.0.32.1/sbin/service stop