Install PostgreSQL 8.4.x on FreeBSD 8.0

Source: Internet
Author: User
Recently, I am preparing to create a project to use PostgreSQL. Of course, I have to install PostgreSQL on the server. The installation is a little more troublesome than MySQL, and the record is as follows.

1. Compile and install PostgreSQL 8.4.2
Reference
Wget http://wwwmaster.postgresql.org/redir/391/f/source/v8.4.2/postgresql-8.4.2.tar.gz
Tar zxvf postgresql-8.4.2.tar.gz
CD postgresql-8.4.2
./Configure -- prefix =/usr/local/pgsql
Make
Make install

2. Create a PostgreSQL user. Because PostgreSQL cannot be initialized and started using root, you must create a new user.
Reference
PW groupadd pgsql
PW useradd pgsql-G pgsql-D/data/pgsql-S/bin/CSH

3. Create a PostgreSQL data storage directory
Reference
Mkdir-P/data/pgsql/Data
Chown-r pgsql: pgsql/data/pgsql/

4. initialize the database
Reference
Su pgsql/usr/local/pgsql/bin/initdb-D/data/pgsql/data-e utf8

5. Modify the PostgreSQL Startup File
Reference
CP contrib/start-scripts/FreeBSD/usr/local/pgsql
VI/usr/local/pgsql

# Modify pgdata =/usr/local/pgsql/Data
# For pgdata =/data/pgsql/Data

# Modify pguser = Postgres
# Pguser = pgsql
# Save and exit

VI/etc/rc. Local

# Add/usr/local/pgsql start
# Save and exit

So far, even if PostgreSQL is installed, the next step is to install PostgreSQL support for PHP.

1. Create a libpq. so.5 link.
Reference
Ln-S/usr/local/pgsql/lib/libpq. so.5/usr/lib/libpq. so.5

2. recompile PHP
Reference
. /Configure -- prefix =/usr/local/PHP -- With-config-file-Path =/usr/local/PHP/etc -- With-mysql =/usr/local/MySQL -- with-mysqli =/usr/local/MySQL/bin/mysql_config -- With-iconv-Dir =/usr -- With-FreeType-dir -- With-JPEG-dir -- With-PNG- dir -- With-zlib -- With-libxml-Dir =/usr/local -- enable-XML -- disable-rpath -- enable-discard-path -- enable-safe-mode -- enable-bcmath -- enable-shmop -- enable-sysvsem -- enable-inline-optimization -- With-curl -- With-curlwrappers -- enable-mbregex -- enable-FastCGI -- enable-FPM -- enable-force-CGI -redirect -- enable-mbstring -- With-mcrypt -- With-Gd -- enable-Gd-native-TTF -- With-OpenSSL -- With-mhash -- enable-pcntl -- enable-sockets -- -XMLRPC -- enable-zip -- disable-ipv6 -- without-pear -- With-pgsql =/usr/local/pgsql
Make zend_extra_libs = '-liconv'
Make install

3. Restart PHP-FPM.
Reference
/Usr/local/PHP/sbin/PHP-FPM stop
/Usr/local/PHP/sbin/PHP-FPM start

If no error is reported, the entire PostgreSQL installation and PHP support will be completed. We wish you a smooth installation.

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.