Created
March 11, 2012 11:01
-
-
Save riipandi/2015997 to your computer and use it in GitHub Desktop.
Pure-FTPd Install Script - CentOS 6.x / Fedora 16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# ---------------------------------------------------------------------- | |
# http://www.howtoforge.com/virtual-hosting-with-PureFTPd-and-mysql-debian-lenny | |
# ---------------------------------------------------------------------- | |
# Install Apache, MySQL, PHP | |
yum install -y mysql mysql-server php phpmyadmin httpd | |
# Install & konfigurasi PureFTPd | |
yum install -y pure-ftpd | |
groupadd -g 2001 ftpgroup | |
useradd -u 2001 -s /bin/false -d /bin/null -c "pureftpd user" -g ftpgroup ftpuser | |
cat > /tmp/pureftpd.sql <<EOF | |
CREATE DATABASE pureftpd; | |
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON pureftpd.* TO 'pureftpd'@'localhost' IDENTIFIED BY 'ftpdpass'; | |
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON pureftpd.* TO 'pureftpd'@'localhost.localdomain' IDENTIFIED BY 'ftpdpass'; | |
FLUSH PRIVILEGES; | |
USE pureftpd; | |
CREATE TABLE IF NOT EXISTS ftpd ( | |
id int(11) NOT NULL AUTO_INCREMENT, | |
User varchar(16) NOT NULL DEFAULT '', | |
status enum('0','1') NOT NULL DEFAULT '0', | |
Password varchar(64) NOT NULL DEFAULT '', | |
Uid varchar(11) NOT NULL DEFAULT '-1', | |
Gid varchar(11) NOT NULL DEFAULT '-1', | |
Dir varchar(128) NOT NULL DEFAULT '', | |
ULBandwidth smallint(5) NOT NULL DEFAULT '0', | |
DLBandwidth smallint(5) NOT NULL DEFAULT '0', | |
comment tinytext NOT NULL, | |
ipaccess varchar(15) NOT NULL DEFAULT '*', | |
QuotaSize smallint(5) NOT NULL DEFAULT '0', | |
QuotaFiles int(11) NOT NULL DEFAULT '0', | |
PRIMARY KEY (id), | |
UNIQUE KEY User (User) | |
) ENGINE=MyISAM DEFAULT CHARSET=utf8; | |
INSERT INTO ftpd SET | |
User = 'tes', | |
status = '1', | |
Password = MD5('rahasia'), | |
Uid = '2001', | |
Gid = '2001', | |
Dir = '/home/tes', | |
ULBandwidth = '100', | |
DLBandwidth = '100', | |
comment = 'Contoh User FTP', | |
ipaccess = '*', | |
QuotaSize = 50, | |
QuotaFiles = '0'; | |
EOF | |
mysql -u root -p < /tmp/pureftpd.sql | |
sed -i -e 's/# MySQLConfigFile/MySQLConfigFile/g' /etc/pure-ftpd/pure-ftpd.conf | |
sed -i -e 's/#CreateHomeDir/CreateHomeDir/g' /etc/pure-ftpd/pure-ftpd.conf | |
mv /etc/pure-ftpd/pureftpd-mysql.conf /etc/pure-ftpd/pureftpd-mysql.asli | |
cat /dev/null > /etc/pure-ftpd/pureftpd-mysql.conf | |
cat > /etc/pure-ftpd/pureftpd-mysql.conf <<EOF | |
MYSQLSocket /var/lib/mysql/mysql.sock | |
MYSQLServer localhost | |
#MYSQLPort 3306 | |
MYSQLUser pureftpd | |
MYSQLPassword ftpdpass | |
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") | |
EOF | |
chkconfig --levels 235 pure-ftpd on | |
service pure-ftpd restart | |
# Install FTP Web Admin | |
cd /tmp | |
wget http://stmikpasim.ac.id/download/ftpadmin.tar.gz | |
tar xzvf ftpadmin.tar.gz | |
mv /tmp/ftpadmin /var/www/ftpadmin | |
nano /var/www/ftpadmin/config.inc.php | |
cat > /etc/httpd/conf.d/ftpadmin.conf <<EOF | |
Alias /ftpadmin "/var/www/ftpadmin" | |
<Directory "/var/www/ftpadmin/"> | |
Options Indexes MultiViews FollowSymLinks | |
AllowOverride None | |
Order deny,allow | |
Allow from all | |
</Directory> | |
EOF | |
chmod 755 -R /var/www/ftpadmin | |
service httpd restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment