搭建lamp环境
[root@111 ~]# yum install -y httpd php php-mysql mysql-server mysql-devel mysql
[root@111 ~]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 0.0.0.111 for ServerName
[ OK ]
[root@111 ~]# vim /etc/resolv.conf
[root@111 ~]# vim /etc/sysconfig/network
[root@111 ~]# tar -zxvf pure-ftpd-1.0.36.tar.gz -C /usr/local/src/
[root@111 ~]# cd /usr/local/src/pure-ftpd-1.0.36/
[root@111 pure-ftpd-1.0.36]# ./configure \
> --prefix=/usr/local/pureftpd \
> --with-mysql \
> --with-shadow \
> --with-pam \
> --with-welcomemsg \
> --with-uploadscript \
> --with-cookie \
> --with-virtualchroot \
> --with-virtualhosts \
> --with-diraliases \
> --with-quotas \
> --with-puredb \
> --with-sysquotas \
> --with-ratios \
> --with-ftpwho \
> --with-throtting \
> --with-language=simplified-chinese
[root@111 pure-ftpd-1.0.36]# make && make install
yum install httpd php php-mysql mysql mysql-server mysql-server
[root@donghao244 pure-ftpd-1.0.36]# cd /usr/local/pureftpd/
[root@donghao244 pureftpd]# ll
total 12
drwxr-xr-x 2 root root 4096 Aug 4 17:46 bin
drwxr-xr-x 2 root root 4096 Aug 4 17:46 sbin
drwxr-xr-x 3 root root 4096 Aug 4 17:46 share
[root@111 pureftpd]# pwd
/usr/local/pureftpd
[root@111 pureftpd]# mkdir etc
[root@111 pure-ftpd-1.0.36]# cd configuration-file/
[root@111 configuration-file]# cd /usr/src/pure-ftpd-1.0.36/
//服务的控制脚本
[root@111 configuration-file]# cp pure-ftpd.conf /usr/local/pureftpd/etc/
[root@111 configuration-file]# chmod 755 pure-config.pl
服务启动时调用的控制脚本
[root@111 configuration-file]# cp pure-config.pl /usr/local/pureftpd/sbin/
[root@111 contrib]# pwd
/usr/src/pure-ftpd-1.0.36/contrib
[root@111 contrib]# cp redhat.init /etc/init.d/pureftpd
[root@111 contrib]# chmod 755 /etc/init.d/pureftpd
[root@111 contrib]# ll /etc/init.d/pureftpd
-rwxr-xr-x 1 root root 1178 Aug 7 19:15 /etc/init.d/pureftpd
修改控制脚本
18 fullpath=/usr/local/pureftpd/sbin/$prog
19 pureftpwho=/usr/local/pureftpd/sbin/pure-ftpwho
24 $fullpath /usr/local/pureftpd/etc/pure-ftpd.conf --daemonize
[root@111 contrib]# service pureftpd restart
Stopping pure-config.pl: cat: /var/run/pure-ftpd.pid: No such file or directory
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
Starting pure-config.pl: Running: /usr/local/pureftpd/sbin/pure-ftpd --daemonize -A -c50 -B -C8 -D -fftp -H -I15 -L10000:8 -m4 -s -U133:022 -u100 -k99 -Z
//pureftp 已经可以正常启动
[root@111 contrib]# chkconfig --add pureftpd
[root@111 contrib]# chkconfig --list |grep pureftpd
Pureftpd 0: off 1:off 2:on 3:on 4:on 5 :on 6 :off
[root@111 contrib]# mkdir /ftproot
[root@111 contrib]# useradd vtftp -d /ftproot -s /sbin/nologin -M
[root@111 contrib]# chown vtftp.vtftp /ftproot/
[root@111 contrib]# ll -d /ftproot/
drwxrwxrwx 2 vtftp vtftp 4096 Aug 7 19:26 /ftproot/
修改主配置文档
[root@111 contrib]# vim /usr/local/pureftpd/etc/pure-ftpd.conf
77 NoAnonymous yes //不允许匿名
336 CreateHomeDir yes //生成家目录
调度数据库中的数据进行验证
[root@111 contrib]# vim /usr/local/pureftpd/etc/pure-ftpd.conf
116 MySQLConfigFile /usr/local/pureftpd/etc/pureftpd-mysql.conf
[root@111 ~]# cp pureftp/pureftpd-mysql.conf /usr/local/pureftpd/etc/
27 MYSQLUser ftp //访问数据库的身份
32 MYSQLPassword tmppasswd
37 MYSQLDatabase ftpusers
45 MYSQLCrypt md5
//后台管理的账号
50 INSERT INTO admin VALUES ('admin',MD5('123'));
//导入数据
Mysql -u root -p < pureftp.sql
[root@111 pureftp]# mysql -u root -p <pureftp.sql
Enter password:123
[root@111 pureftp]# //成功导入数据
mysql> use ftpusers;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+--------------------+
| Tables_in_ftpusers |
+--------------------+
| admin |
| users |
+--------------------+
2 rows in set (0.00 sec)
mysql> select * from admin;
+----------+----------------------------------+
| Username | Password |
+----------+----------------------------------+
| admin | 202cb962ac59075b964b07152d234b70 |
+----------+----------------------------------+
1 row in set (0.00 sec)
[root@111 pureftp]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databasess;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'databasess' at line 1
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| extmail |
| ftpusers |
| mysql |
| test |
+--------------------+
5 rows in set (0.11 sec)
管理页面
[root@111 pureftp]# tar -zxvf PureAdmin-0.3.tar.gz -C /var/www/html/
[root@111 pureftp]# cd /var/www/html/
[root@111 html]# mv PureAdmin-0.3 pureadmin
[root@111 html]# cd pureadmin/
[root@111 pureadmin]# vim config.php
3 $cfg['dbname']='ftpusers'; //mysql db name
4 $cfg['dbuser']='ftp'; //mysql user
5 $cfg['dbpasswd']='temppasswd'; //mysql password
10 $cfg['passwdtype']='MD5';
14 $cfg['dir']='/ftproot/'; //dir
[root@111 configuration-file]# mkdir /ftproot
[root@111 configuration-file]# chmod -R 777 /ftproot
[root@111 configuration-file]# useradd vtftp -d /ftproot -s /sbin/nologin -M
[root@111 configuration-file]# vim /usr/local/pureftpd/etc/pure-ftpd.conf
336 CreateHomeDir yes
116 MySQLConfigFile /etc/pureftpd-mysql.conf
116 MySQLConfigFile /usr/local/pureftpd/etc/pureftpd-mysql.conf
[root@111 configuration-file]# service pureftpd restart
Stopping pure-config.pl:
Starting pure-config.pl: Running: /usr/local/pureftpd/sbin/pure-ftpd --daemonize -A -c50 -B -C8 -D -fftp -H -I15 -L10000:8 -m4 -s -U133:022 -u100 -j -k99 -Z
[root@111 configuration-file]# cp /root/pureftp/pureftpd-mysql.conf /usr/local/pureftpd/etc/
[root@111 configuration-file]# vim /usr/local/pureftpd/etc/pureftpd-mysql.conf
32 MYSQLPassword tmppasswd
27 MYSQLUser ftp
45 MYSQLCrypt md5
[root@111 configuration-file]# cd /root/pureftp/
[root@111 pureftp]# vim pureftp.sql
50 INSERT INTO admin VALUES ('admin',MD5('123'));
[root@111 pureftp]# mysql -u root -p <pureftp.sql
Enter password:
[root@111 pureftp]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 22
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| extmail |
| ftpusers |
| mysql |
| test |
+--------------------+
5 rows in set (0.00 sec)
mysql> select * from admin;
+----------+----------------------------------+
| Username | Password |
+----------+----------------------------------+
| admin | 202cb962ac59075b964b07152d234b70 |
+----------+----------------------------------+
1 row in set (0.00 sec)
mysql> \q
[root@111 pureftp]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 24
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> grant all privileges on ftpusers.* to ftp@localhost identified by 'tmppasswd';
Query OK, 0 rows affected (0.03 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
[root@111 pureftp]# tar -zxvf /root/pureftp/PureAdmin-0.3.tar.gz -C /var/www/html/
[root@111 pureftp]# cd /var/www/html/
[root@111 html]# mv PureAdmin-0.3/ pureadmin
[root@111 html]# cd pureadmin/
[root@111 pureadmin]# vim config.php
3 $cfg['dbname']='ftpusers'; //mysql db name
4 $cfg['dbuser']='ftp'; //mysql user
5 $cfg['dbpasswd']='tmppasswd'; //mysql password
9 //ftp passwd type : TEXT/CRYPT/MD5
10 $cfg['passwdtype']='MD5';
14 $cfg['dir']='/ftproot/'; //dir
[root@111 pureadmin]# vim config.php
1 <?php
2 $cfg['dbhost']='localhost'; //mysql host
3 $cfg['dbname']='ftpusers'; //mysql db name
4 $cfg['dbuser']='ftp'; //mysql user
5 $cfg['dbpasswd']='tmppasswd'; //mysql password
7 //ftp config
8 $cfg['page']=15;
9 //ftp passwd type : TEXT/CRYPT/MD5
10 $cfg['passwdtype']='MD5';
11 //ftp default
12 $cfg['uid']=1000; //uid
13 $cfg['gid']=1000; //gid
14 $cfg['dir']='/ftproot/'; //dir
15 $cfg['qf']=0; //quotafiles
16 $cfg['qs']=100; //quotasize
17 $cfg['ul']=100; //ULBandwidth
18 $cfg['dl']=200; //DLBandwidth
19 $cfg['ur']=0; //ULRatio
20 $cfg['dr']=0; //DLRatio
21 $cfg['status']=1; //status
22 $cfg['ip']= '*'; //ipaddress
23 ?>
重新启动pureftp服务
使用web方式管理ftp服务器
此时可以使用pureftpadm通过web方式管理ftp服务