【centos 7】搭FTP服务和web访问

步骤:安装 vsftpd-->增加用户-->配置vsftpd和用户权限 -->配置iptables

安装httpd,开放http访问 /var/tmp/user1下目录

1、安装和用户、权限配置

yum install vsftpd

useradd -d /var/tmp/user1 -s /sbin/nologin user1
useradd -d /var/tmp/user2  user2

passwd user1

passwd user2 

------------------
usermod -s /sbin/nologin user1   #禁止user1 登录到系统,如果直接使用useradd 不加 -s,用此命令限制登录;

配置不同用户的权限(配置/etc/vsftpd/vsftpd.conf 和 /etc/vsftpd.chroot_list )

user1--只能在自己目录下访问,不允许访问父级目录

user2--允许切换到其他目录

vim /etc/vsftpd/vsftpd.conf

chroot_local_user=YES
chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd/chroot_list
chroot_list_file=/etc/vsftpd.chroot_list

listen_port=XXXX  #默认21端口,改为其他端口较安全;
----------------------------
vim /etc/vsftpd.chroot_list

user2

 配置iptables,增加开放 配置的XXXX端口

vim /etc/sysconfig/iptables 

-A INPUT -p tcp -m state --state NEW -m tcp --dport XXXX -j ACCEPT

2、安装httpd服务

yum install httpd


vim /etc/httpd/conf/httpd.conf

-------------------------------
<VirtualHost *:XXX2>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/tmp/user1/
    DirectoryIndex index.php
     <Directory />
        Options FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
        Satisfy all
        </Directory>
</VirtualHost>

授权,可通过web访问

# 很重要,允许web访问
chomd 755 /var/tmp/user1

最后,启动/重启各服务,使配置生效。

service httpd start

service vsftpd start

service iptables restart

附,参考:

【FTP】

FTP搭建完全教程: https://www.howtoing.com/install-ftp-server-in-centos-7/

http://yunkus.com/centos7-ftp-service-install-config/

vsftpd配置文件详解http://yuanbin.blog.51cto.com/363003/108262

 【HTTP配置】

CentOS下web服务安装配置 :http://www.centoscn.com/CentosSecurity/CentosSafe/2014/0914/3745.html

原文地址:https://www.cnblogs.com/mousean/p/6950783.html