database.sarang.net
UserID
Passwd
Database
DBMS
MySQL
ㆍPostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
PostgreSQL Tutorials 4274 게시물 읽기
 News | Q&A | Columns | Tutorials | Devel | Files | Links
No. 4274
Tutorial - Installation of PostgreSQL, Apache and PHP
작성자
정재익(advance)
작성일
2002-08-01 09:56
조회수
7,101

Tutorial - Installation of PostgreSQL, Apache and PHP

 

원본출처 : http://pgsql.designmagick.com/tutorial.php?id=3

 

This tutorial is for those who are having problems installing PostgreSQL, PHP, and Apache together. At the moment, this is for

Linux only, I don't have access to Windows NT or Windows 2000 to try and get it going on there. For more information on that,

please see PHP-4-Win.

 

Also note, this information is for a fresh install of these programs, NOT for an upgrade.

 

First of all, we need to download the source for the programs. The routine I'm explaining will not work with the RPM's. For RPM's, download the RPM's, then use the standard syntax-

 

rpm -ivh postgresql-*.rpm

 

to install them.

 

Get the programs from-

http://www.postgresql.org/

http://www.apache.org/

http://www.php.net/

 

When you download, please choose a mirror site close to you.

 

First we'll work on the PostgreSQL installation. Create a PostgreSQL "superuser". This is who "owns" the database. I use the "postgres" user, with the group being "daemon". See your system documentation on how to do this (hint - man useradd). Give the user a home directory of /usr/local/pgsql as this is where PostgreSQL defaults to when it installs.

 

After downloading the source code, run these commands -

 

designmagick:/home/tomcat # gunzip postgresql-7_0_2.tar.gz

designmagick:/home/tomcat # tar -xvf postgresql-7_0_2.tar

designmagick:/home/tomcat # mv postgresql-7.0.2/ /usr/src

 

If you have multiple partitions on your system, and your home directory and the usr directory are on different partitions, you

will get a message like this -

mv: cannot move `postgresql-7.0.2' across filesystems: Not a regular file

Run these commands instead -

designmagick:/home/tomcat # cp -r postgresql-7.0.2/ /usr/src

designmagick:/home/tomcat # rm -r postgresql-7.0.2/

 

Now that we've unpacked PostgreSQL, we can work on getting it going.

 

designmagick:/home/tomcat # cd /usr/src/postgresql-7.0.2/src/

designmagick:/usr/src/postgresql-7.0.2/src # ./configure

 

This basically works out what sort of system you have, and what commands work. When that finishes, run

 

designmagick:/usr/src/postgresql-7.0.2/src # make

 

This should give the last line as "All of PostgreSQL is successfully made. Ready to install." The next part, we do as the database superuser we set up before (postgres). So we have to change to this user first.

 

designmagick:/usr/src/postgresql-7.0.2/src # su - postgres

postgres@designmagick:~ > cd /usr/src/postgresql-7.0.2/src/

postgres@designmagick:/usr/src/postgresql-7.0.2/src > make install

 

If you have problems with this, you CAN do it as root, then change the owner of the files. Do the "make install" as root, then change the permissions of the files. How?

 

designmagick:/usr/src/postgresql-7.0.2/src # cd /usr/local

designmagick:/usr/local # chown -R postgres:daemon pgsql

 

Now we have to tell the system where the PostgreSQL libraries are. Add this line into /etc/ld.so.conf -

 

/usr/local/pgsql/lib

 

Then run

 

designmagick:/usr/local # /sbin/ldconfig

 

Next we have to set up the PostgreSQL database. Do this as the postgres user, not as root. In fact, PostgreSQL won't start as root.

 

postgres@designmagick:/usr/local > /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data

 

The "-D" option tells the database where the data is stored. When this finishes, it will tell you you can start the server. This is my script which i call "pgsql". I put it in the /etc/rc.d directory, you can put it wherever you want

-

 

su -c '/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data >> /usr/local/pgsql/logs/server.log 2>&1' postgres

&

 

This puts the output into a log file. As the postgres superuser, make a "log" directory, otherwise it won't work. To make it automatically start when the computer starts, add this line into /etc/rc.d/boot.local (this is for SuSE, for others, check the directory first).

 

/etc/rc.d/pgsql

 

If anyone has any better suggestions for a script, let us know. If you run this script now, it will start the PostgreSQL server.

 

That should be enough for PostgreSQL for now, we'll move onto PHP and Apache installation.

 

Now we setup PHP and apache. We need to unpack the source code for these before we can do anything, so we do this -

 

designmagick:/home/tomcat # gunzip apache-1.3.20.tar.gz

designmagick:/home/tomcat # tar -xvf apache-1.3.20.tar

designmagick:/home/tomcat # gunzip php-4.0.6.tar.gz

designmagick:/home/tomcat # tar -xvf php-4.0.6.tar

 

Then we move them to the /usr/src directory, as we did before.

 

designmagick:/home/tomcat # mv apache_1.3.20/ /usr/src

designmagick:/home/tomcat # mv php-4.0.6/ /usr/src

 

Again, if you get this message -

 

mv: cannot move `apache_1.3.20' across filesystems: Not a regular file

