在 OpenVZ 上安装 Pure-FTPd

打开存放在Gmail里面的账单,Monday, June 14, 2010,由于我买了13个月的VPS,所以还有一个多月就到期吧。

VPS到期之前,写下一点关于VPS上FTP服务器的的架设吧。

由于本地模拟时用的 Pure-FTPd,当然也由于我是用的真机,所以用 apt-get安装的 pureftpd-mysql 是没有一点问题的。

但是在VPS上部署的时候就出鬼了。

当然,主要OpenVZ的内核限制,好像是限制了么lib库吧,然后 apt-get 安装的 Pure-ftpd 无法进入 capabilities 模式。

所以啦,VPS还是与真机有区别的。

起初我只有放弃使用 Pure-ftpd ,换上了ProFtpd,但是后来觉得没有那一款FTP服务器比得上Pure-FTPd的。

当然,鹚偏爱Pure-ftpd是有原因的。

首先是其通过 Mysql 数据库来实现虚拟用户的方式。

这涉及文件的权限和系统的安全性问题,比如像鹚这样以 APACHE2HANDLER 模式下运行的 PHP 来说,文件的所有者为 www-data 是很重要的。

但是对于配套的 Ftp 管理来说,直接用 www-data 管理文件是很不安全,也很不方便的。

所以,Pure-ftpd就是很好的解决方案,通过虚拟化用户,比如建立一个名为 mucidftpd 的虚拟FTP账户,然后映射到 www-data ,再为 mucidftp 这个虚拟FTP账户设置独立的密码,就显得更方便和安全了!

第二点,就是 Pure-FTPd 有配套的 Web 管理面板。

通过浏览器就可以实现对Ftp用户的添加与删除,免除了在SSH里面打那些罗嗦命令的麻烦,真的很适合生产环境。

有兴趣的话,可以打开 http://vps.brightway.be 来看看效果的说!

Pure-ftpd是如此优秀,所以,鹚要想尽办法将其部署到VPS。

没错,办法还是有的 —— 我们进行对 Pure-ftpd 的特殊编译安装。

这里只演示 Pure-FTPd主程序安装,web面板就不啰嗦了。

首先下载 Pure-ftpd 源码:

wget http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.30.tar.gz

解压:

tar zxvf pure-ftpd-1.0.30.tar.gz

cd pure-ftpd-1.0.30

以 Ubuntu(Debian)Server 为例安装依赖:

sudo apt-get install libmysqlclient-dev

开始编译安装吧,主要是注意这个编译参数 –without-capabilities

./configure --prefix=/usr/local/pureftpd CFLAGS=-O2 --with-mysql --with-quotas --with-cookie --with-virtualhosts --with-virtualroot --with-diraliases --with-sysquotas --with-ratios --with-altlog --with-paranoidmsg --with-shadow --with-welcomemsg  --with-throttling --with-uploadscript --with-language=simplified-chinese --without-capabilities

make&&sudo make install

对,就是 –without-capabilities 这个参数,去掉 capabilities 支持,这样 Pure-FTPd 就可以运行在基于 OpenVZ 的 Linux VPS上了!

至于去掉了 capabilities 有什么坏处,好像会轻微的降低安全性,不过不担心,也不会有大问题的!

接下来制作 Pure-Ftpd 的 Server 脚本啦!

sudo cp configuration-file/pure-config.pl /usr/local/pureftpd/sbin/

sudo chmod 755 /usr/local/pureftpd/sbin/pure-config.pl

sudo vi /etc/init.d/pureftpd

将下列内容复制到 /etc/init.d/pureftpd 里面:

#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

# Check if user is root
if [ $(id -u) != "0" ]; then
    printf "Error: You must be root to run this script!\n"
    exit 1
fi

prog="Pure-FTPd"

start() {
	printf "Starting $prog... \n"
	/usr/local/pureftpd/sbin/pure-config.pl /usr/local/pureftpd/pure-ftpd.conf --daemonize
}
stop() {
	printf "Stopping $prog... \n"
	killall pure-ftpd
}

case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart)
		stop
		start
		;;
	status)
		if [ -e /var/run/pure-ftpd.pid ]; then
			printf "$prog is running.\n"
		else
			printf "$prog is NOT running.\n"
		fi
		;;
	*)
		printf "Usage: service pureftpd {start|stop|restart|status|who}\n"
esac
exit

最后来一句:

sudo chmod 755 /etc/init.d/pureftpd

基本完工,这时试试来一句:

sudo service pureftpd start|stop|restart

感觉如何,比 apt-get 安装的 Pure-FTPd 不会差哦!

有必要的话,记得添加Pureftpd开机启动:

