ChinaUnix首页 > 精华文章 > FTP服务器 > 正文

[精华] [原创]Solaris8下 proftpd-1.2.10 + mysql-5.0.18 认证安装方法


http://www.chinaunix.net 作者:ptsmy  发表于:2006-07-21 16:51:07
发表评论】 【查看原文】 【FTP服务器讨论区】【关闭

这几天和朋友花了三天的时间终于把proftpd+mysql在solaris8下安装好了,因为是新手所以费了很大的力气,今天把安装过程写下来,与大家交流。

安装前的准备:

1、配置gcc环境(在这就不多说了,如果有问题请查找资料,网上有许多)。配置好的标准是可以正确的安装其它的源码包。因为我的mysql和proftpd都是源码安装,所以gcc是必须的。
2、安装mysql,(CU上有相关的教程,请查阅),我的是源码安装,版本为5.0.18 , 安装路径为/usr/local/mysql



开始安装:


bash-2.03# cd /home/software
bash-2.03# wget ftp://ftp.proftpd.org/distrib/source/proftpd-1.2.10.tar.gz
bash-2.03# gunzip < proftpd-1.2.10.tar.gz | tar xvf -
bash-2.03# cd proftpd.1.2.10
bash-2.03#./configure --with-modules=mod_sql:mod_sql_mysql:mod_quotatab:mod_quotatab_sql \
> --with-includes=/usr/local/mysql/include/mysql \
> --with-libraries=/usr/local/mysql/lib/mysql \
> --prefix=/usr/local/proftpd



说明:因为我的mysql是用的源码安装,安装路径为/usr/local/mysql,所以他的include库文件在/usr/local/mysql/include/mysql目录下面,他的lib库文件在/usr/local/mysql/lib/mysql目录下面,如mysql用的二进制包安装,请参考相关帮助文件将--with-includes和--with-libraries设置为你自己的路径。


bash-2.03# make
bash-2.03# make install


现在开始添加系统用户


bash-2.03# groupadd -g 5500 ftpgroup
bash-2.03# useradd -u 5500 -s /bin/false -d /bin/null -c "proftpd user" -g ftpgroup ftpuser


proftpd安装结束,现在开始配置mysql数据库

登陆mysql
bash-2.03# mysql -uroot -p

在mysql中建立数据库proftpd
mysql> create database proftpd;

添加proftpd数据库的用户权限,proftpd数据库的用户名为:proftpd,密码为:123456,它只有查询、更新、插入的权限。
mysql> grant select,update,insert on proftpd.* to proftpd@localhost identified by '123456';

在proftpd数据库中建立数据表,proftpd使用mysql验证用户时一共使用4个表,分别是ftpuser,ftpgroup,ftpquotalimits,ftpquotatallies。下面是建立这4个表的sql语句。


CREATE TABLE ftpgroup (
groupname varchar(16) NOT NULL default '',
gid smallint(6) NOT NULL default '5500',
members varchar(16) NOT NULL default '',
KEY groupname (groupname)
) TYPE=MyISAM COMMENT='ProFTP group table';



# --------------------------------------------------------

#
# Table structure for table `ftpquotalimits`
#

CREATE TABLE ftpquotalimits (
name varchar(30) default NULL,
quota_type enum('user','group','class','all') NOT NULL default 'user',
per_session enum('false','true') NOT NULL default 'false',
limit_type enum('soft','hard') NOT NULL default 'soft',
bytes_in_avail int(10) unsigned NOT NULL default '0',
bytes_out_avail int(10) unsigned NOT NULL default '0',
bytes_xfer_avail int(10) unsigned NOT NULL default '0',
files_in_avail int(10) unsigned NOT NULL default '0',
files_out_avail int(10) unsigned NOT NULL default '0',
files_xfer_avail int(10) unsigned NOT NULL default '0'
) TYPE=MyISAM;

# --------------------------------------------------------

#
# Table structure for table `ftpquotatallies`
#

CREATE TABLE ftpquotatallies (
name varchar(30) NOT NULL default '',
quota_type enum('user','group','class','all') NOT NULL default 'user',
bytes_in_used int(10) unsigned NOT NULL default '0',
bytes_out_used int(10) unsigned NOT NULL default '0',
bytes_xfer_used int(10) unsigned NOT NULL default '0',
files_in_used int(10) unsigned NOT NULL default '0',
files_out_used int(10) unsigned NOT NULL default '0',
files_xfer_used int(10) unsigned NOT NULL default '0'
) TYPE=MyISAM;




#
# Table structure for table `ftpuser`
#

