GNU/Linux >> Linux の 問題 >  >> Ubuntu

Ubuntu 14.04LTSでのProftpdとMySQL(クォータを含む)を使用した仮想ホスティング

このドキュメントでは、実際のシステムユーザーの代わりにMySQLデータベースの仮想ユーザーを使用するProftpdサーバーをインストールする方法について説明します。これははるかにパフォーマンスが高く、1台のマシンに数千人のftpユーザーを配置できます。それに加えて、この設定でのクォータの使用法を示します。このチュートリアルはUbuntu14.04LTSに基づいています。

MySQLデータベースの管理には、このハウツーにもインストールされるphpMyAdminなどのWebベースのツールを使用できます。 phpMyAdminは快適なグラフィカルインターフェイスであるため、コマンドラインをいじくり回す必要はありません。

このハウツーは実用的なガイドとして意図されています。理論的背景については説明していません。それらは、Webの他の多くのドキュメントで扱われます。

このドキュメントには、いかなる種類の保証もありません。このようなシステムを構築する方法はこれだけではありません。この目標を達成する方法はたくさんありますが、これが私のやり方です。これがあなたのために働くという保証はありません!

1予備メモ

このチュートリアルでは、ホスト名server1.example.comとIPアドレス192.168.0.100を使用します。これらの設定は異なる場合があるため、必要に応じて置き換える必要があります。

rootとしてログインしていることを確認してください:

sudo su

1.1デフォルトシェルの変更

/ bin/shは/bin/ dashへのシンボリックリンクですが、/ bin/dashではなく/bin/bashが必要です。したがって、これを行います:

dpkg-ダッシュの再構成

dashを/bin/ shとしてインストールしますか? <-いいえ

1.2AppArmorを無効にする

AppArmorは、拡張セキュリティを提供するセキュリティ拡張機能(SELinuxと同様)です。私の意見では、安全なシステムを構成するためにそれを必要とせず、通常、利点よりも多くの問題を引き起こします(一部のサービスが期待どおりに機能しなかったため、1週間のトラブルシューティングを行った後、それを考えてください。すべてが問題ないことを確認してください。AppArmorだけが問題を引き起こしていました)。したがって、無効にします。

次のように無効にできます:

/etc/init.d/apparmor stop
update-rc.d -f apparmor remove
apt-get remove apparmor apparmor-utils

2MySQLとphpMyAdminをインストールします

これはすべて、1つのコマンドでインストールできます:

apt-get install mysql-server mysql-client phpmyadmin apache2

MySQLルートユーザーのパスワードを入力するように求められます。このパスワードは[メール保護]ユーザーと[メール保護]ユーザーに有効であるため、後でMySQLルートパスワードを手動で指定する必要はありません。

MySQLの「root」ユーザーの新しいパスワード:<-yourrootsqlpassword
MySQLの「root」ユーザーのパスワードを繰り返します:<-yourrootsqlpassword

これに加えて、次の質問が表示されます。

自動的に再構成するWebサーバー:<-apache2
dbconfig-commonを使用してphpmyadminのデータベースを構成しますか? <-いいえ

3MySQLサポートを使用してProftpdをインストールする

Ubuntuの場合、事前構成されたproftpd-mod-mysqlパッケージが利用可能です。次のようなスタンドアロンデーモンとしてインストールします:

apt-get install proftpd-mod-mysql

次の質問があります:

proftpdを実行します:<-スタンドアロン

次に、すべての仮想ユーザーがマップされるftpグループ(ftpgroup)とユーザー(ftpuser)を作成します。グループIDとユーザーID2001を、システムで無料の番号に置き換えます。

groupadd -g 2001 ftpgroup
useradd -u 2001 -s / bin / false -d / bin / null -c "p​​roftpd user" -g ftpgroup ftpuser

4Proftpd用のMySQLデータベースを作成する

次に、ftpという名前のデータベースとproftpdという名前のMySQLユーザーを作成します。このユーザーは、後でproftpdデーモンがftpデータベースに接続するために使用します。

mysql -u root -p

CREATE DATABASE ftp;
GRANT SELECT、INSERT、UPDATE、DELETEONftp。*TO'proftpd'@'localhost' IDENTIFIED BY'password';
GRANT SELECT、INSERT、UPDATE、DELETEONftp。* TO'proftpd' @'localhost.localdomain' IDENTIFIED BY'password';
FLUSH PRIVILEGES;

