gpgkey=http://repo.mysql.com/RPM-GPG-KEY-mysql
2)安装数据库相关包
yum install -y mysql-community-server mysql-community-devel mysql-community-client 3.1.4 安装相关包
yum install -y vsftpd pam-devel httpd 3.1.5 下载pam模块(可选,编译安装才需要)
wget http://prdownloads.sourceforge.net/pam-mysql/pam_mysql-0.7RC1.tar.gz 3.1.6 开启防火墙端口 In CentOS 6:
vim /etc/sysconfig/iptables 加入如下行:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 50000:60000 -j ACCEPT
重启防火墙服务:
/etc/init.d/iptables restart In CentOS 7:
firewall-cmd --permanent --add-service ftp
firewall-cmd --permanent --add-port 50000-60000/tcp
firewall-cmd --reload
firewall-cmd --list-all 3.1.7 关闭selinux
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config 3.2 安装pam模块 3.2.1 yum方式安装 In CentOS 6:
yum install -y http://dl.fedoraproject.org/pub/epel/6/i386/pam_mysql-0.7-0.12.rc1.el6.i686.rpm 注:下载页面,
http://dl.fedoraproject.org/pub/epel/6/i386/ In CentOS 7:
yum install -y ftp://ftp.pbone.net/mirror/archive.fedoraproject.org/fedora/linux/releases/20/Everything/x86_64/os/Packages/p/pam_mysql-0.7-0.16.rc1.fc20.x86_64.rpm 注:下载页面,
http://rpm.pbone.net/index.php3/stat/4/idpl/25165183/dir/fedora_20/com/pam_mysql-0.7-0.16.rc1.fc20.x86_64.rpm.html 3.2.2 编译安装方式(可选,编译安装才需要)
1)解压安装包
tar -xf pam_mysql-0.7RC1.tar.gz 2)编译并安装
cd pam_mysql-0.7RC1
./configure --with-mysql=/usr/bin/mysql_config
make && make install
如果提示错误以下错误:
configure: error: Your system doesn't appear to be configured to use PAM. Perhaps you need to specify the correct location where the PAM modules reside. 可增加参数解决:
./configure --with-mysql=/usr/bin/mysql_config --with-pam-mods-dir=/usr/lib64/security 3.3 配置数据库 3.3.1 启动服务并配置自动启动 In CentOS 6:
/etc/init.d/mysqld start
chkconfig mysqld on In CentOS 7:
systemctl start mysqld
systemctl enable mysqld 3.3.2 初始化数据库
mysql_secure_installation 向导如下:
[...]
Enter current password for root (enter for none):
OK, successfully used password, moving on...
[...]
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
[...]
Remove anonymous users? [Y/n] y
... Success!
[...]
Disallow root login remotely? [Y/n] n
... skipping.
[...]
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
[...]
Reload privilege tables now? [Y/n] y
... Success!
[...] 3.3.3 创建验证数据库
mysql -uroot -p
create database vsftpd; 3.3.4 创建验证数据表
use vsftpd;
create table users (
id int auto_increment not null,
name char(20) not null unique key,
passwd char(48) not null,
primary key(id)
); 3.3.5 添加测试数据
insert into vsftpd.users(name,passwd) values ('test1',password('123456')); 查询数据库中的账号:
select * from vsftpd.users; 3.3.6 配置验证账号
grant select on vsftpd.* to vsftpd@localhost identified by 'abc123';
grant select on vsftpd.* to vsftpd@127.0.0.1 identified by 'abc123';
flush privileges; 3.3.7 测试验证账号
mysql -uvsftpd -pabc123 3.4 配置vsftp 3.4.1 备份配置文件
cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.defalut
vim /etc/vsftpd/vsftpd.conf
输入如下配置:
listen=YES
anonymous_enable=NO