CREATE TABLE ftpuser (
id int(10) unsigned NOT NULL auto_increment,
userid varchar(32) NOT NULL default '',
passwd varchar(32) NOT NULL default '',
uid smallint(6) NOT NULL default '5500',
gid smallint(6) NOT NULL default '5500',
homedir varchar(255) NOT NULL default '',
shell varchar(16) NOT NULL default '/sbin/nologin',
count int(11) NOT NULL default '0',
accessed datetime NOT NULL default '0000-00-00 00:00:00',
modified datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (id),
UNIQUE KEY userid (userid)
) TYPE=MyISAM COMMENT='ProFTP user table';



# 数据表建立成功后加入测试帐号test,安装成功后你可以用这个帐号测试

 INSERT INTO `ftpgroup` VALUES ('ftpgroup', 5500, 'ftpuser');
 INSERT INTO `ftpuser` VALUES (1, 'test', 'test', 5500, 5500, '/home/ftp/test', '/sbin/nologin',0,'','');
 INSERT INTO `ftpquotalimits` VALUES ('test','user','false','hard','15728640','0','0','0','0','0');


这时数据库中已经有一个用户,用户名为:test,密码为:test,用户根目录为:/home/ftp/test,他的空间大小限制为15M,超过 15M后用户将不能上传文件。


下面是/usr/local/proftpd/etc/proftpd.conf文件的内容。


ServerName                      "SPST.CN FTP Server"
ServerType                      Standalone
ServerAdmin                     ptsmy@163.com

# Hide as much as possible to outside users
ServerIdent                     on "Welcome to SPST.CN FTP server. Please login..."
DeferWelcome on

DefaultServer                   on

# Allow FTP resuming.
# Remember to set to off if you have an incoming ftp for upload.
AllowStoreRestart               on

# Port 21 is the standard FTP port.
Port                            21

# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
Umask                           022

# To prevent DoS attacks, set the maximum number of child processes
# to 30.  If you need to allow more than 30 concurrent connections
# at once, simply increase this value.  Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd).
MaxInstances                    30

# Set the user and group under which the server will run.
User                            nobody
Group                           nogroup

# To cause every FTP user to be "jailed" (chrooted) into their home
# directory, uncomment this line.
DefaultRoot ~

# Normally, we want files to be overwriteable.

  AllowOverwrite                on


# The passwords in MySQL are encrypted using CRYPT
SQLAuthTypes            Plaintext Crypt
SQLAuthenticate         users* groups*

# used to connect to the database
# databasename@host database_user user_password
SQLConnectInfo  proftpd@localhost proftpd 123456

# Here we tell ProFTPd the names of the database columns in the "usertable"
# we want it to interact with. Match the names with those in the db
SQLUserInfo     ftpuser userid passwd uid gid homedir shell

# Here we tell ProFTPd the names of the database columns in the "grouptable"
# we want it to interact with. Again the names match with those in the db
SQLGroupInfo    ftpgroup groupname gid members

# set min UID and GID - otherwise these are 999 each
SQLMinID        500

# create a user's home directory on demand if it doesn't exist
SQLHomedirOnDemand on

# Update count every time user logs in
SQLLog PASS updatecount
SQLNamedQuery updatecount UPDATE "count=count+1, accessed=now() WHERE userid='%u'" ftpuser

# Update modified everytime user uploads or deletes a file
SQLLog  STOR,DELE modified
SQLNamedQuery modified UPDATE "modified=now() WHERE userid='%u'" ftpuser

# User quotas
# ===========
QuotaEngine on
QuotaDirectoryTally on
QuotaDisplayUnits Mb
QuotaShowQuotas on

SQLNamedQuery get-quota-limit SELECT "name, quota_type, per_session, limit_type, bytes_in_avail, bytes_out_avail, bytes_xfer_avail, files_in_avail, files_out_avail, files_xfer_avail FROM ftpquotalimits WHERE name = '%{0}' AND quota_type = '%{1}'"

SQLNamedQuery get-quota-tally SELECT "name, quota_type, bytes_in_used, bytes_out_used, bytes_xfer_used, files_in_used, files_out_used, files_xfer_used FROM ftpquotatallies WHERE name = '%{0}' AND quota_type = '%{1}'"

SQLNamedQuery update-quota-tally UPDATE "bytes_in_used = bytes_in_used + %{0}, bytes_out_used = bytes_out_used + %{1}, bytes_xfer_used = bytes_xfer_used + %{2}, files_in_used = files_in_used + %{3}, files_out_used = files_out_used + %{4}, files_xfer_used = files_xfer_used + %{5} WHERE name = '%{6}' AND quota_type = '%{7}'" ftpquotatallies

SQLNamedQuery insert-quota-tally INSERT "%{0}, %{1}, %{2}, %{3}, %{4}, %{5}, %{6}, %{7}" ftpquotatallies

QuotaLimitTable sql:/get-quota-limit
QuotaTallyTable sql:/get-quota-tally/update-quota-tally/insert-quota-tally


