pureftpd+mysql
验证
的安装配置文档
一.
mysql
编译安装:
1,准备工作
a,下载安装程序mysql-5.1.41.tar.gz
b,为mysql建立用户和组
groupadd -g 2001 mysql
useradd -M -s /sbin/nologin -u 2001 -g 2001 mysql
2,编译安装mysql
[root@localhost software]# tar -zxf mysql-5.1.41.tar.gz
[root@localhost software]# cd mysql-5.1.41
[root@localhost mysql-5.1.41]#./congfigure \
--prefix=/home/mysql/ \ / *指定安装目录 */
--without-debug \ /*去除debug模式*/
--with-extra-charsets=complex \ /*字符集的支持*/
--enable-assembler \ /*支持汇编*/
--enable-thread-safe-client \ 以线程方式编译客户端
--with-client-ldflags=-all-static \ 以纯静态方式编译客户端
--with-mysqld-ldflags=-all-static 以纯静态方式编译服务端
[root@localhost mysql-5.1.41]#make
[root@localhost mysql-5.1.41]#make install
3,复制mysql默认全局启动参数配置文件到/etc目录
mysql-5.1.41]#cp support-files/my-medium.cnf /etc/my.cnf
4,初始化数据库
mysql-5.1.41]# scripts/mysql_install_db --user=mysql
5,修改目录权限(数据库所属的用户主mysql)
/*设置/usr/local/mysql/var的属主和属组为mysql*/
chown -R mysql:mysql /usr/local/mysql/var/
/*设置/usr/local/mysql/属组为mysql*/
chgrp -R mysql /usr/local/mysql/
6,启动测试
[root@localhost mysql]# bin/mysqld_safe --user=mysql &
7,修改数据库用户root的用户名密码,连接测试
[root@localhost mysql]# bin/mysqladmin -u root password 123456
[root@localhost mysql]# bin/mysql -u root -p
mysql> show databases;
证明安装成功。
8,把mysql加入到系统服务中
cp /usr/local/mysql/share/mysql/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
完了之后就可以使用service mysqld start|stop|status|restart 或/etc/rc.d/init.d/mysqldstart|stop|status|restart进行管理mysql了
二.
prueptpd
的安装和配置
1, tar -zxf pure-ftpd-1.0.27.tar.gz
cd pure-ftpd-1.0.27
2,编译安装pureftpd
[root@localhost pure-ftpd-1.0.27]# ./configure \
> --prefix=/usr/local/pureftpd \
> --with-everything \
> --with-rfc2640 \
> --with-mysql=/usr/local/mysql/
注意:如果是用Tar包安装的mysql,可能在编译时会遇到 configure: error: Your MySQL client libraries aren't properly installed 问题,解决的办法是把/usr/local/mysql/lib/mysql/下的文件全部copy到/usr/lib中,重新./configure就ok!
3,make
4,make install
5,
/*创建/usr/local/pureftpd/etc目录,并拷贝pureftpd的置文件到/usr/local/pureftpd/etc目录下*/
[root@localhost pure-ftpd-1.0.27]# mkdir /usr/local/pureftpd/etc
cp configuration-file/pure-ftpd.conf /usr/local/pureftpd/etc/
/*拷贝pureftpd的启动程序到/usr/local/pureftpd/sbin/,加可执行权限*/
cp configuration-file/pure-config.pl /usr/local/pureftpd/sbin/
chmod u+x /usr/local/pureftpd/sbin/pure-config.pl
/*拷贝和mysql有关的配置文件到/usr/local/pureftpd/etc/
cp pureftpd* /usr/local/pureftpd/etc/
6,pureftp的启动和停止
/usr/local/pureftpd/sbin/pure-config.pl \
/usr/local/pureftpd/etc/pure-ftpd.conf
killall pure-ftpd
三.
Pureftp
和
mysql
的结合
1, 创建所需数据库、表和用户
bin/mysql -u root –p
> CREATE DATABASE pureftpd;
> grant all on pureftpd.* to pureftp@localhost identified by "123456";
>use pureftpd
>CREATE TABLE users (
User varchar(16) NOT NULL default '',
status enum('0','1') NOT NULL default '0',
Password varchar(64) NOT NULL default '',
Uid varchar(11) NOT NULL default '-1',
Gid varchar(11) NOT NULL default '-1',
Dir varchar(128) NOT NULL default '',
ULBandwidth smallint(5) NOT NULL default '0',
DLBandwidth smallint(5) NOT NULL default '0',
comment tinytext NOT NULL,
ipaccess varchar(15) NOT NULL default '*',
QuotaSize smallint(5) NOT NULL default '0',
QuotaFiles int(11) NOT NULL default 0,
PRIMARY KEY (User),
UNIQUE KEY User (User)
) TYPE=MyISAM;
查看所建的users表:
mysql> desc users;
表示表已经建立成功;
2, 向表里插入数据:
insert into users values('test1','1','123456',
'3001','3001','/var/ftp/test',0,0,'','*',0,0);
注:如果password字段使用password()函数加密,将不能连接ftp服务器。
3,修改/usr/local/pureftpd/etc/pureftpd-mysql.conf 文件.
MYSQLServer
localhost
MYSQLPort
3306
MYSQLSocket
/tmp/mysql.sock
MYSQLUser
pureftp
mYSQLPassword
******** //这里填你自己的密码
MYSQLDatabase
pureftpd
MYSQLCrypt
crypt //密码加密方式,
查找以下字符,并把前面的#号去掉
MySQLGetQTAFS
MySQLGetQTASZ
MySQLGetBandwidthUL
MySQLGetBandwidthDL
保存退出
9,修改/usr/local/pureftpd/etc/pure-ftpd.conf文件
就该下面一条:
MySQLConfigFile
/usr/local/pureftpd/etc/pureftpd-mysql.conf
10,建立主目录/var/ftp/test,设置读写权限。
********************************
*
决远程连接
mysql
时
1130
错误:
*
********************************
例如,你想
myuser使用mypassword从任何主机连接到mysql服务器的话。
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
如果你想允许用户
myuser从ip为192.168.1.3的主机连接到mysql服务器,并使用mypassword作为密码
GRANT ALL PRIVILEGES ON *.* TO
'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;