文字列passwordを、MySQLユーザーproftpdに使用するパスワードに置き換えます。引き続きMySQLシェルで、必要なデータベーステーブルを作成します。

FTPを使用します;

CREATE TABLE ftpgroup(
groupname varchar(16)NOT NULL default''、
gid smallint(6)NOT NULL default '5500'、
members varchar(16)NOT NULL default''、
KEY groupname(groupname)
)ENGINE =MyISAM COMMENT ='ProFTP group table';

CREATE TABLE ftpquotalimits(
name varchar(30)default NULL、
quote_type enum('user'、'group'、'class'、'all')NOT NULL default'user'、
per_session enum('false'、'true')NOT NULL default'false'、
limit_type enum('soft'、'hard')NOT NULL default'soft'、
bytes_in_avail bigint(20)unsigned NOT NULL default '0'、
bytes_out_avail bigint(20)unsigned NOT NULL default '0'、
bytes_xfer_avail bigint(20)unsigned NOT NULL default '0'、
files_in_avail int(10) unsigned NOT NULL default '0'、
files_out_avail int(10)unsigned NOT NULL default '0'、
files_xfer_avail int(10)unsigned NOT NULL default '0'
)ENGINE =MyISAM;

CREATE TABLE ftpquotatallies(
name varchar(30)NOT NULL default''、
quote_type enum('user'、'group'、'class'、'all')NOT NULL default'user'、
bytes_in_used bigint(20)unsigned NOT NULL default '0'、
bytes_out_used bigint(20)unsigned NOT NULL default '0'、
bytes_xfer_used bigint(20)unsigned NOT NULL default '0'、
files_in_used int(10)unsigned NOT NULL default '0'、
files_out_used int(10)unsigned NOT NULL default '0'、
files_xfer_used int(10)unsigned NOT NULL default '0'
)ENGINE =MyISAM;

CREATE TABLE ftpuser(
id int(10)unsigned NOT NULL auto_increment、
userid varchar(32)NOT NULL default''、
passwd varchar(32)NOT NULL default''、
uid smallint(6)NOT NULL default '5500'、
gid smallint(6)NOT NULL default '5500'、
homedir varchar(255)NOT NULL default''、
shell varchar(16)NOTNULLデフォルト'/ sbin / nologin'、
count int(11)NOTNULLデフォルト'0'、
アクセス日時NOTNULLデフォルト'0000-00-00 00:00:00 '、
変更された日時NOTNULLデフォルト'0000-00-00 00:00:00'、
PRIMARY KEY(id)、
UNIQUE KEY userid(userid)
)ENGINE =MyISAM COMMENT='ProFTPユーザーテーブル';

やめる;

お気づきかもしれませんが、やめます。コマンドMySQLシェルを終了し、Linuxシェルに戻りました。

ところで、(ftpサーバーシステムのホスト名はserver1.example.comであると想定しています)http://server1.example.com/phpmyadmin/でphpMyAdminにアクセスできます(server1の代わりにIPアドレスを使用できます。 example.com)をブラウザに表示し、proftpdとしてログインします。次に、データベースを確認できます。後で、phpMyAdminを使用してProftpdサーバーを管理できます。

5Proftpdを構成する

/etc/proftpd/modules.confを開きます...

vi /etc/proftpd/modules.conf

...そして次の3つのモジュールを有効にします:

[...]
# Install one of proftpd-mod-mysql, proftpd-mod-pgsql or any other
# SQL backend engine to use this module and the required backend.
# This module must be mandatory loaded before anyone of
# the existent SQL backeds.
LoadModule mod_sql.c [...] # Install proftpd-mod-mysql and decomment the previous
# mod_sql.c module to use this.
LoadModule mod_sql_mysql.c [...] # Install one of the previous SQL backends and decomment
# the previous mod_sql.c module to use this
LoadModule mod_quotatab_sql.c [...]

次に、/ etc / proftpd / proftpd.confを開き、次の行をコメントアウトします。

vi /etc/proftpd/proftpd.conf

[...]
#<IfModule mod_quotatab.c>
#QuotaEngine off
#</IfModule>
[...]

ファイルのさらに下に、次の行を追加します。

[...]
#
# Alternative authentication frameworks
#
#Include /etc/proftpd/ldap.conf
#Include /etc/proftpd/sql.conf

