已经安装好MySQL数据库,准备提供ftp服务:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
[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/service/pure-ftpd-1.0.36 --with-mysql=/usr/local/mysql/ [root@hz pure-ftpd-1.0.36]# make && make install [root@hz pure-ftpd-1.0.36]# ln -s /byrd/service/pure-ftpd-1.0.36 /usr/local/ftpd [root@hz pure-ftpd-1.0.36]# mkdir /usr/local/ftpd/etc [root@hz pure-ftpd-1.0.36]# cp pureftpd-mysql.conf /usr/local/ftpd/etc [root@hz pure-ftpd-1.0.36]# cp configuration-file/pure-ftpd.conf /usr/local/ftpd/etc [root@hz pure-ftpd-1.0.36]# cp configuration-file/pure-config.pl /usr/local/ftpd/sbin [root@hz pure-ftpd-1.0.36]# chmod +x /usr/local/ftpd/sbin/pure-config.pl [root@hz pure-ftpd-1.0.36]# cp contrib/redhat.init /usr/local/ftpd/sbin/service [root@hz pure-ftpd-1.0.36]# chmod +x /usr/local/ftpd/sbin/service [root@hz pure-ftpd-1.0.36]# cd /usr/local/ftpd [root@hz ftpd]# sed -i 's#fullpath=/usr/local/sbin/$prog#fullpath=/usr/local/ftpd/sbin/$prog#g' sbin/service [root@hz ftpd]# sed -i 's#pureftpwho=/usr/local/sbin/pure-ftpwho#pureftpwho=/usr/local/ftpd/sbin/pure-ftpwho#g' sbin/service [root@hz ftpd]# sed -i 's#$fullpath /etc/pure-ftpd.conf --daemonize#$fullpath /usr/local/ftpd/etc/pure-ftpd.conf --daemonize#g' sbin/service [root@hz ftpd]# sed -i 's#NoAnonymous no#NoAnonymous yes#g' etc/pure-ftpd.conf [root@hz ftpd]# sed -i 's#\# MySQLConfigFile /etc/pureftpd-mysql.conf#MySQLConfigFile /usr/local/ftpd/etc/pureftpd-mysql.conf#g' etc/pure-ftpd.conf #################################################################################### 修改sbin/pure-config.pl 在/usr/sbin/pure-ftpd后面添加一行/usr/local/ftpd/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) mysql> update users set UID=678; Query OK, 1 row affected (0.01 sec) mysql> update users set GID=876; [root@hz ftpd]# sed -i 's#MYSQLUser root#MYSQLUser ftp#g' etc/pureftpd-mysql.conf [root@hz ftpd]# vim etc/pureftpd-mysql.conf [root@hz ftpd]# sed -i 's#MYSQLPassword rootpw#MYSQLPassword admin#g' etc/pureftpd-mysql.conf [root@hz ftpd]# sed -i 's#MYSQLDatabase pureftpd#MYSQLDatabase ftp#g' etc/pureftpd-mysql.conf [root@hz ftpd]# iptables -I INPUT -p tcp --dport 20 -j ACCEPT [root@hz ftpd]# iptables -I INPUT -p tcp --dport 21 -j ACCEPT [root@hz ftpd]# iptables -I INPUT -p tcp --dport 10000:50000 -j ACCEPT [root@hz ftpd]# iptables-save [root@hz ftpd]# /byrd/service/ftpd/sbin/service start |
================================================================SourceByrd's Weblog-https://note.t4x.org/system/centos-pureftp-server/
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
[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-1.0.36 --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-1.0.36/etc [root@hz pure-ftpd-1.0.36]# cp pureftpd-mysql.conf /byrd/server/pure-ftpd-1.0.36/etc [root@hz pure-ftpd-1.0.36]# cp configuration-file/pure-config.pl /byrd/server/pure-ftpd-1.0.36/sbin [root@hz pure-ftpd-1.0.36]# chmod +x /byrd/server/pure-ftpd-1.0.36/sbin/pure-config.pl [root@hz pure-ftpd-1.0.36]# cp configuration-file/pure-ftpd.conf /byrd/server/pure-ftpd-1.0.36/etc/ [root@hz pure-ftpd-1.0.36]# cp contrib/redhat.init /byrd/server/pure-ftpd-1.0.36/sbin/service [root@hz pure-ftpd-1.0.36]# chmod +x /byrd/server/pure-ftpd-1.0.36/sbin/service [root@hz pure-ftpd-1.0.36]# cd /byrd/server/pure-ftpd-1.0.36/ [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 |
申明:本文转载于MOYO的博客,版权归MOYO所有!
MOYO:http://moyo.uuland.org/lnmp/SourceByrd's Weblog-https://note.t4x.org/system/centos-pureftp-server/
SourceByrd's Weblog-https://note.t4x.org/system/centos-pureftp-server/
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!