「ProFTPDとMySQLの仮想ホスティング構成」の編集履歴(バックアップ)一覧に戻る
# apt-get install make gcc g++ zlib1g-dev libcdk5-dev # groupadd mysql # useradd -g mysql -d /usr/local mysql # cd /usr/local/src # wget http://downloads.mysql.com/archives/mysql-4.1/mysql-4.1.21.tar.gz # tar zxvf mysql-4.1.21.tar.gz # cd mysql-4.1.21 #/mysql-4.1.21# ./configure \ --with-charset=utf8 \ --with-extra-charsets=all \ --with-mysqld-user=mysql # make
# apt-get install autoconf2.13 # apt-get install automake1.4 # apt-get install libtool # make install # cp support-files/my-small.cnf /etc/my.cnf # /usr/local/bin/mysql_install_db # chmod -R 777 /usr/local/var
# su mysql # /usr/local/bin/mysqld_safe & # /usr/local/bin/mysqladmin -u root password <password> # /usr/local/bin/mysql -u root -p mysql Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 to server version: 4.1.21-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> DELETE FROM user WHERE password=''; Query OK, 3 rows affected (0.00 sec) mysql> select user, host, password from mysql.user; +------+-----------+-------------------------------------------+ | user | host | password | +------+-----------+-------------------------------------------+ | root | localhost | *EX4858XB86EXA20BX33X0AECXE8AX108X56BX7FA | +------+-----------+-------------------------------------------+ 1 row in set (0.00 sec) mysql> exit Bye # exit
# cp /usr/local/src/mysql-4.1.21/support-files/mysql.server \ /etc/init.d/mysql # chmod +x /etc/init.d/mysql # update-rc.d mysql defaults
# apt-get install patch # groupadd proftpd # useradd -g proftpd -d /dev/null -s /usr/sbin/nologin proftpd # cd /usr/local/src # wget ftp://ftp.proftpd.org/distrib/source/proftpd-1.3.0.tar.gz # wget http://www.hakusan.tsg.ne.jp/tjkawa/software/misc/proftpd-iconv/\ pack/proftpd-1.3.0-iconv.patch.gz # wget http://www.hayasoft.com/haya/linux/proftpd-nlst-patch/\ proftpd-1.3.0-nlst-ffftp.patch # tar -zxvf proftpd-1.3.0.tar.gz # gzip -d proftpd-1.3.0-iconv.patch.gz # patch -p0 < proftpd-1.3.0-iconv.patch # patch -p0 < proftpd-1.3.0-nlst-ffftp.patch # cd /usr/local/src/proftpd-1.3.0 # ./configure --prefix=/usr/local \ --with-modules=mod_codeconv:mod_df\ :mod_sql:mod_sql_mysql:mod_quotatab:mod_quotatab_sql \ --with-libraries=/usr/local/lib/mysql \ --with-includes=/usr/local/include/mysql \ --disable-auth-pam # make # make install
# proftpd -l Compiled-in modules: mod_core.c mod_xfer.c mod_auth_unix.c mod_auth_file.c mod_auth.c mod_ls.c mod_log.c mod_site.c mod_delay.c mod_codeconv.c mod_df.c mod_sql.c mod_sql_mysql.c mod_quotatab.c mod_quotatab_sql.c mod_cap.c # mkdir /var/log/proftpd # chown -R proftpd:proftpd /var/log/proftpd/ # vi /etc/init.d/proftpd
#!/bin/sh # Start the proftpd FTP daemon. PATH=/bin:/usr/bin:/sbin:/usr/sbin DAEMON=/usr/sbin/proftpd NAME=proftpd # Defaults RUN="yes" OPTIONS="" PIDFILE=`grep -i 'pidfile' /usr/local/etc/proftpd.conf | \ sed -e 's/pidfile[\t ]\+//i'` if [ "x$PIDFILE" = "x" ]; then PIDFILE=/var/run/proftpd.pid fi # Read config (will override defaults) [ -r /etc/default/proftpd ] && . /etc/default/proftpd trap "" 1 trap "" 15 #test -f $DAEMON || exit 0 # # These compatibility funcs are here just for sarge backports. # They will be removed post-etch. # log_daemon_msg() { echo -n "$1: $2" } log_end_msg() { if [ $1 -ne 0 ]; then echo " failed!" else echo "." fi } [ -f /lib/lsb/init-functions ] && . /lib/lsb/init-functions # # Servertype could be inetd|standalone|none. # In all cases check against inetd and xinetd support. # if ! egrep -qi "^[[:space:]]*ServerType.*standalone" \ /usr/local/etc/proftpd.conf then if [ $(dpkg-divert --list xinetd|wc -l) -eq 1 ] then if egrep -qi "server[[:space:]]*=[[:space:]]*/usr/sbin/proftpd" \ /etc/xinetd.conf 2>/dev/null || \ egrep -qi "server[[:space:]]*=[[:space:]]*/usr/sbin/proftpd" \ /etc/xinetd.d/* 2>/dev/null then RUN="no" INETD="yes" else if ! egrep -qi "^[[:space:]]*ServerType.*inetd" \ /usr/local/etc/proftpd.conf then RUN="yes" INETD="no" else RUN="no" INETD="no" fi fi else if egrep -qi "^ftp.*/usr/sbin/proftpd" /etc/inetd.conf 2>/dev/null then RUN="no" INETD="yes" else if ! egrep -qi "^[[:space:]]*ServerType.*inetd" \ /usr/local/etc/proftpd.conf then RUN="yes" INETD="no" else RUN="no" INETD="no" fi fi fi fi # /var/run could be on a tmpfs [ ! -d /var/run/proftpd ] && mkdir /var/run/proftpd start() { log_daemon_msg "Starting ftp server" "$NAME" start-stop-daemon --start --quiet --pidfile "$PIDFILE" --exec $DAEMON \ -- $OPTIONS if [ $? != 0 ]; then log_end_msg 1 exit 1 else log_end_msg 0 fi } signal() { if [ "$1" = "stop" ]; then SIGNAL="TERM" log_daemon_msg "Stopping ftp server" "$NAME" else if [ "$1" = "reload" ]; then SIGNAL="HUP" log_daemon_msg "Reloading ftp server" "$NAME" else echo "ERR: wrong parameter given to signal()" exit 1 fi fi if [ -f "$PIDFILE" ]; then start-stop-daemon --stop --signal $SIGNAL --quiet --pidfile \ "$PIDFILE" if [ $? = 0 ]; then log_end_msg 0 else SIGNAL="KILL" start-stop-daemon --stop --signal $SIGNAL --quiet \ --pidfile "$PIDFILE" if [ $? != 0 ]; then log_end_msg 1 [ $2 != 0 ] || exit 0 else log_end_msg 0 fi fi if [ "$SIGNAL" = "KILL" ]; then rm -f "$PIDFILE" fi else log_end_msg 0 fi } case "$1" in start) if [ "x$RUN" = "xyes" ] ; then start else if [ "x$INETD" = "xyes" ] ; then echo "ProFTPd is started from inetd/xinetd." else echo "ProFTPd warning: cannot start neither \ in standalone nor in inetd/xinetd mode. Check \ your configuration." fi fi ;; force-start) if [ "x$INETD" = "xyes" ] ; then echo "Warning: ProFTPd is started from inetd/xinetd \ (trying to start anyway)." fi start ;; stop) if [ "x$RUN" = "xyes" ] ; then signal stop 0 else if [ "x$INETD" = "xyes" ] ; then echo "ProFTPd is started from inetd/xinetd." else echo "ProFTPd warning: cannot start neither \ in standalone nor in inetd/xinetd mode. Check \ your configuration." fi fi ;; force-stop) if [ "x$INETD" = "xyes" ] ; then echo "Warning: ProFTPd is started from inetd/xinetd \ (trying to kill anyway)." fi signal stop 0 ;; reload) signal reload 0 ;; force-reload|restart) if [ "x$RUN" = "xyes" ] ; then signal stop 1 sleep 2 start else if [ "x$INETD" = "xyes" ] ; then echo "ProFTPd is started from inetd." else echo "ProFTPd warning: cannot start neither \ in standalone nor in inetd/xinetd mode. Check \ your configuration." fi fi ;; *) echo "Usage: /etc/init.d/$NAME {start|force-start|stop|\ force-stop|reload|restart|force-reload}" exit 1 ;; esac exit 0
# chmod +x /etc/init.d/proftpd # update-rc.d proftpd defaults # mkdir /var/lock/subsys/ # touch /var/lock/subsys/proftpd # ln -s /usr/local/sbin/proftpd /usr/sbin/proftpd # vi /usr/local/etc/proftpd/proftpd.conf
CharsetLocal UTF-8 CharsetRemote CP932 ServerIdent on "" RootLogin off ListOptions "-la" DefaultRoot ~ !wheel RequireValidShell off UseReverseDNS off IdentLookups off TimesGMT off TimeoutIdle 600 TimeoutLogin 300 TimeoutNoTransfer 600 TimeoutStalled 600 ShowSymlinks on MaxClientsPerHost 2 MaxHostsPerUser 1 LogFormat allinfo "%t : %u (%a [%h]) : [%s], %T, %m (%f)" LogFormat write "%t : %u : %F (%a)" LogFormat read "%t : %u : %F (%a)" LogFormat auth "%t : %u (%a [%h])" ExtendedLog /var/log/proftpd/all.log ALL allinfo ExtendedLog /var/log/proftpd/write.log WRITE write ExtendedLog /var/log/proftpd/read.log READ read ExtendedLog /var/log/proftpd/auth.log AUTH auth <Directory /*> AllowOverwrite on AllowStoreRestart on AllowRetrieveRestart on </Directory>
<IfModule mod_sql_mysql.c> SQLAuthenticate users SQLConnectInfo proftpd@localhost:3306 proftpd proftpd SQLAuthTypes Crypt SQLUserInfo users userid password uid gid homedir shell SQLGroupInfo groups groupname gid members AuthOrder mod_sql.c </IfModule> <IfModule mod_quotatab.c> QuotaEngine on QuotaLog /var/log/proftpd/quota-log QuotaLimitTable sql:/get-quota-limit QuotaTallyTable sql:/get-quota-tally/update-quota-tally/\ insert-quota-tally SQLNamedQuery get-quota-limit SELECT "userid, 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 quotalimits WHERE userid = '%{0}' \ AND quota_type = '%{1}'" SQLNamedQuery get-quota-tally SELECT "userid, quota_type, \ bytes_in_used, bytes_out_used, bytes_xfer_used, files_in_used, \ files_out_used, files_xfer_used FROM quotatallies WHERE \ userid = '%{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 userid = '%{6}' \ AND quota_type = '%{7}'" quotatallies SQLNamedQuery insert-quota-tally INSERT "%{0}, %{1}, %{2}, \ %{3}, %{4}, %{5}, %{6}, %{7}" quotatallies QuotaLock /tmp/proftpd-quota-lock QuotaShowQuotas on QuotaDisplayUnits Gb QuotaDirectoryTally on </IfModule>
# chown -R mysql:mysql /usr/local/var/ # mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 55 to server version: 4.1.21-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> create database proftpd; mysql> CREATE TABLE groups ( groupname VARCHAR(30) NOT NULL , gid SMALLINT(5) UNSIGNED NOT NULL DEFAULT 1000, members varchar(255) default NULL, PRIMARY KEY ( groupname ), UNIQUE KEY gid (gid) ); mysql> CREATE TABLE users ( userid varchar(30) NOT NULL, password varchar(30) NOT NULL, uid SMALLINT(5) UNSIGNED NOT NULL DEFAULT 1000, gid SMALLINT(5) UNSIGNED NOT NULL DEFAULT 1000, homedir varchar(255) default NULL, shell varchar(255) default '/bin/true', PRIMARY KEY (userid), UNIQUE KEY uid (uid) ); mysql> CREATE TABLE quotalimits ( userid VARCHAR(30) NOT NULL, quota_type ENUM("user", "group", "class", "all") NOT NULL, per_session ENUM("false", "true") DEFAULT 'true' NOT NULL, limit_type ENUM("soft", "hard") DEFAULT 'soft' NOT NULL, bytes_in_avail FLOAT DEFAULT '0' NOT NULL, bytes_out_avail FLOAT DEFAULT '0' NOT NULL, bytes_xfer_avail FLOAT DEFAULT '0' NOT NULL, files_in_avail INT UNSIGNED DEFAULT '0' NOT NULL, files_out_avail INT UNSIGNED DEFAULT '0' NOT NULL, files_xfer_avail INT UNSIGNED DEFAULT '0' NOT NULL ); mysql> CREATE TABLE quotatallies ( userid VARCHAR(30) NOT NULL, quota_type ENUM("user", "group", "class", "all") DEFAULT 'user' NOT NULL, bytes_in_used FLOAT DEFAULT '0' NOT NULL, bytes_out_used FLOAT DEFAULT '0' NOT NULL, bytes_xfer_used FLOAT DEFAULT '0' NOT NULL, files_in_used INT UNSIGNED DEFAULT '0' NOT NULL, files_out_used INT UNSIGNED DEFAULT '0' NOT NULL, files_xfer_used INT UNSIGNED DEFAULT '0' NOT NULL ); mysql> GRANT SELECT,UPDATE,INSERT ON proftpd.* TO proftpd@localhost IDENTIFIED BY 'proftpd'; mysql> INSERT INTO groups VALUES ('testgroup',1000,''); mysql> INSERT INTO users VALUES ( 'testuser',encrypt('testuser'),1001,1000,'/var/ftpdata','/bin/true'); mysql> INSERT INTO quotalimits VALUES ( 'testuser','user','false','hard', 524288000,0,0,0,0,0);
# /etc/init.d/mysql restart # /etc/init.d/proftpd restart
MasqueradeAddress <domain-name | global-ipaddr> PassivePorts <min-port-number> <max-port-number>
KUROBOX-PRO:~# apt-get install libcdk5-dev Reading package lists... Done Building dependency tree... Done The following extra packages will be installed: libc6-dev libcdk5 libncurses5-dev linux-kernel-headers Suggested packages: glibc-doc manpages-dev Recommended packages: gcc c-compiler The following NEW packages will be installed: libc6-dev libcdk5 libcdk5-dev libncurses5-dev linux-kernel-headers 0 upgraded, 5 newly installed, 0 to remove and 15 not upgraded. 1 not fully installed or removed. Need to get 1856kB/5843kB of archives. After unpacking 27.1MB of additional disk space will be used. Do you want to continue [Y/n]?
KUROBOX-PRO:~# apt-get install gcc Reading package lists... Done Building dependency tree... Done The following extra packages will be installed: binutils cpp cpp-4.1 gcc-4.1 libssp0 Suggested packages: binutils-doc cpp-doc gcc-4.1-locales make manpages-dev autoconf automake1.9 libtool flex bison gdb gcc-doc gcc-4.1-doc Recommended packages: libmudflap0-dev The following NEW packages will be installed: binutils cpp cpp-4.1 gcc gcc-4.1 libssp0 0 upgraded, 6 newly installed, 0 to remove and 15 not upgraded. Need to get 16.6kB/4915kB of archives. After unpacking 12.3MB of additional disk space will be used. Do you want to continue [Y/n]?
KUROBOX-PRO:~# apt-get install make Reading package lists... Done Building dependency tree... Done Suggested packages: make-doc-non-dfsg The following NEW packages will be installed: make 0 upgraded, 1 newly installed, 0 to remove and 15 not upgraded. Need to get 0B/381kB of archives. After unpacking 1229kB of additional disk space will be used.
KUROBOX-PRO:~# apt-get install make Reading package lists... Done Building dependency tree... Done Suggested packages: make-doc-non-dfsg The following NEW packages will be installed: make 0 upgraded, 1 newly installed, 0 to remove and 15 not upgraded. Need to get 0B/381kB of archives. After unpacking 1229kB of additional disk space will be used.
KUROBOX-PRO:~# apt-get install g++ Reading package lists... Done Building dependency tree... Done The following extra packages will be installed: g++-4.1 libstdc++6-4.1-dev Suggested packages: gcc-4.1-doc libstdc++6-4.1-doc The following NEW packages will be installed: g++ g++-4.1 libstdc++6-4.1-dev 0 upgraded, 3 newly installed, 0 to remove and 15 not upgraded. Need to get 3408kB of archives. After unpacking 11.7MB of additional disk space will be used. Do you want to continue [Y/n]?
KUROBOX-PRO:~# apt-get install zlib1g-dev Reading package lists... Done Building dependency tree... Done The following NEW packages will be installed: zlib1g-dev 0 upgraded, 1 newly installed, 0 to remove and 15 not upgraded. Need to get 0B/410kB of archives. After unpacking 602kB of additional disk space will be used.
KUROBOX-PRO:/usr/local/src# apt-get install patch Reading package lists... Done Building dependency tree... Done Suggested packages: diff-doc The following NEW packages will be installed: patch 0 upgraded, 1 newly installed, 0 to remove and 15 not upgraded. Need to get 0B/101kB of archives. After unpacking 197kB of additional disk space will be used. KUROBOX-PRO:~# apt-get install autoconf2.13 Reading package lists... Done Building dependency tree... Done The following extra packages will be installed: autoconf m4 Suggested packages: autobook autoconf-archive gnu-standards autoconf-doc Recommended packages: automaken automake1.4 The following NEW packages will be installed: autoconf autoconf2.13 m4 0 upgraded, 3 newly installed, 0 to remove and 15 not upgraded. Need to get 976kB of archives. After unpacking 3547kB of additional disk space will be used. Do you want to continue [Y/n]?
KUROBOX-PRO:~# apt-get install automake1.4 Reading package lists... Done Building dependency tree... Done The following extra packages will be installed: autotools-dev The following NEW packages will be installed: automake1.4 autotools-dev 0 upgraded, 2 newly installed, 0 to remove and 15 not upgraded. Need to get 333kB of archives. After unpacking 1163kB of additional disk space will be used. Do you want to continue [Y/n]?
KUROBOX-PRO:~# apt-get install libtool Reading package lists... Done Building dependency tree... Done Suggested packages: libtool-doc automaken g77 fortran77-compiler gcj Recommended packages: libltdl3-dev The following NEW packages will be installed: libtool 0 upgraded, 1 newly installed, 0 to remove and 15 not upgraded. Need to get 328kB of archives. After unpacking 950kB of additional disk space will be used. Get:1 http://ftp.jaist.ac.jp etch/main libtool 1.5.22-4 [328kB] Fetched 328kB in 0s (679kB/s) Selecting previously deselected package libtool. (Reading database ... 17513 files and directories currently installed.) Unpacking libtool (from .../libtool_1.5.22-4_arm.deb) ... Setting up libtool (1.5.22-4) ... KUROBOX-PRO:/usr/local/src#