sudo update-rc.d pureftpd defaults

About Mucid

My life is brilliant !
This entry was posted in Technology and tagged , , , , , , . Bookmark the permalink.

42 Responses to 在 OpenVZ 上安装 Pure-FTPd

  1. 小邪 says: Google Chrome 13.0.782.24 Google Chrome 13.0.782.24 Windows 7 x64 Edition Windows 7 x64 Edition

    推荐下次碰到不知道怎么安装的时候,去看看有些套件例如lnmp的脚本,里面有pure-ftpd的安装命令。应该蛮有帮助的喔,嘿嘿。
    P.s. 前段时间失踪,最近老文章补课中,蛋定。

    • Mucid says: Firefox 5.0 Firefox 5.0 Windows 7 Windows 7

      @小邪 , LNMP的安装脚本被我通读了,呢,小邪自己都没看到的说,不然你就会发现,上面的脚本参数都是参考自LNMP一键包的脚本的,但是你直接用LNMP一键包的脚本是绝对不行的说! :twisted:

  2. 奶牛 says: Firefox 4.0 Firefox 4.0 Windows 7 Windows 7

    有SSH就可以弃用ftp咯~~~ :smile:

  3. maplebeats says: Firefox 4.0.1 Firefox 4.0.1 GNU/Linux GNU/Linux

    =,=以前搞半天就是ftp搞不出来,搞恶心了。后来直接sftp+命令行将就用到现在@。@

  4. yetone says: Google Chrome 11.0.696.71 Google Chrome 11.0.696.71 GNU/Linux x64 GNU/Linux x64

    感谢国家

  5. Solo says: Google Chrome 13.0.772.0 Google Chrome 13.0.772.0 Windows 7 Windows 7

    vsftpd也不错吧….

  6. joyla says: Internet Explorer 9.0 Internet Explorer 9.0 Windows 7 Windows 7

    等等我再折腾,嘿嘿!

  7. DaZuoo says: Google Chrome 10.0.648.204 Google Chrome 10.0.648.204 Windows XP Windows XP

    小姨上次维护时间忒长就是去玩独立了- –

  8. yongqi says: Internet Explorer 8.0 Internet Explorer 8.0 Windows XP Windows XP

    :???: :???: :???:以下省略N个….

  9. 公子 says: Google Chrome 8.0.552.237 Google Chrome 8.0.552.237 Windows 7 Windows 7

    又学习了~

  10. 减肥咖啡 says: Internet Explorer 8.0 Internet Explorer 8.0 Windows XP Windows XP

    程序方面 看来你还是挺懂的嘛

  11. 枫叶红秋雨 says: Firefox 4.0.1 Firefox 4.0.1 Windows XP Windows XP

    俺的VPS用的也是这个。不错的!

  12. kita says: Google Chrome 11.0.696.68 Google Chrome 11.0.696.68 Mac OS X  10.6.7 Mac OS X 10.6.7

    童子節快樂哇!話說kita一直都是再用ssh的那個sftp。。。

  13. 张扬扬 says: Firefox 4.0.1 Firefox 4.0.1 Windows XP Windows XP

    不错啊

  14. 减肥药排行榜 says: Internet Explorer 8.0 Internet Explorer 8.0 Windows XP Windows XP

    显得更方便和安全了!

  15. 婉秋 says: Firefox 4.0.1 Firefox 4.0.1 GNU/Linux GNU/Linux

    :???: 高深

  16. 雅岚 says: Firefox 3.6.13 Firefox 3.6.13 Windows XP Windows XP

    完全不懂。。。岚女只是来看望小鹚,儿童节快乐,哈哈哈。。。 :mrgreen:

  17. EmiNarcissus says: Safari 5.0.5 Safari 5.0.5 Mac OS X  10.6.7 Mac OS X 10.6.7

    pureftpd确实是目前用过最傻瓜的ftp服务器了,而且功能真得已经够用了。

  18. 囧阿囧 says: Google Chrome 11.0.696.71 Google Chrome 11.0.696.71 Windows 7 Windows 7

    自己装不会,一键包里面的

    • Mucid says: Firefox 4.0.1 Firefox 4.0.1 GNU/Linux GNU/Linux

      @囧阿囧 , 其实我被这个就是参照的一键包的脚本,由本人修改而来,不过一键包的脚本在我的vps上是绝对安不好的!

  19. Tao Zhu says: Firefox 4.0.1 Firefox 4.0.1 GNU/Linux GNU/Linux

    俺也来围观技术控

  20. 软件街小秘 says: Google Chrome 11.0.696.71 Google Chrome 11.0.696.71 Windows 7 Windows 7

    第一次听说OpenVZ

    围观技术控 :eek: