CentOS下mysql+pureftpd的编译安装

操作系统:CentOS

软件:mysql-5.0.22.tar.gz pure-ftpd-1.0.22.tar.gz

一、编译安装mysql

1、下载并解压mysql和pure-ftpd软件包

[root@localhost chenye]# ls
mysql-5.0.22 mysql-5.0.22.tar.gz pure-ftpd-1.0.22 pure-ftpd-1.0.22.tar.gz

2、编译并安装mysql

[root@localhost chenye]# cd mysql-5.0.22

[root@localhost mysql-5.0.22]# ./configure --prefix=/usr/local/mysql --with-mysql-user=mysql --with-extra-charsets=all --with-unix-socket-path=/usr/local/mysql/var/mysql.sock ;make ;make install

--with-mysql-user指定mysql运行的用户
--with-extra-charsets支持扩展字符集
--with-unix-socket-path指定mysql运行后,套接字文件存放位置

3、配置mysql
[root@localhost mysql-5.0.22]# cd /usr/local/mysql/

建立配置文件
[root@localhost mysql]# cp share/mysql/my-large.cnf /etc/my.cnf

建立启动数据库所用的用户mysql
[root@localhost mysql]# adduser -d /usr/local/mysql/var mysql

在用户宿主目录中修改.bashrc文件,添加命令的搜索路径
[root@localhost mysql]# vi var/.bashrc
set PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/sbin/nologin

初始化数据库
[root@localhost mysql]# ./bin/mysql_install_db --user=mysql

[root@localhost mysql]# ls var
mysql mysql-bin.000001 mysql-bin.000002 mysql-bin.index test

4、启动数据库
[root@localhost mysql]# ./bin/mysqld_safe &

[root@localhost mysql]# ls var
ibdata1 localhost.localdomain.err mysql-bin.000001 mysql-bin.index
ib_logfile0 localhost.localdomain.pid mysql-bin.000002 mysql.sock
ib_logfile1 mysql mysql-bin.000003 test

开机自动运行
[root@localhost mysql]# cp share/mysql/mysql.server /etc/init.d/mysqld
[root@localhost mysql]# chkconfig --level 35 mysqld on

5、建立数据库管理员
[root@localhost mysql]# ./bin/mysqladmin -u root password xxxxxxxx

登陆测试
[root@localhost mysql]# ./bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 5.0.22-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

数据库常用管理命令,在/usr/local/mysql/bin目录下:
Mysql 显示和使用mysql数据库
Mysqladmini 创建和维护mysql数据库
Isamachk 修复、检查和优化.ism后缀的数据文件
Mysqldump 备份数据库
Myisamchk 修复.myi后缀的数据文件
Mysql.server start stop 启动和停止mysql

二、编译安装pure-ftpd

1、编译安装pureftp 源代码http://www.pureftpd.org/

[root@localhost pure-ftpd-1.0.22]# ./configure --prefix=/usr/local/pureftpd --with-cookie --with-throttling --with-ratios --with-quotas --with-sysquotas --with-largefile --with-welcomemsg --with-upload_script_ --with-virtualhosts --with-virtualroot --with-virtualchroot --with-diraliases --with-peruserlimits --with-language=simplified-chinese --with-mysql=/usr/local/mysql --with-paranoidmsg --with-altlog --with-puredb

如果出现类似configure: error: Your MySQL client libraries aren't properly installed 的错误,将mysql目录下的 include/mysql下的mysql.h文件以及lib/mysql下的全部文件,连接(直接复制过去或许也可)到 /usr/lib 目录下.

[root@localhost pure-ftpd-1.0.22]# make ; make install

2、建立配置文件

[root@localhost pure-ftpd-1.0.22]# mkdir -m 755 /usr/local/pureftpd/etc

[root@localhost pure-ftpd-1.0.22]# cp pureftpd-mysql.conf /usr/local/pureftpd/etc/
[root@localhost pure-ftpd-1.0.22]# cp configuration-file/pure-ftpd.conf /usr/local/pureftpd/etc/
[root@localhost pure-ftpd-1.0.22]# cp configuration-file/pure-config.pl /usr/local/pureftpd/bin/
[root@localhost pure-ftpd-1.0.22]# chmod u+x /usr/local/pureftpd/bin/pure-config.pl

三、建立mysql认证数据库表
[root@localhost pure-ftpd-1.0.22]# ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql

mysql> create database pureftpd;
mysql> grant all on pureftpd.* to pureftpd@localhost identified by 'pureftpd';
mysql> use pureftpd

mysql> CREATE TABLE users (
id int(32) unsigned NOT NULL auto_increment,
User varchar(16) NOT NULL default '*',
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 '-1',
QuotaSize smallint(5) NOT NULL default 0,
QuotaFiles int(11) NOT NULL default 0,
ULBandwidth smallint(5) NOT NULL default 0,
DLBandwidth smallint(5) NOT NULL default 0,
ULRatio smallint(6) NOT NULL default 0,
DLRatio smallint(6) NOT NULL default 0,
comment tinytext NOT NULL,
ipaccess varchar(15) NOT NULL default '*',
status enum('0','1') NOT NULL default '0',
create_date datetime NOT NULL default '0000-00-00 00:00:00',
modify_date datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (id,User),
UNIQUE KEY User (User)
) TYPE=MyISAM AUTO_INCREMENT=5;

建立用户
INSERT INTO users VALUES (1,'chenye', 'qqqqqq', '2000', '2000', '/var/pureftp', 0, 0, 0, 0, 0, 0, '*', '*', '1', '2009-7-11 09:20:33', '2009-7-11 09:20:33');

四、建立用于pureftpd认证用户的系统信息

[root@localhost /]# groupadd -g 2000 pureftp
[root@localhost /]# useradd -u 2000 -g pureftp -d /var/pureftp -s /sbin/nologin pureftp

五、修改pureftpd的配置文件

[root@localhost var]# vi /usr/local/pureftpd/etc/pure-ftpd.conf

MySQLConfigFile /usr/local/pureftpd/etc/pureftpd-mysql.conf
NoChmod yes
IPV4Only yes
DisplayDotFiles no 不显示隐藏文件

CreateHomeDir yes 自动建立家目录

[root@localhost var]# vi /usr/local/pureftpd/etc/pureftpd-mysql.conf

MYSQLSocket /usr/local/mysql/var/mysql.sock
MYSQLUser pureftpd
MYSQLPassword pureftpd
MySQLGetQTAFS SELECT QuotaFiles FROM users WHERE User="\L"
MySQLGetQTASZ SELECT QuotaSize FROM users WHERE User="\L"

六、运行pureftpd

启动pureftpd
[root@localhost ~]# /usr/local/pureftpd/bin/pure-config.pl /usr/local/pureftpd/etc/pure-ftpd.conf

启动自动运行
[root@localhost ~]# vi /etc/init.d/pureftpd

#!/bin/bash
#
# Startup script for the pure-ftpd FTP Server $Revision: 1.3 $
#
# chkconfig: 2345 85 15
# description: Pure-FTPd is an FTP server daemon based upon Troll-FTPd
# processname: pure-ftpd
# pidfile: /var/run/pure-ftpd.pid
# config: /etc/pure-ftpd.conf

# Source function library.
. /etc/rc.d/init.d/functions

RETVAL=0

# Path to the pure-ftp binaries.
prog=pure-config.pl
fullpath=/usr/local/pureftpd/bin/$prog
pureftpwho=/usr/local/pureftpd/sbin/pure-ftpwho

start() {
echo -n $"Starting $prog: "
$fullpath /usr/local/pureftpd/etc/pure-ftpd.conf --daemonize
RETVAL=$?
[ $RETVAL = 0 ] && touch /var/lock/subsys/$prog
echo
}

stop() {
echo -n $"Stopping $prog: "
kill $(cat /var/run/pure-ftpd.pid)
RETVAL=$?
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/$prog
echo
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)

stop
start
;;
condrestart)
if [ -f /var/lock/subsys/$prog ] ; then
stop
# avoid race
sleep 3
start
fi
;;
status)
status $prog
RETVAL=$?
if [ -f $pureftpwho ] && [ $RETVAL -eq 0 ] ; then
$pureftpwho
fi
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|status}"
RETVAL=1
esac
exit $RETVAL

**********不能把用户的dir放在其他用户的dir下面,否则会出现不能登录的问题。************

QUICK TAGS

centosmysqlpureftpd

Leave a Comment

Other

Copyright © 2007-2010 PageDNS, Some Rights Reserved. Theme by M4 | Powered by Typecho))) | Hosted by 37hi.com.