CenOS 下安装FTP和apache血泪史

CenOS 下安装FTP和apache血泪史 安装了一天半 浪费无数时间
硬件环境:
Cenos 6.5
一 安装ftp
1. yum -y install vsftpd
2. chkconfig vsftpd on 设置开机启动vsftpd ftp服务
二 配置防火墙
2. vi /etc/sysconfig/iptables
3. 加入-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 21 -j ACCEPT
4. 保存和关闭文件,重启防火墙 service iptables start
三 配置vsftpd服务器

  1. vi /etc/vsftpd/vsftpd.conf
    这里写图片描述
    比较详细的说明
    http://yangzexin07.blog.51cto.com/767128/227899
    主要改动点
  2. chroot_list_enable=YES
  3. chroot_list_file=/etc/vsftpd/chroot_list
  4. 加入 pam_service_name=vsftpd
    四 增加用户

  5. useradd -d /home/wwwroot/ftpuser -g ftp -s /sbin/nologin ftpuser /home/wwwroot/ftpuser为你定义的目录

  6. 设置用户口令 passwd ftpuser
  7. 编辑文件chroot_list 加入用户ftpuser
    五 目录授权

  8. 提升目录权限 chmod 777 /home/wwwroot/ftpuser -R

  9. 将目录分配给ftp组的ftpuser用户 chown xxx:ftp /home/wwwroot/ftpuser 若不成功直接修改/etc/passwd ftptest:x:501:50::/home/wwwroot/ftpuser:/sbin/nologin

    * 六 启动ftp*

  10. service vsftpd restart 重启 restart可以改为start stop

以上是正常流程 不过过程中会遇到很多问题
问题一
linux–解决登录vsftpd后无法使用dir和切换目录的方法
查看selinux是否打开ftp支持
getsebool -a|grep ftp
如果出现

SELinux is disabled
如果需要重新开启selinux,请按下面步骤:
vi /etc/selinux/config
更改为:SELINUX=1
必须重启linux,不重启是没办法立刻开启selinux的
开启目录查看和文件上传
setsebool -P ftpd_disable_trans 1 或 setsebool -P ftp_home_dir 1
setsebool -P allow_ftpd_full_access 1
然后重启服务器

问题二
vsftpd 530 Permission denied
使用在vsftpd.conf中添加userlist_*阻止特定的本地用户
userlist_enable=YES
userlist_deny=YES
userlist_file=/etc/vsftpd/user_list
编辑/etc/vsftpd/user_list ,添加上需要阻止的本地用户,一个用户名一行 用被阻止的用户登录FTP显示的消息为:530 Permission denied
我本机的etc/vsftpd/vsftpd.conf文件里,只有userlist_enable=YES 于是用root用户登录报错530 Permission denied 把YES改成NO就OK了
还有一种情况,就是没有指定 userlist_file文件位置。解决:加上userlist_file=/etc/vsftpd/user_list

问题三
530 Login incorrect
只有用匿名anonymous才可登录,其余所有用户都报530 Login incorrect错
local_enable=YES
write_enable=YES
pam_service_name=vsftpd
userlist_enable=YES
加入这句话就OK啦.现在原因还不知道.

其他的解决思路:1、被动模式的问题
2、有时候可能是主目录的问题,比如你的FTP主目录是/data/www,但是用户vsftpd的在/etc/passwd不是这个目录也会出问题,记住查看日志。

centos 卸载vsftpd方法

如果服务器上安装了vsftpd,配置出错需要卸载vsftpd

[root@localhost ~]# rpm -aq vsftpd

vsftpd-2.0.5-16.el5_5.1 #此处是查找vsftpd的返回结果

[root@localhost ~]# rpm -e vsftpd-2.0.5-16.el5_5.1
warning: /etc/vsftpd/user_list saved as /etc/vsftpd/user_list.rpmsave
warning: /etc/vsftpd/ftpusers saved as /etc/vsftpd/ftpusers.rpmsave #删除时将备份vsftp的用户列表文件。

看下是否卸载了vsftpd,进行stop及start操作:

[root@localhost ~]# /sbin/service vsftpd stop

vsftpd: unrecognized service #找不到vsftpd

[root@localhost ~]# /sbin/service vsftpd start

vsftpd: unrecognized service #找不到vsftpd记住,在卸载vsftpd之前,先停止vsftpd。

安装apache
安装apache 然后把apache的默认读取目录修改为ftp的上传目录
首先在系统上面查询一下是否已经安装了apache 软件
rpm -qa httpd
安装
yum install httpd -y

chkconfig httpd on 开机启动
service httpd start 启动软件
现在,您的浏览器到http://IP,你应该看到Apache2的测试页:
Apache的默认文档根目录是在CentOS上的/var/www/html 目录 ,配置文件是/etc/httpd/conf/httpd.conf。配置存储在的/etc/httpd/conf.d/目录
我们修改apache的默认文档目录
vi /etc/httpd/conf/httpd.conf

找到DocumentRoot 改目录为你设置的目录
配置很多 就不多说了
最后的结果就是 通过http://ip+文件目录 就可以实现对上传文件的访问

相关问题博客URL:
http://yangzexin07.blog.51cto.com/767128/227899

http://blog.itpub.net/16797271/viewspace-616673/

http://www.zjgsq.com/1509.html

http://blog.sina.com.cn/s/blog_a7cf995a0101azak.html

http://blog.chinaunix.net/uid-20804677-id-457317.html

http://blog.youkuaiyun.com/shutfuckingup/article/details/8250290

http://blog.youkuaiyun.com/gaojiewang/article/details/7368751
http://yangzexin07.blog.51cto.com/767128/227899
http://www.linuxidc.com/Linux/2014-03/98886.htm
http://blog.itpub.net/16797271/viewspace-616673/
http://www.cnsecer.com/179.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值