Fan Li (Dream)
This article is a fool-style tutorial. The purpose is to let the beginner FreeBSD can do a step step by step, it has established its own FTP Server. There may be some coming, there is a horizontal friend, you can jump out, thank you! If you are using pureftpd, you can do step-by-step work, and help you clear the entire installation process and ideas help. Thanks all. About PureftPD, I suggest you go to its official station to see, I think it is better than proftpd and vsftpd ...
One, install Pureft MySQL: Of course, you have to install FreeBSD, it is best to update the ports, if you don't know how to update, please refer to I have written to the freeBSD upgrade optimization.
First, make sure you have installed the MySQL database server software, otherwise the system will be installed, if you don't have installed, do the following installation steps, install the mysql database.
CD / USR / PORTS / DATABASES / MYSQL40-Server
Make skip_dns_check = yes build_optimized = yes build_static = yes install
among them:
Skip_dns_check = YES means no reverse analysis when adding native names
Build_optimized = yes Indicates the optimization processing at compile time
Build_Static = YES compiles mysqld into static execution versions
So we completely Mysql installed, it automatically installed in the / usr / local directory, the database directory is located / var / db / mysql, then install the Pureftpd this FTP Server software, please enter:
CD / USR / PORTS / FTP / PURE-FTPD
Pure-ftpd supports multiple authentication methods such as LDAP, PGSQL, MySQL, and my favorite is integrate with MySQL, using MySQL to do important transactions such as user authentication, FTP root directory, uploading download rates. Therefore, we need to compile into the mysql option, do the command to install Pure-ftpd mysql below
Make with_mysql = 1 install
In this way, Pure-ftpd will automatically include mysql into in installation, saving us to our integration. Second, configure the PureftPD system installation, automatically install the relevant profile sample. Sample to the / usr / local / etc directory, so we also make it easier to find these configuration files.
CD / USR / local / etc
CP pureftpd-mysql.conf.sample pureftpd-mysql.conf
Cp pure-ftpd.conf.sample pure-ftpd.conf
However, there is a little because we want to use the pureftpd-php-manager to manage users, so pureft-mysql.conf, etc. we will cover with additional files.
Now start modifying the pure-ftpd.conf configuration file so that this Server can be better, stable, follow these steps:
vi /usr/local/etc/pure-ftpd.conf
Detailed profile instructions, please refer to:
http://www.chinaunix.net/jh/15/145846.html
Here I only list a few more than the need to change ~~
# CAGE IN EVERY USER IN HOS Home Directory
# Limit each user to your own root directory
Chrooteveryone Yes
# Disallow anonymous connection. Only Allow Authenticated Users.
# Cancel anonymous user
Noanonymous Yes
# MySQL Configuration FILE (See Readme.Mysql)
# pfFTPD-mysql.conf file location
MySQLCONFIGFILE /USR /LOCAL/Etc/pureftpd-mysql.conf
OK, remember the deployment of the deployment, if you can't use: WQ, add an exclamation point after you: WQ! You can, indicate forced execution of the storage exit command.
Three, add FTP users and user groups
PW GroupAdd ftpusers -g 2000
Add FTP user group
PW useradd ftp -u 2000 -g ftpusers -s / sbin / nologin
Add FTP users, and prohibit login shell
FTP This username must be added, otherwise the system will report an error in startup.
I like to start the user ID of the virtual host from 2000, it is also convenient to calculate the quantity.
Four, configure PureftPD-PHP_MANAGER I downloaded the version of ZIP, and you can perform decompression work by following the command.
unzip pureft_php_manager.zip
CHMOD -R 755 Pureft_php_manager
The program will then decompress the program to the Pureft_php_manager directory.
Note that because the ZIP file compresses from the WIN is inside the UNIX system, it will change the permissions to 600, so we must change the permissions before, otherwise you will not be able to access it from the web!
Let's configure pureftpd_php_manager, let us manage FTP through your browser
Cp -R pureftpd_php_manager /Home/onlinecq.com/
# OnlineCQ.com is the root of my website, please change your own
CD /HOME/OnlineCQ.COM/pureftpd_php_manager
CP pureftpd-mysql.conf.sample /usr/local/etc/pureftpd-mysql.conf
This is the configuration file that integrates Pureft and MySQL, copies to the ETC Configuration Directory, replaces the original pureftpd-mysql.conf file
Next, we need to edit the configuration of this file.
Mainly modified here
MySQLUser Pureftpd
MySQLPassword 123 ***
MySQLDATABASE PUREFTPD
MySQLUSER means a user name of MySQL
MySQLPassword means a password for mysql username
MySQLDATABASE represents the database name
For safety, it is highly recommended not to use root because PHP's vulnerability is much, if you are not friendly to configure the server, get this file through the shell, easily.
Here, we assume that a PureftPD user and pureft database, and modify the relevant fields in the pureft-mysql.conf file, the deployment exits ~~
Next, a data table called FTPD is required, and its structure is as follows:
DROP TABLE IF EXISTS FTPD;
Create Table FTPD (
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 (User),
UNIQUE Key User (User)
) TYPE = MyISAM;
After establishing it, then do the following step, you can complete the configuration of the pureftpd-php-manager:
CD /HOME/OnlineCQ.COM/pureftpd_php_manager
Vi pureftp.config.php
Enter the file, edit it, I posted my own file configuration, give you a reference:
PHP
#######################################
####### setup ########
#######################################
// Your Exactly Located MySQL Config File for Pureftpd
$ Pureftp_config_file = '/usr/local/etc/pureftpd-mysql.conf';
// the location where all the forms directed to. (Mayby No change Need)
$ Self_URL = 'Index.php';
// the location of your pure-ftpdwho binary 4711)
$ Ftp_who = "/ usr / local / sbin / pure-ftpwho";
##############################
# Default new-user params #
##############################
$ Defaultuser = ""; # default user logon
$ Defaultpass = ""; # default user password
$ DEFAULTUID = ""; # default user ID (Must Be a real user acct)
$ Defaultgid = "2000"; # default group ID (Must Be a real group acct)
$ Defaultdir = "/ home"; # default user dir (use /./ at the end to chroot)
$ Defaultul = "0"; # default upload throttle (0 Disables it)
$ Defaultdl = "0"; # default download throttle (0 Disables IT)
$ Default = "*"; # default ip restrictions (* = any ip)
$ Defaultqs = "200"; # default quota size (0 disables it)
$ DEFAULTCMT = ""
$ Defaultqf = "0"; # default quota files (0 disables it) ^ m
$ PWC = "55"; # vorsatz Fuerr Crypt Password ^ M
?>
Five, run until this, our FTP Server is odd 鹄 拴 拴 拴 拴 Now testing can run normally.
Please change your name from the startup file so you can save the FTP after starting the server.
Cp /usr/local/etc/rc.d/pure-ftpd.sh.sample pure-ftpd.sh
Trial run:
/usr/local/etc/rc.d/pure-ftpd.sh
If there is no error, check
Try to log in to FTP Server whether there is no reflection, the normal situation is as follows:
Pure-ftpfreebsd # ftp localhost
Trying :: 1 ...
Connected to Localhost.
220 ---------- Welcome to Pure-ftpd [TLS] ----------
220-you are user number 1 of 50 allowed.
220-local time is now 13:58. Server port: 21.
220-this is a private system - no anonymous login
220 you will be disconnected after 15 minutes of inactivity.
Name (localhost: fanli):
Oh, this means that pureftpd we have already installed!
Six, encryption pureft_php_manager directory Because we are putting it online, you must don't want everyone to go to see your FTP users!
I usually use htpasswd verification, please do this, still use the example in front:
My pureft_php_manager directory is located in /Home/onlinecq.com/pureftpd_php_manager directory, modify httpd.conf
Deny from all
Options none
ALLOWOVERRIDE AUTHCONFIG
ORDER DENY, ALOW
Directory>
In this way, if someone wants to enter the directory, we must verify through Apache to ensure our security (not absolutely safe)
CD /HOME/OnlineCQ.COM/pureftpd_php_manager
Then enter the directory of the pureft_php_manager, use the VI to create a .htaccess authentication file:
Vi .htaccess
The content is as follows:
Authtype Basic
Authorfile /usr/local/etc/pureftpd.passwd
Authname pureftpd
Require Valid-User
Satisfy Any
After the deployment is exited, we can use the htpasswd command to add the user who allows you to enter the directory!
CD / USR / local / etc
Enter this directory
htpasswd -bc pureft.passwd ftp 123654
This will create a pureft.passwd authentication file in your current directory, the username is FTP, the password is 123654, you can change it to you. All right. It looks almost, trouble you to restart Apache test. If a smooth. I congratulate you. Everything is successful!
Attach: self-started pureftpd.sh
#! / bin / sh if! prefix = $ (expr $ 0: "/(/.*/ )/tc/rc/.d/$ (BaseName $ 0) / $"); then echo "$ 0: cannot determine the prefix "> & 2 Exit 1 Fi Case" $ 1 "in start" [-r $ {prefix} /etc/pure-ftpd.conf] && / $ {prefix} /sbin/pure-config.pl $ {prefix} / etc / Pure-ftpd.conf> / dev / null && / echo -n 'pure-ftp'; Stop)
[-r /var/run/pure-ftpd.pid] && /
Kill `Cat / Var / Run / Pure-fpd.pid`> / dev / null& /
echo -n 'pure-ftp'
;
*)
echo "USAGE:` Basename $ 0` {Start | Stop} "> & 2 ;; ESAC EXIT 0
Conclusion so so, can generally operate FTP
Server has established, you can reocconate, let the latest settings and software take effect.
If an error occurs during the installation process, you can check the error first, then install it. Or you can choose
Some parts you are interested in installation!
Of course, because of the time rush, the knowledge involved is too wide, and the ability is limited, and the mistakes are inevitable, please
The readers are proposed, and everyone will improve together and make progress together!