在Arch Linux上安装Proftpd,使用mysql存储Proftpd用户

作者:admin 发布于:2012-3-20 16:20 Tuesday 分类:FTP

这是一片安装Proftpd服务器,并且将用户存储在mysql数据库里的教程。这使得成千上万的人能够使用这个FTP服务。

我们可以说phpMyAdmin来管理mysql,从而来管理FTP用户。

这篇文章基于Arch Linux,你应该在你的本地也已经有了一台这样的服务器。

我们认为你已经在Arch Linux配置好LAMP环境,如果你还没有配置好,可以参考这篇文章:https://wiki.archlinux.org/index.php/Apache,https://wiki.archlinux.org/index.php/Phpmyadmin

 

1,安装Proftpd,并使mysql支持它!

pacman -S proftpd

groupadd -g 2001 ftpgroup
useradd -u 2001 -s /bin/false -d /bin/null -c "proftpd user" -g ftpgroup ftpuser

 

2,为Proftpd创建mysql数据库,SQL语句如下,你可以在phpmyadmin里面输入这些sql语句。

create database ftp;
GRANT SELECT, INSERT, UPDATE, DELETE ON ftp.* TO 'proftpd'@'localhost' IDENTIFIED BY 'password';
GRANT SELECT, INSERT, UPDATE, DELETE ON ftp.* TO 'proftpd'@'localhost.localdomain' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;

CREATE TABLE `ftpgroup` ( `groupname` varchar(16) NOT NULL DEFAULT '',
`gid` smallint(6) NOT NULL DEFAULT '9001',
`members` varchar(16) NOT NULL DEFAULT '',
KEY `groupname` (`groupname`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='ProFTP group table';

CREATE TABLE `ftpquotalimits` ( `name` varchar(30) NOT NULL DEFAULT '',
`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` bigint(10) unsigned NOT NULL DEFAULT '0',
`bytes_out_avail` bigint(10) unsigned NOT NULL DEFAULT '0',
`bytes_xfer_avail` bigint(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', PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `ftpquotatallies` ( `name` varchar(30) NOT NULL DEFAULT '',
`quota_type` enum('user','group','class','all') NOT NULL DEFAULT
'user', `bytes_in_used` bigint(10) unsigned NOT NULL DEFAULT '0',
`bytes_out_used` bigint(10) unsigned NOT NULL DEFAULT '0',
`bytes_xfer_used` bigint(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'
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

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 '9001',
`gid`smallint(6) NOT NULL DEFAULT '9001',
`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',
`email` varchar(64) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `userid` (`userid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='ProFTP user table';

 

3,配置Proftpd

打开/etc/proftpd.conf,然后添加下面的行

DefaultRoot ~

# The passwords in MySQL are encrypted using CRYPT

SQLAuthTypes            Crypt
SQLAuthenticate         users* groups*

# used to connect to the database
# databasename@host database_user user_password
SQLConnectInfo  ftp@localhost proftpd password PERCONNECTION

# 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
CreateHome on 770 dirmode 770

# 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 Gb
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

然后重启Proftpd:/etc/rc.d/proftpd restart

4,测试
INSERT INTO `ftpgroup` (`groupname`, `gid`,
`members`) VALUES ('ftpgroup', 9001, 'ftpuser');

INSERT INTO `ftpquotalimits` (`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`) VALUES
      ('exampleuser', 'user', 'false', 'hard', 1073741824, 0, 0, 0, 0, 0);

  

  INSERT INTO `ftpuser` (`userid`, `passwd`, `uid`, `gid`, `homedir`,
  `shell`, `count`, `accessed`, `modified`, `email`) VALUES
  ('exampleuser', encrypt('secret'), 2001, 2001, '/srv/ftp/exampleuser',
  '/sbin/nologin', 0, '0000-00-00 00:00:00', '0000-00-00 00:00:00',
  'exampleuser@howtoforge.com');

ls -l /srv/ftp
现在你就可以使用刚才我们创建的FTP用户试试啦!

标签: DEFAULT null used files bytes avail Proftpd unsigned quota xfer

评论(0) 引用(0) 浏览(29)

LAMP,在CentOS 6.2 安装apache,php,mysql

作者:admin 发布于:2012-3-17 20:12 Saturday 分类:Web Server -Apache

1,在本教材中,我使用server1.example.com作为域名,192.168.0.100作为IP地址。这个设置可能跟你的实际情况有所不一样,你需要根据你的实际情况来修改。


2,安装mysql5服务器

yum install mysql mysql-server

然后,创建mysql的启动链接使得它能够随系统的启动而启动服务。

chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start

为mysql设置root密码

mysql_secure_installation

 

[root@server1 ~]# mysql_secure_installation




NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!


In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n]
 <-- ENTER
New password: <-- yourrootsqlpassword
Re-enter new password: <-- yourrootsqlpassword
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n]
 <-- ENTER
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n]
 <-- ENTER
 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n]
 <-- ENTER
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n]
 <-- ENTER
 ... Success!

Cleaning up...



All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!


[root@server1 ~]#


4,安装apache2

yum install httpd

使apache随系统一起启动

chkconfig --levels 235 httpd on

启动apache

/etc/init.d/httpd start

用浏览器打开http://192.168.0.100,你可以看到下面的页面了:


5,安装php5

yum install php

重启apache2

/etc/init.d/httpd restart

 

6,测试php5

vi /var/www/html/info.php

输入:<?php phpinfo(); ?>

用浏览器打开http://192.168.0.100/info.php

现在apache已经完全支持php5了。


7,让php5支持mysql5

