Combined Use of Pureftpd and PostgreSQL

Source: Internet
Author: User
Tags psql

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.

 
 
  1. # tar xzvf postgresql-8.1.5.tar.gz  
  2.  
  3. # cd postgresql-8.1.5  

Install quick installation

 
 
  1. #./Configure
  2.  
  3. # Gmake // remember to use GNU make
  4.  
  5. # Make install
  6.  
  7. # Adduser postgres // added the postgres Group
  8.  
  9. # Mkdir/usr/local/pgsql/data
  10.  
  11. # Chown postgres/usr/local/pgsql/data
  12.  
  13. # 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:

 
 
  1. # .bash_profile  
  2.  
  3. # 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

 
 
  1. # 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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.