HOWTO_PureFTPD_with_MySQL_Auth_and_PhpMyAdmin
Contents |
About
PureFTPd is a free (BSD license) FTP Server.
Install
| Code: Install PureFTPd |
emerge -av net-ftp/pure-ftpd net-ftp/pure-ftpd -ldap +mysql +pam +ssl +vchroot |
| Code: Get the version number |
emerge -pv net-ftp/pure-ftpd |
Configure
Configure PureFTPD
Like all configuration files on Gentoo, the pure-ftpd configuration file is placed in /etc/conf.d.
Open /etc/conf.d/pure-ftpd:
nano -w /etc/conf.d/pure-ftpd
Uncomment the configuration flag
IS_CONFIGURED="yes"
Add the MySQL authenticator at the end of the file
AUTH="-l mysql:/etc/pureftpd-mysql.conf"
Save and exit nano.
Basic configuration
Adding SSL Support
In order to add SSL support to pure-ftpd you need to ensure that you have emerged pure-ftpd with the ssl use flag.
Then make a .pem cert.
mkdir -p /etc/ssl/private openssl req -x509 -nodes -newkey rsa:1024 -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem chmod 600 /etc/ssl/private/pure-ftpd.pem
Then edit MISC_OTHER in /etc/conf.d/pure-ftpd to enable ssl support.
Add '-Y x' into MISC_OTHER field where x is;
'-Y 0': Disable the SSL/TLS encryption layer (default). '-Y 1': Accept both standard and encrypted sessions. '-Y 2': Refuse connections that aren't using SSL/TLS security mechanisms,
User management
Requirements:
- Web server - to serve the Usermanager
- PHP - the Usermanager is a PHP application
- Usermanager - the web application where virtual users can be created and modified
Make sure, PHP is compiled with the following USE flags:
- mysql - adds MySQL support
- posix - adds posix support
- session - adds session support
- pcre - adds pcre support
If you are missing one of these USE flags, add them in the /etc/make.conf code> and update PHP
emerge -avu php
The pure-ftpd usermanager is not in Portage, so download and install it manually. Change path to your website document folder:
cd /var/www/localhost/htdocs
Get the tar ball:
wget http://machiel.generaal.net/files/pureftpd/ftp_v2.1.tar.gz
Untar, this wil create the Usermanager in the folder ftp code>:
tar zxf ftp_v2.1.tar.gz
For the created folder, change owner to the proper user/group:
chown -R apache:apache ftp
Make sure install code> is named install.php code>
cd ftp mv install install.php
Make config.php code> writable
chmod 664 config.php
The documentation its pretty easy to follow, the file you have to edit is the config.php
vim config.php
This will enable you to establish a connection to the mysql server, and install the database for pure-ftpd.
Fireup the install.php code> in your favorite webbrowser:
http://localhost/ftp/install.php
Follow the installation wizard, you will be guided in 7 steps
- Choose New installation, create a new database.
- Fill in the hosts/username/password to administrate Mysql, this information is used to create the ftpusers database
- Fill in the hosts/username/password for the ftpusers database, this information is used by pure-ftpd to connect to Mysql
- Fill in all the stuff, this information is used by the Usermanager in PHP to modify the ftpusers database
- When done press the Save button to write the configuration to the
config.php code> file
- When done press the Save button to write the configuration to the
- Fill in a proper password for the Administrator user, this is used to login in the Usermanager
- Press the Change button to save the password
- Copy all text in the gray block from Step B, paste the text in
/etc/pureftpd-mysql.conf code> and save it - Close the installation wizard
If you have any trouble at this point, you should consult the documentation of the User Manager for Pure-FTPd. You might want to use phpMyadmin if you don't know how to use mysql.
After you finish installing the Manager ( and creating the purepftpd-mysql.conf file ), you open your web browser and go to :
http://localhost/ftp
Note Make sure you have a valid password for the ftpusers database user. It must not be empty, or Pure-FTPd will fail to start.
Add users
You first need to start PureFTPd (see PureFTPd#Start PureFTPd). Then open the Usermanager, it is an web application so go to
http://localhost/ftp/
Log in with the password as defined in the installation wizard (Step 5). You should now be able to add/delete/modify virtual users.
Start PureFTPd
Start the FTP server
/etc/init.d/pure-ftpd start
If it fails to start, check the log file
tail /var/log/messages
If it succeeds, let pure-ftpd start automatically
rc-update add pure-ftpd default
Clean up
When all is set and done there are some loose ends we have to take care off.
There is a serious security breach when the install.php code> is public accessible. So delete it or rename it
To delete:
rm /var/www/localhost/htdocs/ftp/install.php
or rename:
mv /var/www/localhost/htdocs/ftp/install.php /var/www/localhost/htdocs/ftp/install
Delete the downloaded Usermanager tarball:
rm /var/www/localhost/htdocs/ftp_v2.1.tar.gz
See also
[updated to use user manager for pure-ftpd - ikaro at fluxbox dot org ]
Created by NickStallman.net, Luxury Homes Australia
Real estate agents should be using interactive floor plans and list their apartments, townhouses and units.
