Compile and install bandwidthd and postgresql in Ubuntu, and save the data to pgsql

Source: Internet
Author: User
I mentioned earlier that bandwidthd should be installed using the deb package in Ubuntu. Now I want to compile and install bandwidthd and postgresql by myself. Users who use linux can install bandwidthd in this way. Environment Description: hostname = BK3. the user is netuser and domain = localdomain during installation; 1. Prepare 1.1 to install apache2 and support the apt-getinstal package required for php1.1.1 installation.

I mentioned earlier that bandwidthd should be installed using the deb package in Ubuntu. Now I want to compile and install bandwidthd and postgresql by myself. Users who use linux can install bandwidthd in this way.

Environment Description:

Hostname = BK3. the user is netuser and domain = localdomain during installation;

1. Prepare

1.1 install apache2 and support php

1.1.1 package required for Installation

Apt-get install apache2

Apt-get install php5

Apt-get install php5-pgsql

Apt-get install php5-gd

1.1.2 restart apache2

/Etc/init. d/apache2 restart

1.1.3 Test

Create a PHP file under/var/www

Vi/var/www/info. php

Input

Save and exit wq

Access http: // ip/info. php in a browser

1.2 install other required software

Apt-get install gcc

Apt-get install flex (lex)

Apt-get install bison (yacc)

1.3 compile and install the library required by bandwidthd

Install zlib

Install libpng

Install libgd

Install libpcap

Parameters

./Configure -- prefix =/usr/

2. install and configure postgresql

2.1 install the required package

Apt-get install zlib1g

Apt-get install libreadline5-dev

2.2 create an account for postgresql

Useradd S

Create a home directory for your account

Mkdir/home/postgres

Set the main directory of the account to the folder you just created.

Usermod-d/home/postgres

Set the account to use bash (otherwise, after su posgres, only $)

Usermod-s/bin/bash postgres

2.3 compile and install pgsql (you must install pgsql in/usr/local/pgsql. When compiling bandwidthd, it will only find pgsql here. If it cannot be found, it will not support pgsql after compilation)

Tar zxvf postgresql-8.4.3.tar.gz

./Configure-prefix =/usr/local/pgsql

Make & make install

2.4 Configuration

2.4.1 modify Environment Variables

Add the following content to/etc/profile:

PATH =/usr/local/pgsql/bin: $ PATH

Export PATH

MANPATH =/usr/local/pgsql/man: $ MANPATH

Export MANPATH

LD_LIBRARYPATH =/usr/local/pgsql/lib: $ LD_LIBRARYPATH

Export LD_LIBRARYPATH

Execute./etc/profile to make the modified environment variable take effect immediately. There is a space between. And /.

2.4.2 create a database directory and grant permissions

Mkdir/usr/local/pgsql/data

Mkdir/usr/local/pgsql/log

Touch/usr/local/pgsql/log/syslog. log

Chown postgres/usr/local/pgsql/data

Chown postgres/usr/local/pgsql/log

2.4.3 activate the database as postgres

Su ipvs

Initdb-D/usr/local/pgsql/data # bind a data directory

The configuration file is generated under data.

2.4.4 modify the configuration file

Returns netuser,

Exit

Modify pg_cmd.conf to solve the authentication failure problem and enable the php program to connect to the database,

Change as follows

Host all 127.0.0.1/32 trust

Local all trust

Host all: 1/128 trust

Modify postgresql. conf to modify the listening range of the database.

Listen_addresses = '*'

2.5 start the database

Su postgres # started by the postgres user by default

/Usr/local/pgsql/bin/postgres-D/usr/local/pgsql/data

Or

/Usr/local/pgsql/bin/pg_ctl-D/usr/local/pgsql/data-l/usr/local/log/syslog. log start

# Reference:

Pg_ctl start [-w] [-d datadir] [-s] [-l FILENAME] [-o "OPTIONS"]

Pg_ctl stop [-W] [-d datadir] [-s] [-m SHUTDOWN-MODE]

Pg_ctl restart [-w] [-d datadir] [-s] [-m SHUTDOWN-MODE] [-o "OPTIONS"]

Pg_ctl reload [-d datadir] [-s]

Pg_ctl status [-d datadir]

Add a user to postgresql: createuser netuser

# Account created during Ubuntu Login

Create Database: createdb mydb

2.6 Test Database

Return to netuser

Exit

Enter the following command line:

Psql mydb

# Display: mydb = #, indicating that the connection is successful and the account is the database administrator.

Exit the database with exit

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.