mv: cannot move `php-4.0.6' across filesystems: Not a regular file

 

Do this instead -

 

designmagick:/home/tomcat # cp -r apache_1.3.20/ /usr/src

designmagick:/home/tomcat # rm -r apache_1.3.20/

designmagick:/home/tomcat # cp -r php-4.0.6/ /usr/src

designmagick:/home/tomcat # rm -r php-4.0.6/

 

Now we actually get into the installation of the programs.

 

designmagick:/home/tomcat # cd /usr/src

designmagick:/usr/src # cd apache_1.3.20/

designmagick:/usr/src/apache_1.3.20 # ./configure

 

This gives us a configuration of Apache, PHP needs this for its installation. We'll go back to PHP again now.

 

designmagick:/usr/src/apache_1.3.20 # cd ..

designmagick:/usr/src # cd php-4.0.6/

designmagick:/usr/src/php-4.0.6 #

 

We now configure PHP to work with PostgreSQL. This is the configure command I use, it works well -

 

designmagick:/usr/src/php-4.0.6 # ./configure --with-pgsql --with-apache=../apache-_1.3.20 --enable-track-vars

 

Next we make it and install it.

designmagick:/usr/src/php-4.0.6 # make

designmagick:/usr/src/php-4.0.6 # make install

 

Next we make and install Apache.

designmagick:/usr/src/php-4.0.6 # cd ..

designmagick:/usr/src # cd apache_1.3.20/

 

We have to run the configure command again to tell Apache we want to use the PHP module.

designmagick:/usr/src/apache_1.3.20 # ./configure --activate-module=src/modules/php4/libphp4.a

 

This file doesn't exist at the moment (libphp4.a), it will be created by the process.

 

designmagick:/usr/src/apache_1.3.20 # make

designmagick:/usr/src/apache_1.3.20 # make install

 

The Apache server is now installed. We only have a couple more steps to go through, and then we have a working PostgreSQL, PHP,

and Apache webserver.

We have to tell Apache how to deal with php scripts. We need to add this line to the srm.conf file located in the /usr/local/apache/conf/ directory (this is the default installation directory for Apache).

 

Addtype application/x-httpd-php .php

 

The last thing we have to do, is set up a script to start Apache when the computer boots up. You actually get a program to do this, its called "apachectl" and is located in the /usr/local/apache/bin directory. The other thing we have to check is that an older version of Apache doesn't start up. Check for a file in the /etc/rc.d directory called either "apache" or "httpd". If you do have one of these files, backup the file, edit it and change the httpd location to "/usr/local/apache/bin/httpd". If you don't have one of these files, add this line into /etc/rc.d/boot.local :

 

/usr/local/apache/bin/apachectl start

 

You can also run this file right now to start the Apache webserver. That should be about it!

[Top]
No.
제목
작성자
작성일
조회
4300The PostgreSQL JDBC Primer
정재익
2002-08-15
6573
4285mimic oracle's replace function. versions in pltcl and plpgsql
정재익
2002-08-05
5415
4275LAMPS Tutorial v2.0
정재익
2002-08-01
7472
4274Tutorial - Installation of PostgreSQL, Apache and PHP
정재익
2002-08-01
7101
4272PostgreSQL에서 집합 함수와 연산자 사용하기
정재익
2002-07-29
6855
4258PostgreSQL CBT - Referential Integrity
정재익
2002-07-18
4688
4253PostgreSQL에서 JDBC 사용하기
정재익
2002-07-09
5402
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2023 DSN, All rights reserved.
작업시간: 0.050초, 이곳 서비스는
	PostgreSQL v16.1로 자료를 관리합니다