RootLogin off
RequireValidShell off


上面的内容你可以完全复制过去使用,需要注意的是下面数据库连接参数要与你自己设置的相同。

# 数据库名@数据库主机 数据库名称 数据库密码
SQLConnectInfo  proftpd@localhost proftpd 123456



到这里proftpd已经安装成功,你可以使用test用户登陆测试,如安装过程中有什么问题,可以与我交流。

另外说明:本人刚开始学习solaris,水平有限。这篇文章是我参考linux平台下的一篇文件写的,经过自己安装后没有问题,所以将安装过程回忆后记录下来。文章中的解释性内容较少,如有需要可以参考其它文章。

[ 本帖最后由 ptsmy 于 2006-1-15 22:04 编辑 ]



 wolfg 回复于:2006-01-10 19:43:30

引用:bash-2.03# 

solaris 8 下用的是bash?


 ptsmy 回复于:2006-01-15 22:05:41

我在LINUX下用bash用习惯了,所以也将solaris8换成了bash


 badb0y 回复于:2006-01-16 08:22:02

我在SUN9下一直编译不成功,郁闷,,顶!!!


 NTO 回复于:2006-01-25 09:44:16

请教LZ
完全按照LZ的步骤,在proftpd的编译时,出现make错误,出错信息如下
ld: warning: file /usr/local/mysql/lib/libmysqlclient.a(libmysql.o): wrong ELF class: ELFCLASS64
Undefined                       first referenced
 symbol                             in file
make_scrambled_password             modules/mod_sql_mysql.o
mysql_fetch_row                     modules/mod_sql_mysql.o
mysql_ping                          modules/mod_sql_mysql.o
mysql_errno                         modules/mod_sql_mysql.o
mysql_error                         modules/mod_sql_mysql.o
mysql_options                       modules/mod_sql_mysql.o
mysql_init                          modules/mod_sql_mysql.o
mysql_num_fields                    modules/mod_sql_mysql.o
mysql_store_result                  modules/mod_sql_mysql.o
mysql_real_connect                  modules/mod_sql_mysql.o
mysql_real_query                    modules/mod_sql_mysql.o
mysql_close                         modules/mod_sql_mysql.o
mysql_real_escape_string            modules/mod_sql_mysql.o
mysql_field_count                   modules/mod_sql_mysql.o
mysql_free_result                   modules/mod_sql_mysql.o
mysql_num_rows                      modules/mod_sql_mysql.o
ld: fatal: Symbol referencing errors. No output written to proftpd
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `proftpd'

试了很多编都是这样,请问这是为什么?我的gcc是从sunfreeware上下载的2.95.3版本
请高手指点,时间紧迫,在线等待,万分感谢~~~~~~


 wolfg 回复于:2006-01-25 13:10:26

你的mysql安装的是什么版本的?


 ptsmy 回复于:2006-01-26 23:16:18

没有碰以这类问题,我估计是环境变量设置有问题,请版主想想办法

[ 本帖最后由 ptsmy 于 2006-1-26 23:20 编辑 ]


 wolfg 回复于:2006-01-27 10:55:08

引用:原帖由 ptsmy 于 2006-1-26 23:16 发表
没有碰以这类问题,我估计是环境变量设置有问题,请版主想想办法 



参考
http://lists.mysql.org/perl/2373

估计是因为安装了64位的mysql,换32位的试试


 NTO 回复于:2006-02-05 15:46:38

mysql换成了mysql-max-5.0.18-solaris8-32bit-sparc版本,make的时候问题依旧。
/usr/include/sys/ioctl.h:103: warning: this is the location of the previous definition
/usr/include/sys/termios.h:307: warning: `FLUSHO' redefined
/usr/include/sys/ioctl.h:104: warning: this is the location of the previous definition
/usr/include/sys/termios.h:308: warning: `PENDIN' redefined
/usr/include/sys/ioctl.h:110: warning: this is the location of the previous definition
gcc -Llib -o proftpd src/main.o src/timers.o src/sets.o src/pool.o src/regexp.o  src/dirtree.o src/support.o src/netaddr.o src/inet.o src/child.o  src/log.o src/xferlog.o src/bindings.o src/netacl.o src/class.o  src/scoreboard.o src/help.o src/feat.o src/netio.o src/response.o  src/ident.o src/data.o src/modules.o src/auth.o src/fsio.o  src/mkhome.o src/ctrls.o src/event.o modules/mod_core.o modules/mod_xfer.o modules/mod_auth_unix.o modules/mod_auth_file.o modules/mod_auth.o modules/mod_ls.o modules/mod_log.o modules/mod_site.o modules/mod_auth_pam.o modules/mod_sql_mysql.o modules/mod_sql.o  modules/module_glue.o -L/usr/local/mysql -lsupp -lsocket -lnsl -lresolv  -lm -lz -lmysqlclient  -lpam
ld: fatal: library -lmysqlclient: not found
ld: fatal: File processing errors. No output written to proftpd
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `proftpd'

