# ----- Advanced APACHE Configuration in 10 Easy Steps -------- # This file describes how to build and install an apache httpd server # with ssl, php and postresql RDMS support. # # Don't waste your time, MySQL is not a real database. # # It may be helpful to refer to the 2 web pages below: # # http://www.modssl.org/example/ # http://www.joot.com/dave/writings/articles/php/ # # Original edits: raw 07/16/02 # Installation Time: Approximately 2.5 hours (Pentium III-450, cable or DSL modem). # Many commands can be mouse highlighted and pasted to a bash shell. # 1. Base installation: Red Hat Linux 7.1 with Postgresql installed # This put all of the postgresql executables in the /usr/bin directory. There is already a # group 'postgres' and user 'postgres' with home directory /var/lib/pgsql. # 2. Download and unzip-untar ('tar -zxvf tarballname') the program tarballs # in a common directory like /root. -rw-r--r-- 1 root root 2303147 Jul 14 17:17 apache_1.3.26.tar.gz -rw-r--r-- 1 root root 753241 Jul 14 17:07 mod_ssl-2.8.10-1.3.26.tar.gz -rw-r--r-- 1 root root 2671568 Jul 14 19:30 openssl-0.9.7-beta2.tar.gz -rw-r--r-- 1 root root 3376494 Jul 14 17:01 php-4.2.1.tar.gz # 3. Build and install php with postgresql support. You shouldn't need to edit /etc/ld.so.conf # to include postrgesql libraries because they are already in the root path. cd /root/php-4.2.1 ./configure --with-apache=../apache_1.3.26 \ --with-pgsql=shared \ --enable-track-vars \ --with-xml make; make install # 3a. Copy the php.ini file. cp php.ini-dist /usr/local/lib/php.ini # 4. Build and install openssl cd ../openssl-0.9.7-beta2 ./configure make; make install # 5. Build mod_ssl cd ../mod_ssl-2.8.10-1.3.26 ./configure \ --with-apache=../apache_1.3.26 \ --with-ssl=../openssl-0.9.7-beta2 \ --enable-module=ssl \ --prefix=/usr/local/apache # 6. Build and install apache cd ../apache_1.3.26 ./configure --prefix=/usr/local/apache \ --activate-module=src/modules/php4/libphp4.a \ --enable-module=ssl make make certificate make install # If you are successful, you should see something like the following: +--------------------------------------------------------+ | You now have successfully built and installed the | | Apache 1.3 HTTP server. To verify that Apache actually | | works correctly you now should first check the | | (initially created or preserved) configuration files | | | | /usr/local/apache/conf/httpd.conf | | | and then you should be able to immediately fire up | | Apache the first time by running: | | | | /usr/local/apache/bin/apachectl start | | | Or when you want to run it with SSL enabled use: | | | | /usr/local/apache/bin/apachectl startssl | | | Thanks for using Apache. The Apache Group | | http://www.apache.org/ | +--------------------------------------------------------+ # 7. Tell Apache to link PHP pages with PHP. Edit /usr/local/apache/conf/httpd.conf. # Add (or uncomment) the lines: AddType application/x-httpd-php .php .php3 .phtml AddType application/x-httpd-php-source .phps # 8. Start the apache web server with ssl. Verify the running process with 'ps aux | grep httpd'. /usr/local/apache/bin/apachectl -startssl # 9. Get started with postgresql: Login as user postgres and initialize the database su postgres initdb # You should see something like this: This database system will be initialized with username "postgres". This user will own all the data files and must also own the server process. Fixing permissions on pre-existing data directory /usr/local/postgres/data Creating database system directory /usr/local/postgres/data/base Creating database XLOG directory /usr/local/postgres/data/pg_xlog Creating template database in /usr/local/postgres/data/base/template1 Creating global relations in /usr/local/postgres/data/base Adding template1 database to pg_database Creating view pg_user. Creating view pg_rules. Creating view pg_views. Creating view pg_tables. Creating view pg_indexes. Loading pg_description. Vacuuming database. Success. You can now start the database server using: /usr/bin/postmaster -D /usr/local/postgres/data or /usr/bin/pg_ctl -D /usr/local/postgres/data start # 10. Start the postgesql server. -i option must be used with PHP. postmaster -i -D $PGDATA # You are now running both servers http and postgresql. You'll probably # want to edit/add scripts to automatically start these servers on bootup. # The rest of these intructions verify the PHP operation. # 11. Create the database called AddressBook: createdb AddressBook # The console should show a successful reply: CREATE DATABASE # 12. Create a table inside of AddressBook using psql's interactive mode (the second line will be typed in at the prompt AddressBook=*): psql AddressBook CREATE TABLE Addresses ("Name" text, "Phone" text, "Email" text); # The console should show a successful reply: CREATE # 13. To verify the operation of PHP, create a user 'web'. For example: useradd -c web -d /home/web web # 14. Login as 'web'. Make and in the directory 'public_html' # create 2 server files as follows. add.html:
Name
Phone
E-mail
add-entry.php: "; echo "Phone = $phoneResult
"; echo "E-mail = $emailResult
"; pg_Close( $db ); ?>

Add Okay!

# 14. If you're lucky or good, when you browse to: http://localhost/~web/add.html # you'll be able to insert the user input data # to postgres through your web pages. Check it. # 15. I'm not that good so I had to do edit my php.ini file to load # the pgsql.so extension module. Like this: ; Directory in which the loadable extensions (modules) reside. extension_dir = /usr/local/lib/php/extensions/no-debug-non-zts-20020429 Good Luck. Hope these instructions help. Advanced Internet Database Applications are left as an exercise for the user.