手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 免费部署 N8N 的 Zeabur 注册 | 登陆
浏览模式: 标准 | 列表分类:苹果相关

aliyun 安装 ftp(proftpd)

有了服务器,怎么着都得装个Ftp吧,否则,必须得让人用ssh连接来上传文件 ?
于是我找了proftpd,因为比较简单vsftpd太麻烦了。proftpd的教程很简单

1、先apt-get update,apt-get upgrade
2、apt-get install proftpd-basic proftpd-mod-mysql
3、修改 /etc/proftpd/proftpd.conf
因为原内容都注释了,所以直接在文件的最后加上:

XML/HTML代码
  1. DefaultRoot ~  
  2. Include /etc/proftpd/sql.conf  
  3. RequireValidShell off  

4、添加一个组,和一个用户:

XML/HTML代码
  1. groupadd -g 2001 ftpgroup  
  2. useradd -u 2001 -s /bin/false -d /bin/null -c "proftpd user" -g ftpgroup ftpuser  

5、去mysql里增加一个用户,如proftpd/proftpdpass,建一个数据库,如:proftpd
6、插入表结构:

SQL代码
  1. CREATE TABLE ftpgroup (  
  2.  groupname varchar(16) NOT NULL default '',  
  3.  gid smallint(6) NOT NULL default '2001',  
  4.  members varchar(16) NOT NULL default '',  
  5.  KEY groupname (groupname)  
  6.  ) ENGINE=MyISAM COMMENT='ProFTP group table';  
  7.   
  8. CREATE TABLE ftpuser (  
  9.  id int(10) unsigned NOT NULL auto_increment,  
  10.  userid varchar(32) NOT NULL default '',  
  11.  passwd varchar(32) NOT NULL default '',  
  12.  uid smallint(6) NOT NULL default '2001',  
  13.  gid smallint(6) NOT NULL default '2001',  
  14.  homedir varchar(255) NOT NULL default '',  
  15.  shell varchar(16) NOT NULL default '/sbin/nologin',  
  16.  count int(11) NOT NULL default '0',  
  17.  accessed datetime NOT NULL default '0000-00-00 00:00:00',  
  18.  modified datetime NOT NULL default '0000-00-00 00:00:00',  
  19.  PRIMARY KEY (id),  
  20.  UNIQUE KEY userid (userid)  
  21.  ) ENGINE=MyISAM COMMENT='ProFTP user table';  

7、修改/etc/proftpd/modules.conf,去掉两行注释:

XML/HTML代码
  1. LoadModule mod_sql.c  
  2. LoadModule mod_sql_mysql.c  

8、修改/etc/proftpd/sql.conf

 

 

XML/HTML代码
  1. SQLBackend mysql  
  2. SQLAuthTypes Crypt  
  3. #下面一行就是用户名密码  
  4. SQLConnectInfo 数据库@localhost 用户名 密码   
  5. SQLUserInfo ftpuser userid passwd uid gid homedir shell  
  6. SQLGroupInfo ftpgroup groupname gid members  
  7. # Update count every time user logs in  
  8. SQLLog PASS updatecount  
  9. SQLNamedQuery updatecount UPDATE "countcount=count+1, accessed=now() WHERE userid='%u'" ftpuser  
  10. SQLLog STOR,DELE modified  
  11. SQLNamedQuery modified UPDATE "modified=now() WHERE userid='%u'" ftpuser  

9、插入用户:

XML/HTML代码
  1. INSERT INTO `ftpgroup` (`groupname`, `gid`, `members`) VALUES ('ftpgroup', 2001, 'ftpuser');  
  2. INSERT INTO `ftpuser` ( `userid`, `passwd`, `uid`, `gid`, `homedir`, `shell`, `count`) VALUES ( 'username', ENCRYPT('password'), 2001, 2001, '/var/www/www.example.com/', '/sbin/nologin', 0);  

10、重启proftpd:/etc/init.d/proftpd restart
上面这段其实是来自:http://www.sysadminworld.com/2011/install-proftpd-with-mysql-backend-on-debian-ubuntu/

 

--------EOF---

至此,上面的内容基本上就能够登录成功了,如果还是失败,建议先停掉proftpd,然后运行proftpd -nd6,查看错误信息,比如我就看到了这个:

XML/HTML代码
  1. Mar 09 00:22:29 test proftpd[8850] test (0.0.0.0[0.0.0.0]): notice: unable to use '~/' [resolved to '/server/wwwroot/htdocs/']: Permission denied  
  2. Mar 08 16:22:29 test proftpd[8850] test (0.0.0.0[0.0.0.0]): Preparing to chroot to directory '~/'  
  3. Mar 08 16:22:29 test proftpd[8850] test (0.0.0.0[0.0.0.0]): chroot to '~/' failed for user 'xxxxxx': Operation not permitted  
  4. Mar 08 16:22:29 test proftpd[8850] test (0.0.0.0[0.0.0.0]): error: unable to set default root directory  
  5. Mar 08 16:22:29 test proftpd[8850] test (0.0.0.0[0.0.0.0]): FTP session closed.  

我靠,这个怎么办?

 

这时候我又请vampire帮忙了。他就帮我检查了一下,做了几个处理:

1、vim /etc/groups ,在www-data:x:33后面加了:www-data:x:33:ftpgroup ,表示权限跟着www-data,因为我们的ftp目录里的文件都是基于www-data的

2、修改/etc/proftpd/proftpd.conf,改其中的:user / group ,都改成www-data

3、还是/etc/proftpd/proftpd.conf ,改 Umask ,原来是Umask 022 022,去掉一个022

4、因为我的www-data是gid是33,所以刚才在数据库里插的gid统统换成33,而不是原来的2001,这时候再登录其实还是不正常。

5、最重要的一个,在刚才的sql.conf里面,加入:SQLMinID 33,这个玩意要参考:http://www.proftpd.org/docs/directives/linked/config_ref_SQLMinID.html,我晶,这个东西,居然在默认的sql.conf里是没有这一行的。果然还是vampire有经验。因为www-data的gid是33,所以sqlminid就是33了。

这时候,终于一切正常了。折腾了好久。。。

 

 

 

 

 

 

 

Tags: aliyun, proftpd

aliyun二三事

最近在试用阿里云,但是遇到了一些问题。
我在安装数据库的时候,是通过apt-get install mysql-server进行安装的,然而我安装完后,想将数据存储到额外挂载的磁盘时,却发现数据不能写入。。。
因为我老是启动失败。。所以看了下LOG,LOG是说写入目录失败。
于是请vampire帮忙看了一下,他测试了mysql_install_db,但是。。。

XML/HTML代码
  1. # mysql_install_db --datadir=/server/software/mysql_data  
  2. Installing MySQL system tables...  
  3. 130308 16:14:25 [Warning] Can't create test file /server/software/mysql_data/AY130304113437124704.lower-test  
  4. 130308 16:14:25 [Warning] Can't create test file /server/software/mysql_data/AY130304113437124704.lower-test  
  5. ERROR: 1005  Can't create table 'db' (errno: 13)  
  6. 130308 16:14:25 [ERROR] Aborting  
  7.   
  8. 130308 16:14:25 [Note] /usr/sbin/mysqld: Shutdown complete  
  9.   
  10.   
  11. Installation of system tables failed!  Examine the logs in  
  12. /server/software/mysql_data for more information.  
  13.   
  14. You can try to start the mysqld daemon with:  
  15.   
  16.     shell> /usr/sbin/mysqld --skip-grant &  
  17.   
  18. and use the command line tool /usr/bin/mysql  
  19. to connect to the mysql database and look at the grant tables:  
  20.   
  21.     shell> /usr/bin/mysql -u root mysql  
  22.     mysql> show tables  
  23.   
  24. Try 'mysqld --help' if you have problems with paths.  Using --log  
  25. gives you a log in /server/software/mysql_data that may be helpful.  
  26.   
  27. Please consult the MySQL manual section  
  28. 'Problems running mysql_install_db', and the manual section that  
  29. describes problems on your OS.  Another information source are the  
  30. MySQL email archives available at http://lists.mysql.com/.  
  31.   
  32. Please check all of the above before mailing us!  And remember, if  
  33. you do mail us, you MUST use the /usr/scripts/mysqlbug script!  

oh shit,还是安装不了。试了很多都没有用。最后从官方下载了5.6的包进行安装。居然就OK了。我靠,这个源是cn.ubuntu的源啊。。。苦逼了。
所幸问题解决了。

多谢vampire,同时各位朋友也注意下。如果真的不行,也可以尝试从网上直接下载源码编译,要么。就换成中科大的源,然后再upgrade。中科大的更新比较快。

但因为要修改内容和启动参数还是有点危险的。。。

为debian增加apt-add-repository功能

ubuntu下面有一个很不错的功能,它能够使你很方便 的添加ppa的源,那就是apt-add-repository
在我之前写的一篇博客里就有介绍此功能(关于gearman的),但在debian系统上就无法适用,因为debian下没有此功能
于是找了ubuntu下的apt-add-repository的代码,cp了一份到debian下面,但不能运行。所以google了一下,发现这么一段代码就OK了:

XML/HTML代码
  1. #!/bin/bash   
  2. if [ $# -eq 1 ]   
  3. then   
  4.     ppa_name=`echo "$1" | cut -d":" -f2 -s`   
  5.     if [ -z "$ppa_name" ]   
  6.     then   
  7.         echo "PPA name not found"   
  8.         echo "Utility to add PPA repositories in your debian machine"   
  9.         echo "$0 ppa:user/ppa-name"   
  10.     else   
  11.         echo "$ppa_name"   
  12.         echo "deb http://ppa.launchpad.net/$ppa_name/ubuntu lucid main" >> /etc/apt/sources.list   
  13.         apt-get update >> /dev/null 2> /tmp/apt_add_key.txt   
  14.         key=`cat /tmp/apt_add_key.txt | cut -d":" -f6 | cut -d" " -f3`   
  15.         apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $key   
  16.         rm -rf /tmp/apt_add_key.txt   
  17.     fi   
  18. else   
  19.     echo "Utility to add PPA repositories in your debian machine"   
  20.     echo "$0 ppa:user/ppa-name"   
  21. fi   

将这段内容存成apt-add-repository,然后cp到/usr/bin目录下,并且chmod +x 这个文件,让它有可执行的权限。
再接着使用apt-add-repository 来添加源就OK了
这个自定义的版本,在添加完源后,还会将source.list进行了修改。比ubuntu还人性化。。
参考:
1.http://cptbtptp.blog.51cto.com/3228046/620036
2.http://jolin.2001.blog.163.com/blog/static/89912172011485354567/
两篇内容细看,其实就是一样的。。

Tags: debian, ubuntu, apt, ppa

svn: E220001: Unreadable path encountered; access denied

发现svn的代码有更新,却忘了与上次对比。于是svn与上一版本对比的时候就出现了标题的错误:
svn: E220001: Unreadable path encountered; access denied

其实解决方法很简单,在conf/svnserve.conf中。找到anonaccess = read这一行,(默认是注释掉的)
加入一行 anonaccess = none

再试一下,就会发现正常了。

这应该算是svn的BUG了。拜托,就算你不支持anon这样的匿名用户,你好歹默认为NONE这种值你总要存在吧。不存在 就直接造成无法访问,没权限了。

Tags: svn

ubuntu下安装gearman及扩展

Ubuntu下面安装gearman以及php的gearman扩展是需要注意一下的。
不是默认的安装就直接OK
apt-get install gearman
安装完gearman后。使用pecl install gearman安装。这时候会提示你安装新版 的libgearman
如果你直接搜索apt-cache search libgearman,会发现有很多,但其实一个都不是。。不用上当了

OK,怎么办?有人也问过这个问题:http://stackoverflow.com/questions/13312207/installing-gearman-php-extension-on-debian-6
有人这么回复 :

The reason that this doesn't work is that as the error message says, the most recent version of the PHP extension requires libgearman-1.0 (which is why the directory is named 1.0). You'll need to be at least on wheezy (which is the version after debian 6 / squeeze) to get libgearman-1.0.

It might also be a solution to compile libgearman from source, and then use checkinstall to create a debian package that you install afterwards, or use the gearman developer ppa available at https://launchpad.net/~gearman-developers/+archive/ppa. We've built libgearman, gearmand and the PHP extension on a wide variety of distributions (including Debian, Ubuntu, RHEL4 and SL6) and used checkinstall to get a proper package available.

嗯,打开这个网址。
在最上面有提醒你怎么将PPA将入源里:

Adding this PPA to your system

You can update your system with unsupported packages from this untrusted PPA by adding ppa:gearman-developers/ppa to your system's Software Sources. (Read about installing)

OK,那我们开始吧:

 apt-add-repository ppa:gearman-developers/ppa

然后,你根据你的版本,将源加到你的source.list文件里:
vim /etc/apt/source.list
加入:

deb http://ppa.launchpad.net/gearman-developers/ppa/ubuntu precise main  deb-src http://ppa.launchpad.net/gearman-developers/ppa/ubuntu precise main 

然后:apt-get update
apt-get upgrade
会提醒你需要升级gearman到最新版 本
这时候再:
pecl install gearman
然后就直接安装成功,会提示你怎么操作:
XML/HTML代码
  1. Build process completed successfully  
  2. Installing '/usr/lib/php5/20090626+lfs/gearman.so'  
  3. install ok: channel://pecl.php.net/gearman-1.1.1  
  4. configuration option "php_ini" is not set to php.ini location  
  5. You should add "extension=gearman.so" to php.ini  
按照提示操作完后,重启apache。
在命令行下执行:
XML/HTML代码
  1. # php -i |grep gearman  
  2. gearman  
  3. gearman support => enabled  
  4. libgearman version => 0.40  
wow...安装成功。
就是这么简单

 

Tags: ubuntu, gearman, php扩展