PureftpdIt is an open source code software that is used on multiple types of Unix and complies with the GPL protocol. The following describes how he and PostgreSQL are used in combination.
First, we should know what PostgreSQL is? PostgreSQL is an enhanced version of the PostgreSQL database management system, a prototype of next-generation DBMS. PostgreSQL replaces the original PostQuel query language with an extended SQL subset based on the strong data model and rich data types of ipvs. PostgreSQL is free and all source code can be obtained.
PostgreSQL development is conducted by a developer group participating in the PostgreSQL development email list. The current focal point is Marc G. Fournier (scrappy@postgreSQL.org ). This team is now responsible for all development of PostgreSQL.
PostgreSQL 1.01 is written by Andrew Yu and Jolly Chen. Many others have contributed a lot to porting, testing, debugging, and enhancing code. PostgreSQL's initial origins were developed by many graduate students, undergraduates, and programmers under the guidance of Professor Michael Stonebraker at UC Berkeley.
The software was originally named Postgres in Berkeley. In 1995, when the SQL function was added, its name was changed to ipvs95. It was renamed PostgreSQL at the end of 1996. The latest version is 8.1.5.
Install PostgreSQL
We first extract the latest PostgreSQL, sql-8.1.5.tar.gz, from www.postgresql.org.
- # tar xzvf postgresql-8.1.5.tar.gz
-
- # cd postgresql-8.1.5
Install quick installation
- #./Configure
-
- # Gmake // remember to use GNU make
-
- # Make install
-
- # Adduser postgres // added the postgres Group
-
- # Mkdir/usr/local/pgsql/data
-
- # Chown postgres/usr/local/pgsql/data
-
- # Su-postgres
$/Usr/local/pgsql/bin/initdb-D/usr/local/pgsql/data
$/Usr/local/pgsql/bin/postmaster-D/usr/local/pgsql/data> logfile 2> & 1 & // start the database
$/Usr/local/pgsql/bin/createdb test // create a database test
$/Usr/local/pgsql/bin/psql test // use the interactive psql tool to enter the database test
$ Exit psql with the \ q command
Set the environment variable LD_LIBRARY_PATH
$ Vi. bash_profile
Join
LD_LIBRARY_PATH =/usr/local/pgsql/lib
Add it after PATH = $ PATH: $ HOME/bin
:/Usr/local/pgsql/bin
Add LD_LIBRARY_PATH after the export, save and exit, and execute
$ Source. bash_profile
The overall structure should be as follows:
- # .bash_profile
-
- # Get the aliases and functions
If [-f ~ /. Bashrc]; then
.~ /. Bashrc
Fi
# User specific environment and startup programs
PATH = $ PATH: $ HOME/bin:/usr/local/pgsql/bin
LD_LIBRARY_PATH =/usr/local/pgsql/lib
Export PATH LD_LIBRARY_PATH
Unset USERNAME
$ Psql-l // view the existing database
$ Psql // enter the psql Interaction Mode
= # Create user pureftpd with password 'pureftpd ';
= # Create database pureftpd with owner = pureftpd TEMPLATE = template0 ENCODING = 'euc _ cn ';
= # \ Q
$ Psql-l
List of databases
Name | Owner | Encoding
----------- + ----------
Postgres | UTF8
Pureftpd | EUC_CN
Template0 | S | UTF8
Template1 | S | UTF8
Test | S | UTF8
(5 rows)
$ Createlang plpgsql pureftpd
$ Psql-U pureftpd
Pureftpd =>
Drop table users CASCADE;
Drop sequence users_id_seq CASCADE;
Create table "users "(
Id integer DEFAULT nextval ('users _ id_seq ': text) not null,
"User" character varying (16) not null default '',
Status smallint default 0, // this parameter is useless
"Password" character varying (64) not null default '',
"Uid" character varying (11) DEFAULT-1 not null,
"Gid" character varying (11) DEFAULT-1 not null,
"Dir" character varying (128) not null,
"Comment" text,
Ipaccess character varying (15) DEFAULT '*' not null,
"ULBandwidth" smallint default 0,
"DLBandwidth" smallint default 0,
"QuotaSize" integer DEFAULT 0,
"QuotaFiles" integer DEFAULT 0,
ULRatio smallint default 0,
DLRatio smallint default 0,
Create_date timestamp with time zone DEFAULT now () not null,
Modify_date timestamp without time zone DEFAULT now () NOT NULL
);
Create sequence users_id_seq;
Create index users_index ON users (id, "User ");
Alter table only users add constraint users_pkey primary key (id );
Alter table only users add constraint users_id_key UNIQUE (id, "User ");
Pureftpd => \ d
List of relations
Schema | Name | Type | Owner
-------- + -------------- + ----------
Public | users | table | pureftpd
Public | users_id_seq | sequence | pureftpd
(2 rows)
Pureftpd => insert into users VALUES (1, 'test', 1, md5 ('test'), '123456', '/var/ftp/test ', '','' * ', 0, 0, 0, 0, 0, 0, '2017-11-27 14:30:00', '2017-11-27 14:30:00 ');
So the database is built, and then we configure the pureftpd-pgsql.conf File
- # vi /usr/local/pureftpd/etc/pureftpd-pgsql.conf
This is similar to the mysql configuration file we saw earlier, and the modification is similar. I will not go into details here.
Note: password encryption in pureftpd-pgsql.conf I'm using
PGSQLCrypt md5
I have not seen the crypt or encrypt functions. If you have any knowledge about this, you are welcome to discuss it.
Another important thing is that you need to modify
PGSQLGetRatioUL SELECT ULRatio FROM users WHERE User = '\ l'
PGSQLGetRatioDL SELECT DLRatio FROM users WHERE User = '\ l'
Is
PGSQLGetRatioUL SELECT "ULRatio" FROM "users" WHERE "User" = '\ l'
PGSQLGetRatioDL SELECT "DLRatio" FROM "users" WHERE "User" = '\ l'
Format, otherwise it cannot be authenticated.
Modify the pure-ftpd.conf file, just like mysql
PGSQLConfigFile/usr/local/pureftpd/etc/pureftpd-pgsql.conf
Restart the pureftpd program and test it. The permission is the same as that for mysql database authentication.
Based on the description in this article, we can easily find that the combined use of Pureftpd and PostgreSQL works well and hope to help you!