DefaultRoot ~

SQLBackend              mysql
# The passwords in MySQL are encrypted using CRYPT
SQLAuthTypes            Plaintext Crypt
SQLAuthenticate         users groups


# used to connect to the database
# [email protected] database_user user_password
SQLConnectInfo  [email protected] proftpd password


# Here we tell ProFTPd the names of the database columns in the "usertable"
# we want it to interact with. Match the names with those in the db
SQLUserInfo     ftpuser userid passwd uid gid homedir shell

# Here we tell ProFTPd the names of the database columns in the "grouptable"
# we want it to interact with. Again the names match with those in the db
SQLGroupInfo    ftpgroup groupname gid members

# set min UID and GID - otherwise these are 999 each
SQLMinID        500

# create a user's home directory on demand if it doesn't exist
CreateHome on

# Update count every time user logs in
SQLLog PASS updatecount
SQLNamedQuery updatecount UPDATE "count=count+1, accessed=now() WHERE userid='%u'" ftpuser

# Update modified everytime user uploads or deletes a file
SQLLog  STOR,DELE modified
SQLNamedQuery modified UPDATE "modified=now() WHERE userid='%u'" ftpuser

# User quotas
# ===========
QuotaEngine on
QuotaDirectoryTally on
QuotaDisplayUnits Mb
QuotaShowQuotas on

SQLNamedQuery get-quota-limit SELECT "name, quota_type, per_session, limit_type, bytes_in_avail, bytes_out_avail, bytes_xfer_avail, files_in_avail, files_out_avail, files_xfer_avail FROM ftpquotalimits WHERE name = '%{0}' AND quota_type = '%{1}'"

SQLNamedQuery get-quota-tally SELECT "name, quota_type, bytes_in_used, bytes_out_used, bytes_xfer_used, files_in_used, files_out_used, files_xfer_used FROM ftpquotatallies WHERE name = '%{0}' AND quota_type = '%{1}'"

SQLNamedQuery update-quota-tally UPDATE "bytes_in_used = bytes_in_used + %{0}, bytes_out_used = bytes_out_used + %{1}, bytes_xfer_used = bytes_xfer_used + %{2}, files_in_used = files_in_used + %{3}, files_out_used = files_out_used + %{4}, files_xfer_used = files_xfer_used + %{5} WHERE name = '%{6}' AND quota_type = '%{7}'" ftpquotatallies

SQLNamedQuery insert-quota-tally INSERT "%{0}, %{1}, %{2}, %{3}, %{4}, %{5}, %{6}, %{7}" ftpquotatallies

QuotaLimitTable sql:/get-quota-limit
QuotaTallyTable sql:/get-quota-tally/update-quota-tally/insert-quota-tally

RootLogin off
RequireValidShell off
[...]

SQLConnectInfo!

の行で、文字列パスワードをMySQLユーザーproftpdの実際のパスワードに置き換えてください。

次に、Proftpdを再起動します:

/etc/init.d/proftpd restart


Ubuntu
  1. Postfix、Courier、MySQL、SquirrelMailを使用した仮想ユーザーとドメイン(Ubuntu 14.04LTS)

  2. PHP5(PHP-FPM)とMySQLサポートを備えたLighttpdをUbuntu14.04LTSにインストールする

  3. Postfix、Courier、MySQL、SquirrelMailを使用した仮想ユーザーとドメイン(Ubuntu 13.10)

  1. CentOS 7.0でのPureFTPdとMySQL(クォータと帯域幅の管理を含む)を使用した仮想ホスティング

  2. Ubuntu 7.10(Gutsy Gibbon)でのPureFTPdとMySQL(クォータと帯域幅の管理を含む)を使用した仮想ホスティング

  3. Ubuntu 8.04 LTSでのProftpdとMySQL(クォータを含む)を使用した仮想ホスティング

  1. Ubuntu 8.10(Intrepid Ibex)でのPureFTPdとMySQL(クォータと帯域幅の管理を含む)を使用した仮想ホスティング

  2. Ubuntu 8.10でのProftpdとMySQL(クォータを含む)を使用した仮想ホスティング

  3. Ubuntu 9.04(Jaunty Jackalope)でのPureFTPdとMySQL(クォータと帯域幅の管理を含む)を使用した仮想ホスティング