`
bayerlin
  • 浏览: 18244 次
  • 性别: Icon_minigender_1
  • 来自: 广州
最近访客 更多访客>>
社区版块
存档分类
最新评论

FreeBSD6.2架设之Pure-FTPd服务器

阅读更多
Index:

  简介

  Step 1 installation Apache22.

  Step 2 installation MySQL Server.

  Step 3 installation PHP.

  Step 4 installation PureFTPd.

  Step 5 creating a MySQL database.

  Step 6 configuration of PureFTPd.

  Setp 7 User manager for PureFTPd.

  F.A.Q.

  Links to other sources

  

  简介

  

  Pure-FTPd is a free (BSD), secure, production-quality and standard-conformant FTP server. It doesn't provide useless bells and whistles, but focuses on efficiency and ease of use. It provides simple answers to common needs, plus unique useful features for personal users as well as hosting providers.

  Pure-FTPd是一个自由的、安全的、高品质的FTP Server。它,高效并且易于使用。Pure-FTPd提供多语言支持,包括简体文、繁体中文,同时也支持UTF-8。本文使用FreeBSD6.2做为系统,使用Pure-FTPd程序提供FTP服务,并且结合MySQL Server做认证。支持虚拟用户、用户带宽控制、用户磁盘限额。使用User manager for PureFTPd,提供后台管理界面。

  FreeBSD6.2+Apache22+PHP5+php5-extensions+ Pure-FTPd+ User manager for PureFTPd

  软件版本信息:

  · FreeBSD 6.2-RELEASE

  · Apache-2.2.3

  · Mysql-server-5.0.27

  · Php5-5.1.6_3

  · Php5-extensions-1.0

  · Pure-FTPd-1.0.21_1

  · User manager for Pure-FTPd

  

  Step 1 Installation Apache22.

  

  Installation of the Apache server:

  跟随下面步骤安装Apache2.

  使用Ports方式安装Apache22,(更易于以后的维护,比如升级、卸载),进入Apache22所在的Ports安装目录/usr/ports/www/apache22目录,执行make install clean进行安装。

  Shell:

  whereis apache22

  apache22: /usr/ports/www/apache22

  cd /usr/ports/www/apache22

  make install clean

  系统要求选择模块,取消IPV6支持,其它保持默认即可

  

  Options for apache 2.2.6_2

  [ ] I PV6 Enable IPv6 support

  安装完成后,输入rehash命令刷新

  Shell:

  To run apache www server from startup, add apache22_enable="YES"

  in your /etc/rc.conf. Extra options can be found in startup script.

  ===> Cleaning for autoconf-wrapper-20071109

  ===> Cleaning for p5-gettext-1.05_1

  ===> Cleaning for apache-2.2.6_2

  rehash

  系统提示,需要添加apache22_enable=”YES”到/etc/rc.conf文件。

  (具体信息可以查看cat /usr/local/etc/rc.d/apache22会有详细说明)

  Shell:

  vi /etc/rc.conf

  添加以下内容

  Editor:

  #Apache22

  apache22_enable="YES"

  保存退出后,启动Apache进行测试

  输入命令/usr/local/etc/rc.d/apache22 start启动Apache

  Shell:

  /usr/local/etc/rc.d/apache22 start

  Syntax OK

  Starting apache22.

  

  使用浏览器访问FreeBSD服务器IP地址测试Apache是否工作正常

  浏览器打开http://youipaddress

  It works!

  好了,Apache22安装成功了。

  

  Step 2 Installation MySQL Server.

  

  Installation of the MySQL server:

  跟随下面步骤安装MySQL.

  使用Ports方式安装MySQL,进入MySQL所在的Ports安装目录/usr/ports/www/apache22目录,执行make install clean进行安装。

  Shell:

  whereis mysql50-server

  mysql50-server: /usr/ports/databases/mysql50-server

  cd /usr/ports/databases/mysql50-server/

  make install clean

  安装完成后,输入rehash命令刷新

  Shell:

  http://www.mysql.com/

  ===> Cleaning for mysql-client-5.0.45_1

  ===> Cleaning for mysql-server-5.0.45_1

  rehash

  系统提示,需要添加mysql_enable=”YES”到/etc/rc.conf文件。

  (具体信息可以查看cat /usr/local/etc/rc.d/mysql-server会有详细说明)

  Shell:

  vi /etc/rc.conf

  添加以下内容

  Editor:

  #MySQL5.0

  mysql_enable="YES"

  保存退出后,启动Mysql5.0进行测试

  输入命令/usr/local/etc/rc.d/mysql-server start启动Mysql

  

  检测Mysql是否正常运行

  可以通过监听端口和系统进程进行判断

  Shell:

  netstat -an | grep "3306"

  tcp4 0 0 *.3306 *.* LISTEN

  ps -aux|grep mysql|grep -v grep

  mysql 97589 0.0 0.3 1728 1376 p0 I 3:03PM 0:00.09 /bin/sh /usr/local/bin/mysqld_safe --defaults-extra-file=/va

  mysql 97609 0.0 4.9 53844 25576 p0 S 3:03PM 0:01.07 /usr/local/libexec/mysqld --defaults-extra-file=/var/db/mysq

  系统显示Mysql已在所有地址(0)上监听3306端口,并且也可以查到Mysql的进程。

  

  更改Mysql密码

  Mysql安装完成后,并没有设定密码。为增加数据库安装性,使用mysqladmin命令设定Mysql密码

  Shell:

  mysqladmin -u root password '123456' ('123456')是你要设定的密码

  验证密码是否设定常

  Shell:

  mysql -u root -p

  Enter password:

  Welcome to the MySQL monitor. Commands end with ; or \g.

  Your MySQL connection id is 3

  Server version: 5.0.45FreeBSD port: mysql-server-5.0.45_1

  

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

  

  mysql> show databases;

  +--------------------+

  | Database |

  +--------------------+

  | information_schema |

  | mysql |

  | test |

  +--------------------+

  3 rows in set (0.01 sec)

  

  mysql> quit

  Bye

  密码设定正确。至此Mysql安装完成。

  

  Step 3 Installation PHP5.

  

  Installation of the PHP5:

  跟随下面步骤安装PHP5.

  使用Ports方式安装PHP5,进入PHP5所在的Ports安装目录/usr/ports/www/php2执行ake install clean进行安装。

  Shell:

  whereis php5

  php5: /usr/ports/lang/php5

  cd /usr/ports/lang/php5/

  make install clean

  

  安装时,会要求进行php5选项设定,这里选择如下

  Options for php5 5.2.5

  [X] A PACHE Build Apache module

  [X] M ULTIBYTE Enable zend multibyte support

  安装完成后,输入rehash命令刷新

  Shell:

  ***************************************************************

  Make sure index.phpis part of your DirectoryIndex.

  You should add the following to your Apache configuration file:

  

  AddType application/x-httpd-php .php

  AddType application/x-httpd-php-source .phps

  ***************************************************************

  ===> Cleaning for pkg-config-0.22_1

  ===> Cleaning for libxml2-2.6.30

  ===> Cleaning for php5-5.2.5

  rehash

  系统提示,需要添加以上被标记颜色到httpd.conf文件。

  先备份httpd.conf文件

  Shell:

  cd /usr/local/etc/apache22/

  cp httpd.conf httpd.conf.bak

  编辑httpd.conf文件

  Shell:

  vi /usr/local/etc/apache22/httpd.conf

  编辑/usr/local/etc/apache22/httpd.conf文件,以使Apache Server支持php

  编辑/usr/local/etc/apache22/httpd.conf,在AddType application/x-gzip .gz .tgz(大约354行)下面添加添加以下内容

  Editor:

  index.php

  AddType application/x-httpd-php .php

  AddType application/x-httpd-php-source .phps

  

  修改前:

  # probably should define those extensions to indicate media types:

  #

  AddType application/x-compress .Z

  AddType application/x-gzip .gz .tgz

  修改后:

  # probably should define those extensions to indicate media types:

  #

  AddType application/x-compress .Z

  AddType application/x-gzip .gz .tgz

  AddType application/x-httpd-php .php

  AddType application/x-httpd-php-source .phps

  

  

  先不要退出,添加'index.php' 到'DirectoryIndex' 主目录索引(大约212行)Editor:

  DirectoryIndex index.php index.html index.htm

  

  修改前:

  #

  

  DirectoryIndex index.html

  

  

  #

  修改后:

  #

  

  DirectoryIndex index.phpindex.html index.htm

  

  #

  保存退出后。

  

  

  Installation of the PHP5-Extensions:

  跟随下面步骤安装PHP5-Extensions.

  使用Ports方式安装PHP5-extensions,进入PHP5-extensions所在的Ports安装目录/usr/ports/lang/php5-extensions目录,执行make install clean进行安装。

  Shell:

  whereis php5-extensions

  php5-extensions: /usr/ports/lang/php5-extensions

  cd /usr/ports/lang/php5-extensions/

  make install clean

  安装时,会要求进行php5-extensions选项设定,这里选择如下

  Options for php5-extensions 1.0

  [X] M YSQL MySQL database support

  [X] P CRE Perl Compatible Regular Expression support

  [X] P OSIX POSIX-like functions

  [X] S ESSION session support

  安装完成后,输入rehash命令刷新

  

  Shell:

  ===> Cleaning for php5-posix-5.2.5

  ===> Cleaning for php5-session-5.2.5

  ===> Cleaning for php5-extensions-1.1

  rehash

  复制/usr/local/etc/php.ini-dist为/usr/local/etc/php.ini

  Shell:

  cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini

  重新启动Web Server

  Execute the following command to start / restart the Apache webserver.

  Shell:

  /usr/local/etc/rc.d/apache22 restart

  在/usr/local/www/apache22/data/目录下建立一个test.php文件进行php测试

  建立的test.php文件内容如下

  Shell:

  vi /usr/local/www/apache22/data/test.php

  

  Editor:

  

phpinfo();

?>  phpinfo();

  >

  用浏览器打开http://yourip/test.php如显示信息,证明php工作正常。

  

  Step 4 Installation Pure-FTPd.

  

  Installation of the Pure-FTPd:

  跟随下面步骤安装Pure-FTPd

  使用Ports方式安装Pure-FTPd的Ports安装目录/usr/ports/www/apache22目录,执行make install clean进行安装。

  Shell:

  whereis pure-ftpd

  pure-ftpd: /usr/ports/ftp/pure-ftpd

  cd /usr/ports/ftp/pure-ftpd/

  make with_language=simplified-chinese install

  

  安装时,会要求进行php5选项设定,这里选择如下

  Options for pure-ftpd 1.0.21_1

  [X] M YSQL Support for users in MySQL database

  [X] P RIVSEP Enable privilege separation

  [X] P ERUSERLIMITS Per-user concurrency limits

  [X] T HROTTLING Bandwidth throttling

  [X] B ANNER Show pure-ftpd welcome upon session start

  [X] U TF8 Support for charset conversion (expreimental)

  安装完成后,输入rehash命令刷新

  Shell:

  ===> Compressing manual pages for pure-ftpd-1.0.21_1

  ===> Registering installation for pure-ftpd-1.0.21_1

  rehash

  系统提示,需要添加pureftpd_enable=”YES”到/etc/rc.conf文件。

  (具体信息可以查看cat cat /usr/local/etc/rc.d/pure-ftpd会有详细说明)

  Shell:

  vi /etc/rc.conf

  添加以下内容

  Editor:

  #Pure-FTPd

  pureftpd_enable="YES"

  保存退出。

  

  Step 5 Creating a MySQL Database.

  

  Creating a MySQL Database:

  跟随下面步骤创建一个MySQL数据库

  登陆http://machiel.generaal.net/files/pureftpd/v2.x/script.mysql网站下载script.mysql脚本文件。

  Shell:

  cd /root/

  fetch "http://machiel.generaal.net/files/pureftpd/v2.x/script.mysql"

  使用下载的MySQL脚本文件,建立一个数据库

  Shell:

  mysql -u root -p

  Enter password:此处输入你的MySQL密码

  至此数据库创建完成。

  数据内容:创建一个数据库Database:tpusers,Login = ftp Password = tmppasswd ,管理权限用户名是:Administrator密码:tmppasswd(采用MD5加密)

  

  Step 6 Configuration of PureFTPd.

  

  Configuration of PureFTPd:

  跟随下面步骤进行Pure-FTPd配置

  1、配置pure-ftpd.conf

  配置pure-ftpd.conf文件

  复制/usr/local/etc/pure-ftpd.conf.sample为pure-ftpd.conf

  Shell:

  cd /usr/local/etc/

  cp /usr/local/etc/pure-ftpd.conf.sample /usr/local/etc/pure-ftpd.conf

  编辑pure-ftpd.conf 文件MySQLConfigFile位置(大约116行)

  编辑pure-ftpd.conf 文件CreateHomeDir (大约3366行)

  Shell:

  vi /usr/local/etc/pure-ftpd.conf

  

  Editor:

  MySQLConfigFile /usr/local/etc/pureftpd-mysql.conf

  CreateHomeDir yes

  

  修改前:

  # MySQL configuration file (see README.MySQL)

  # MySQLConfigFile /etc/pureftpd-mysql.conf

  

  # Automatically create home directories if they are missing

  #CreateHomeDir yes

  修改后:

  # MySQL configuration file (see README.MySQL)

  MySQLConfigFile /usr/local/etc/pureftpd-mysql.conf

  

  # Automatically create home directories if they are missing

  CreateHomeDir yes

  保存退出后。

  

  2、配置pureftpd-mysql.conf

  从http://machiel.generaal.net/files/pureftpd/v2.x/pureftpd-mysql.conf网站下载,pureftpd-mysql.conf文件

  Shell:

  cd /usr/local/etc/

  fetch "http://machiel.generaal.net/files/pureftpd/v2.x/pureftpd-mysql.conf"

  启动PurtFTPd

  Shell:

  /usr/local/etc/rc.d/pure-ftpd start

  

  

  Step 7 User manager for PureFTPd.

  

  Installation User manager of the PureFTPd:

  跟随下面步骤安装PureFTPd管理程序.

  使用Ports方式安装User manager of the PureFTPd,进入User manager of the PureFTPd所在的Ports安装目录cd /usr/ports/www/usermanager/执行make install clean进行安装。

  Shell:

  whereis usermanager

  usermanager: /usr/ports/www/usermanager

  cd /usr/ports/www/usermanager/

  make install clean

  安装完成后,输入rehash命令刷新

  Shell:

  *****************************************************************

  Please check /usr/local/www/data/UserManager/readme.txt

  To use this manager, you will need to compile your

  Pure-FTPd with -DWITH_MYSQL

  *****************************************************************

  'User manager for PureFTPd' is made by M.Mastenbroek 2002 - 2005

  For more info look at http://machiel.generaal.net

  Version 2.1

  Installation:

  Run the installation wizard install.php in your web browser.

  The installation wizard will lead you step by step

  through the configuration of the User manager for PureFTPd.

  Running:

  The User manager for PureFTPd starts from the index.php file.

  *****************************************************************

  rehash

  系统提示,需要使用浏览器打开install.php进行安装。

  编辑/usr/local/etc/apache22/httpd.conf文件,添加虚拟目录

  Shell:

  cp /usr/local/etc/apache22/httpd.conf /usr/local/etc/apache22/httpd.conf.bak

  vi /usr/local/etc/apache22/httpd.conf

  添加以下内容

  Editor:

  Alias /ftp "/usr/local/www/data/UserManager/"

  

  AllowOverride None

  Options None

  Order allow,deny

  Allow from all

  

  保存退出。

  使用浏览器打开http://youripadderss/ftp/install.php

  根据向导进行安装设定,语言选择中文,并且更改管理员密码。最后记得删除install.php文件

  完成后打开http://youripadderss/ftp/index.php登陆录后台设置页面,进行新增用户操作。

  Configuration 'User manager for PureFTPd' Step [1 - 7]

  

  This configuration script has carried out a few checks to see if everything is ready to start the configuration.

  

  Checking if config.php exists OK!  

  Checking if config.php is writable OK!  

  Checking if PHP Extension MYSQL is enabled OK!  

  Checking if PHP Extension PCRE is enabled OK!  

  Checking if PHP Extension POSIX is enabled OK!  

  Checking if PHP Extension SESSION is enabled OK!  

  

  Please choose your configuration type:.选择New installation,create a new database.

  Step [3 - 7]输入正确的root用户和root的密码。

  Settings MySQL database.直接按默认设置(要是你改过密码,就输入你的密码)

  Step [4 - 7]语言选择中文,选择Quota support,Ratio support(上传下载比可以选择或不选择)按Save按钮保存配置文件,然后点Setp5进行下一步。

  Step [5 - 7]这里你可以更改管理员Administator的密码,也可以创建一个自己的帐号代替Administrator

  Step [6 - 7]系统有一些提示,说需要编辑那2个配置文件,因为前面已经编辑过了。所以直接下一步。

  Step [7 - 7]恭喜你安装完成了。建议把install.php文件更改一下名称。

  管理介面

  PureFTPd 帳號管理 按此以新增帳號

  帳號 UID GID 家目錄 上傳頻寬 (KB/s) 下載頻寬 (KB/s) 設定

  ftpuser1 65534 31 /www/ftp/ftpuser1 75 75

  帳號 启用

  密碼

  再次確認密碼

  UID nobody

  GID guest

  家目錄 /www/ftp

  上傳頻寬(KB/s)

  80 配額檔案數量

  下載頻寬(KB/s)

  5 配額空間大小 (MB)

  上下傳比[上:下]

  0:0

  IP 位址 *

  備註

  

  Step 8 写在最后.

  

  User manager for PureFTPd后台管理程序,创建用户时需要手动指定FTP用户主目录。所以建立FTP用户时,需要先建立用户的FTP目录,并设置目录属性为nobody:guest

  例如:建立一个用户名为sunny的用户,主目录为/home/ftp/sunny

  Shell:

  mkdir -p /home/ftp/demo

  chown nobody:guest demo

  

  查看用户在线状态

  通过'pure-ftpwho命令,查看在线用户状态。在/usr/local/www/apache22/cgi-bin目录下建立一个ftpstatus.c文件

  Shell:

  vi /usr/local/www/apache22/cgi-bin/ftpstatus.c

  内容如下:

  Editor:

  #include

  

  int main(int argc, char *argv[])
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics