Home Database Mysql Tutorial Gentoo安装配置pure-ftpd结合Mysql权限验证全过程_MySQL

Gentoo安装配置pure-ftpd结合Mysql权限验证全过程_MySQL

Jun 01, 2016 pm 01:36 PM
Server

bitsCN.com

Gentoo安装配置pure-ftpd结合Mysql权限验证全过程

 

一、安装pure-ftpd服务端

# echo 'net-ftp/pure-ftpd mysql'>>/etc/portage/package.use

Gentoo会自动把本机的mysql装上。

# emerge pure-ftpd

配置mysql数据库root的密码,以及安装初始化目录。 

我配置的root密码为root,如果设置为其它的则下面的密码也需要跟着改

# ebuild /var/db/pkg/dev-db/mysql-5.5.28/mysql-5.5.28.ebuild config

把client这个段的内容修改成如下 ,这是为了方便我们进入mysql数据库

# vim /etc/mysql/my.cnf

[client]

user            = root

password        = root

host            = 127.0.0.1

port            = 3306

socket          = /var/run/mysqld/mysqld.sock

 

[mysqld]

server-id                                       = 220

skip-name-resolve

# /etc/init.d/mysql start

 

二、在Mysql中创建相应的库和表来存储用户权限

   www.bitsCN.com  

# mysql –A (之前配置my.cnf里的用户和密码就是为了这儿)

mysql> CREATE DATABASE IF NOT EXISTS pureftpd;

mysql> USE pureftpd;

mysql>

CREATE TABLE IF NOT EXISTS `ftpd` (

  `User` varchar(16) NOT NULL DEFAULT '' COMMENT '用户名',

  `status` enum('0','1') NOT NULL DEFAULT '0' COMMENT '可用状态:0 - 不可用;1 - 正在使用',

  `Password` varchar(64) NOT NULL DEFAULT '' COMMENT '密码',

  `Uid` varchar(11) NOT NULL DEFAULT '-1' COMMENT '用户ID',

  `Gid` varchar(11) NOT NULL DEFAULT '-1' COMMENT '组ID',

  `Dir` varchar(128) NOT NULL DEFAULT '' COMMENT '拥有的权限路径',

  `ULBandwidth` smallint(5) NOT NULL DEFAULT '0' COMMENT '上传带宽',

  `DLBandwidth` smallint(5) NOT NULL DEFAULT '0' COMMENT '下载带宽',

  `comment` tinytext NOT NULL COMMENT '备注',

  `ipaccess` varchar(15) NOT NULL DEFAULT '*' COMMENT 'IP地址',

  `QuotaSize` smallint(5) NOT NULL DEFAULT '0' COMMENT '大小配额',

  `QuotaFiles` int(11) NOT NULL DEFAULT '0' COMMENT '文件类型配额',

  PRIMARY KEY (`User`)

) ENGINE=MyISAM DEFAULT CHARSET=gbk COMMENT='ftp用户名密码表';

mysql > 添加用户ftpduser让它对pureftpd下面的库有select权限

grant select on pureftpd.* to ftpduser@'%' identified by 'ftpdpassword';

mysql > 添加一条测试数据,等会儿用来登录

INSERT INTO `ftpd` (`User`, `status`, `Password`, `Uid`, `Gid`, `Dir`, `ULBandwidth`, `DLBandwidth`, `comment`, `ipaccess`, `QuotaSize`, `QuotaFiles`) VALUES ('testuser', '1', md5('testpassword'), '1002', '81', '/var/www', 0, 0, '备注', '*', 0, 0);

 

三、修改配置文件,使用MYSQL进行权限验证

 

# vim /etc/conf.d/pure-ftpd

IS_CONFIGURED="yes"

SERVER="-S 10.36.32.220,21"

MAX_CONN="-c 50"

MAX_CONN_IP="-C 20"

AUTH="-l mysql:/etc/pureftpd-mysql.conf"

MISC_OTHER="-A -H -x -j -R -Z -E -p 50001:59999 -O clf:/var/log/pureftpd/pureftpd.log"

# mkdir –p /var/log/pureftpd/

 

这里的MYSQL配置与我们PHP连接MYSQL雷同,需要注意的是MYSQLCrypt 这是指的咱们对用户密码的加密方式。

# vim /etc/pureftpd-mysql.conf

MYSQLServer 127.0.0.1

MYSQLPort 3306

MYSQLUser ftpduser

MYSQLPassword ftpdpassword

MYSQLDatabase pureftpd

MYSQLCrypt md5

MYSQLGetPW SELECT Password FROM ftpd WHERE User="/L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "/R")

MYSQLGetUID SELECT Uid FROM ftpd WHERE User="/L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "/R")

MYSQLGetGID SELECT Gid FROM ftpd WHERE User="/L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "/R")

MYSQLGetDir SELECT Dir FROM ftpd WHERE User="/L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "/R")

MySQLGetBandwidthUL SELECT ULBandwidth FROM ftpd WHERE User="/L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "/R")

MySQLGetBandwidthDL SELECT DLBandwidth FROM ftpd WHERE User="/L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "/R")

MySQLGetQTASZ SELECT QuotaSize FROM ftpd WHERE User="/L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "/R")

MySQLGetQTAFS SELECT QuotaFiles FROM ftpd WHERE User="/L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "/R")

 

四、添加nfsuser用户,并修改web目录的权限,如果没有就先创建吧

# groupadd apache; useradd nfsuser -u 1002 -g apache -d /dev/null -s /sbin/nologin

# mkdir -p /var/www

# chown -R nfsuser:apache /var/www

 

五、启动pureftpd并用客户端连接测试

# /etc/init.d/pure-ftpd start

 

bitsCN.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Reduce the use of MySQL memory in Docker Reduce the use of MySQL memory in Docker Mar 04, 2025 pm 03:52 PM

This article explores optimizing MySQL memory usage in Docker. It discusses monitoring techniques (Docker stats, Performance Schema, external tools) and configuration strategies. These include Docker memory limits, swapping, and cgroups, alongside

How to solve the problem of mysql cannot open shared library How to solve the problem of mysql cannot open shared library Mar 04, 2025 pm 04:01 PM

This article addresses MySQL's "unable to open shared library" error. The issue stems from MySQL's inability to locate necessary shared libraries (.so/.dll files). Solutions involve verifying library installation via the system's package m

How do you alter a table in MySQL using the ALTER TABLE statement? How do you alter a table in MySQL using the ALTER TABLE statement? Mar 19, 2025 pm 03:51 PM

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

Run MySQl in Linux (with/without podman container with phpmyadmin) Run MySQl in Linux (with/without podman container with phpmyadmin) Mar 04, 2025 pm 03:54 PM

This article compares installing MySQL on Linux directly versus using Podman containers, with/without phpMyAdmin. It details installation steps for each method, emphasizing Podman's advantages in isolation, portability, and reproducibility, but also

What is SQLite? Comprehensive overview What is SQLite? Comprehensive overview Mar 04, 2025 pm 03:55 PM

This article provides a comprehensive overview of SQLite, a self-contained, serverless relational database. It details SQLite's advantages (simplicity, portability, ease of use) and disadvantages (concurrency limitations, scalability challenges). C

Running multiple MySQL versions on MacOS: A step-by-step guide Running multiple MySQL versions on MacOS: A step-by-step guide Mar 04, 2025 pm 03:49 PM

This guide demonstrates installing and managing multiple MySQL versions on macOS using Homebrew. It emphasizes using Homebrew to isolate installations, preventing conflicts. The article details installation, starting/stopping services, and best pra

How do I configure SSL/TLS encryption for MySQL connections? How do I configure SSL/TLS encryption for MySQL connections? Mar 18, 2025 pm 12:01 PM

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? Mar 21, 2025 pm 06:28 PM

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

See all articles