yum search php

选择你要安装的包,进行安装,比如:
yum install php-mysql php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc

重启apache2

/etc/init.d/httpd restart

现在,程序打开浏览器http://192.168.0.100/info.php,你可以看到如下:


标签: 使用 下面 安装 可以 MySQL LAMP,在CentOS 6.2 安装apache,php

评论(0) 引用(0) 浏览(66)

在Ubuntu 11.10上安装Cherokee,PHP5,MySQL

作者:admin 发布于:2012-3-14 23:13 Wednesday 分类:Web Server -Cherokee

Cherokee是一个配置起来快速、简易、容易上手的web服务器。它支持许多现在流行的技术,比如:FastCGI, SCGI, PHP, CGI, TLS and SSL, 虚拟主机, 认证, 负载均衡, Apache日志文件等等等等。下面是一个在Ubuntu 11.10配置php5(fastcgi)和mysql5环境的教程!

1,我在这里使用的域名是server1.example.com,IP地址是192.168.0.100.这可能跟你的情况不一样,你需要根据你的情况适时修改!

  首先,我们需要拥有root权限。

   sudo su

2,安装mysql5

  apt-get install mysql-server mysql-client 

3,安装Cherokee

  apt-get install cherokee

打开你的浏览器,导航到http://192.168.0.100,你应该可以看到如下的页面:

现在我们可以通过基于web的后台控制器来配置Cherokee咯。

运行命令:cherokee-admin -b

你应该可以看到如下面的输出:

root@server1:~# cherokee-admin -b
[09/12/2011 15:40:31.053] (warning) rrd_tools.c:120 - Could not find the
    rrdtool binary. | A custom rrdtool binary has not been defined, and the
    server could not find one in the $PATH.

Cherokee Web Server 1.2.2 (Jul 12 2011): Listening on port ALL:9090, TLS
disabled, IPv6 enabled, using epoll, 4096 fds system limit, max. 2041
connections, caching I/O, 5 threads, 408 connections per thread, standard
scheduling policy

Login:
  User:              admin
  One-time Password: Qsx6Jqp5TYrbjJBP

Web Interface:
  URL:               http://localhost:9090/

你可以使用上面提供的用户名和一次性密码来登陆Cherkee控制后台,浏览器输入http://192.168.0.100:9090


登陆成功之后,这就是首页的样子:

你可以按 CTRL+C  停止Cherokee的后台控制器!

4,安装php5

apt-get install php5-cgi

5,配置php5

我们需要修改/etc/php5/cgi/php.ini文件,把cgi.fix_pathinfo=1前面的注释去掉:

vi /etc/php5/cgi/php.ini

[...]
; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI.  PHP's
; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
; what PATH_INFO is.  For more information on PATH_INFO, see the cgi specs.  Setting
; this to 1 will cause PHP CGI to fix its paths to conform to the spec.  A setting
; of zero causes PHP to behave as before.  Default is 1.  You should fix your scripts
; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
; http://php.net/cgi.fix-pathinfo
cgi.fix_pathinfo=1
[...] 然后重启Cherokee:/etc/init.d/cherokee restart 6,让Cherohee支持php

cherokee-admin -b 登陆:http://192.168.0.100:9090/

打开Behavior tab页面:

在左边,你现在可以看到当前已经存在的配置规则咯

点击在Behavior右边的“+”符号:

在弹出的窗口中,在左边点击language,然后在右边选择PHP,点击“Add”按钮

在“Configuration Assistant ”窗口,点击“Create”。

你现在应该可以在左边的列中看到php的规则。你可以改变默认的规则。

点击 NON FINAL 完成配置!


这是最终的样子

点击右上角的“SAVE”的链接保存配置。 点击“ Graceful restart ”按钮 现在php应该现在在“Behavior”页面 

CTRL+C退出控制室。

7,测试php5

vi /var/www/info.php  

输入:

<?php
phpinfo();
?> 浏览器打开http://192.168.0.100/info.php


现在可以看到php5已经通过FastCGI正常运行了。

8,使php5支持mysql5

apt-get install php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl

重启cherokee:

 /etc/init.d/cherokee restart

把浏览器打到http://192.168.0.100/info.php

你应该可以看到mysql5咯


 

 

标签: PHP5 在Ubuntu 11.10上安装Cherokee MySQL

评论(0) 引用(0) 浏览(39)

使用“shred”命令,彻底删除硬盘上的数据

作者:admin 发布于:2012-2-21 22:03 Tuesday 分类:Linux -Centos

    有的时候,我们需要彻底的删除硬盘上的数据。简单的“删除”是不够,因为它仅仅删除了指向数据的指针,而不是数据本身。甚至有时候格式化硬盘也是不够的!!

    1,准备

    shred命令可以删除,粉碎硬盘上的文件。你可以通过下面命令查看shred的使用说明

    man shred

    2,使用shred命令

    你可以用下面命令来确定你的系统是否已经安装了shred

    which shred

    如果没有安装的话,你使用下面的命令安装

    apt-get install coreutils

    现在,我们可以使用下面命令来删除一个分区上的全部数据。

    shred -vfz -n 10 /dev/sda5

    删除磁盘列阵上的全部数据

    shred -vfz -n 10 /dev/md1

    删除一块硬盘上的全部数据

    shred -vfz -n 10 /dev/sda

    在使用shred销毁数据的时候,可能会话费比较多的时间。这取决于你电脑的配置咯。

标签: shred 数据 命令 删除 硬盘 使用 下面 全部 安装 可以

评论(0) 引用(0) 浏览(58)

Powered by emlog sitemap