4.配置ftp服务器-linux

admin2013-07-29教程82

windows使用和centos使用对比

############################## 4-2.配置ftp服务器-centos CentOS 源码编译安装Pure-FTPd http://py.10isp.com/843 1、找到最新版本的PureFTPd 去网站http://download.pureftpd.org/pub/pure-ftpd/releases/ 我们找到最新版本的的下载链接是http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.36.tar.gz。 2、下载并安装 cd /usr/local/src wget http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.36.tar.gz tar -zxvf pure-ftpd-1.0.36.tar.gz cd pure-ftpd-1.0.36 ./configure //checking for gcc... no  //需要gcc环境 yum install -y gcc* make //-bash: make: command not found //安装make工具包yum install -y make make check make install 如需了解configure的更多选项请看http://download.pureftpd.org/pub/pure-ftpd/doc/README 软件已经被安装到 /usr/local/sbin/pure-ftpd,我们只需执行以下代码即可启动PureFTPd。 /usr/local/sbin/pure-ftpd & 3、开机启动PureFTPd cp contrib/redhat.init /etc/init.d/pure-ftpd chmod 755 /etc/init.d/pure-ftpd chkconfig --add pure-ftpd chkconfig --level 3 pure-ftpd on 4、配置文件 cp configuration-file/pure-ftpd.conf /etc cp configuration-file/pure-config.pl /usr/local/sbin/pure-config.pl chmod 744 /etc/pure-ftpd.conf chmod 755 /usr/local/sbin/pure-config.pl 现在编辑配置文件。 vi /etc/pure-ftpd.conf 设置成以下值。 UnixAuthentication yes #MinUID 100 //UnixAuthentication yes表示系统用户可以登录FTP。 //MinUID 100表示用户的ID大于100才能登录,我们注释掉它,任何的用户ID都能登录了。 使用root用户做测试 5、启动和停止PureFTPd service pure-ftpd stop service pure-ftpd start service pure-ftpd status netstat -anlp | grep pure-ftpd //查看ftp端口是否有监听 tcp        0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN      8095/pure-ftpd (SER iptables里添加21端口的允许 vi /etc/sysconfig/iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 20100:20500 -j ACCEPT 编辑防火墙配置 /etc/init.d/iptables restart 重启防火墙 21管理端口连接上后会去连接一个随机的数据传输端口需要另外配置 手动自定义下数据端口 PassivePortRange            20100 20500 (此处如果设置的太少会导致用户连接时连接数太少) ### WinSock 2.0 -- OpenSSL 0.9.8i 15 Sep 2008 [正在连接到 192.168.0.219 -> IP=192.168.0.219 PORT=21 [已连接到 192.168.0.219 [] 220---------- Welcome to Pure-FTPd [privsep] ---------- [] 220-You are user number 1 of 50 allowed. [] 220-Local time is now 11:38. Server port: 21. [] 220-IPv6 connections are also welcome on this server. [] 220 You will be disconnected after 15 minutes of inactivity. ... [] 257 "/root" is your current location [] TYPE A [] 200 TYPE is now ASCII [] PASV [] 227 Entering Passive Mode (192,168,0,219,7,27) [正在打开数据连接 IP: 192.168.0.219 端口: 1819 [数据 Socket 错误连接超时 [列表错误 [] PASV [] 227 Entering Passive Mode (192,168,0,219,251,98) [正在打开数据连接 IP: 192.168.0.219 端口: 64354 [数据 Socket 错误连接超时 [列表错误 [] PASV 模式失败尝试 PORT  模式。 [监听端口: 52759, 等待连接。 [] PORT 192,168,0,212,206,23 [] 200 PORT command successful [] MLSD [] 150 Connecting to port 52759 [] 226-Options: -a -l  [] 226 11 matches total [列表完成: 1 KB 于 0.02 秒 (76.3 KB/) [] PORT  模式成功请更新你的站点配置文件。 ###   成功后的连接信息 ### [正在连接到 192.168.0.219 -> IP=192.168.0.219 PORT=21 [已连接到 192.168.0.219 [] 220---------- Welcome to Pure-FTPd [privsep] ---------- [] 220-You are user number 1 of 50 allowed. [] 220-Local time is now 11:45. Server port: 21. [] 220-IPv6 connections are also welcome on this server. [] 220 You will be disconnected after 15 minutes of inactivity. [] USER root [] 331 User root OK. Password required [] PASS (隐藏) [] 230 OK. Current directory is /root ... [] 257 "/root" is your current location [] CWD / [] 250 OK. Current directory is / [] PWD [] 257 "/" is your current location [] CWD boot [] 250 OK. Current directory is /boot [] PWD [] 257 "/boot" is your current location [] TYPE A [] 200 TYPE is now ASCII [] PASV [] 227 Entering Passive Mode (192,168,0,219,79,88) [正在打开数据连接 IP: 192.168.0.219 端口: 20312 [] MLSD [] 150 Accepted data connection [] 226-Options: -a -l  [] 226 11 matches total [列表完成: 1 KB 于 0.06 秒 (19.3 KB/)   ###   //新建用户同时增加工作组 groupadd pureftpd //新建pureftpd 组 adduser phpq //新建phpq用户 passwd phpq //给phpq用户设置密码 注::-g 所属组 -d 家目录 -s 所用的SHELL //