请大虾救命啊~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


 NTO 回复于:2006-02-05 15:52:06

更换gcc版本后故障照旧(从gcc 2.95--〉gcc3.32)

gcc  -DSOLARIS2_8 -DSOLARIS2 -I.. -I../include -I/usr/local/mysql/include -O2 -Wall -c mod_core.c
gcc  -DSOLARIS2_8 -DSOLARIS2 -I.. -I../include -I/usr/local/mysql/include -O2 -Wall -c mod_xfer.c
gcc  -DSOLARIS2_8 -DSOLARIS2 -I.. -I../include -I/usr/local/mysql/include -O2 -Wall -c mod_auth_unix.c
gcc  -DSOLARIS2_8 -DSOLARIS2 -I.. -I../include -I/usr/local/mysql/include -O2 -Wall -c mod_auth_file.c
gcc  -DSOLARIS2_8 -DSOLARIS2 -I.. -I../include -I/usr/local/mysql/include -O2 -Wall -c mod_auth.c
gcc  -DSOLARIS2_8 -DSOLARIS2 -I.. -I../include -I/usr/local/mysql/include -O2 -Wall -c mod_ls.c
gcc  -DSOLARIS2_8 -DSOLARIS2 -I.. -I../include -I/usr/local/mysql/include -O2 -Wall -c mod_log.c
gcc  -DSOLARIS2_8 -DSOLARIS2 -I.. -I../include -I/usr/local/mysql/include -O2 -Wall -c mod_site.c
gcc  -DSOLARIS2_8 -DSOLARIS2 -I.. -I../include -I/usr/local/mysql/include -O2 -Wall -c mod_auth_pam.c
gcc  -DSOLARIS2_8 -DSOLARIS2 -I.. -I../include -I/usr/local/mysql/include -O2 -Wall -c mod_sql.c
gcc  -DSOLARIS2_8 -DSOLARIS2 -I.. -I../include -I/usr/local/mysql/include -O2 -Wall -c mod_sql_mysql.c
srcdir=. ./glue.sh mod_core.o mod_xfer.o mod_auth_unix.o mod_auth_file.o mod_auth.o mod_ls.o mod_log.o mod_site.o mod_auth_pam.o mod_sql.o mod_sql_mysql.o
gcc  -DSOLARIS2_8 -DSOLARIS2 -I.. -I../include -I/usr/local/mysql/include -O2 -Wall -c module_glue.c
gcc -Llib -o proftpd src/main.o src/timers.o src/sets.o src/pool.o src/regexp.o  src/dirtree.o src/support.o src/netaddr.o src/inet.o src/child.o  src/log.o src/xferlog.o src/bindings.o src/netacl.o src/class.o  src/scoreboard.o src/help.o src/feat.o src/netio.o src/response.o  src/ident.o src/data.o src/modules.o src/auth.o src/fsio.o  src/mkhome.o src/ctrls.o src/event.o modules/mod_core.o modules/mod_xfer.o modules/mod_auth_unix.o modules/mod_auth_file.o modules/mod_auth.o modules/mod_ls.o modules/mod_log.o modules/mod_site.o modules/mod_auth_pam.o modules/mod_sql_mysql.o modules/mod_sql.o  modules/module_glue.o -L/usr/local/mysql/lib -lsupp -lsocket -lnsl -lresolv  -lm -lz -lmysqlclient  -lpam
Undefined                       first referenced
 symbol                             in file
uncompress                          /usr/local/mysql/lib/libmysqlclient.a(my_compress.o)
compress                            /usr/local/mysql/lib/libmysqlclient.a(my_compress.o)
ld: fatal: Symbol referencing errors. No output written to proftpd
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `proftpd'


 NTO 回复于:2006-02-05 16:09:43

主机硬件平台Fire V440 sparc
OS solaris8 2/04,kernel patch Generic_108528-29
时间紧迫,请各位达人赐教! :(


 wolfg 回复于:2006-02-05 16:19:19

引用:原帖由 NTO 于 2006-2-5 16:09 发表
主机硬件平台Fire V440 sparc
OS solaris8 2/04,kernel patch Generic_108528-29
时间紧迫,请各位达人赐教! :( 


时间紧的话就先试试直接装二进制的proftpd吧
http://www.sunfreeware.com/indexsparc8.html
http://www.sunfreeware.com/programlistsparc8.html#proftpd


 yhn8114 回复于:2006-07-21 16:51:07

我觉得是mysql 的版本问题




原文链接:http://bbs.chinaunix.net/viewthread.php?tid=681322
转载请注明作者名及原文出处