I. to integrate the LinuxApachePHP4FastCGIOracleMySQL environment, you must first prepare the following software packages: (1) database Perl interface 1. perl5 Oracle Database dbi driver: DBD-Oracle-1.03.tar.gz2.perl5 universal database interface program: DBI-1.13.tar.gz3.perl5 MySQL database DBI drive
I. to integrate the Linux/Apache/PHP4/FastCGI/Oracle/MySQL environment, you must first prepare the following software packages: (1) database Perl interface 1. perl5 Oracle Database dbi driver: DBD-Oracle-1.03.tar.gz 2. perl5 universal database interface program: DBI-1.13.tar.gz 3. perl5 MySQL database DBI drive
I. Preparations
To integrate the Linux/Apache/PHP4/FastCGI/Oracle/MySQL environment, you must first prepare the following software packages:
(1) database Perl Interface
1. perl5 Oracle dbi driver: DBD-Oracle-1.03.tar.gz
2. perl5 universal database interface program: DBI-1.13.tar.gz
3. perl5 MySQL database dbi driver: Msql-Mysql-modules-1.2209.tar.gz
(2) Oracle Database
4. Oracle 8iR2 (8.1.6) for Linux: oracle8161.tar.gz
(3) MySQL database
5. MySQL 3.22.32 server package: MySQL-3.22.32-1.i386.rpm
6. MySQL client package: MySQL-client-3.22.32-1.i386.rpm
7. MySQL Development Kit (header file/library file): MySQL-devel-3.22.32-1.i386.rpm
8. MySQL shared library package: MySQL-shared-3.22.32-1.i386.rpm
(4) Apache server
9. Apache 1.3.12 source code package: apache_1.3.12.tar.gz
(5) PHP Module
10. PHP 4.0.0 source package: php-4.0.0.tar.gz
(6) FastCGI Module
11. FastCGI Module source code package: mod_fastcgi_2.2.4.tar.gz
12. FastCGI perl development module: FCGI-0.53.tar.gz 5 pages in total.
2. Install the Oracle client
Because Oracle 8.1.6 is installed in XWindows, you must configure XWindow in advance. If your video card does not support XWindow, you can also use exceed for Remote Installation (not to mention Remote Installation ).
Here is a simple list of operations:
(1) set environment variables:
Add the following to/etc/profile:
Export ORACLE_HOME =/opt/oracle8i/u01
Export ORACLE_BASE =/opt/oracle8i
Export ORACLE_OWNER = oracle
Export ORACLE_SID = ORCL
Export ORACLE_TERM = ansi
Export PATH = $ PATH: $ ORACLE_HOME/bin
Export LD_LIBRARY_PATH = $ ORACLE_HOME/lib
Export ORA_NLS33 = $ ORACLE_HOME/ocommon/nls/admin/data
Export NLS_LANG = "SIMPLIFIED CHINESE_CHINA.ZHS16CGB231280"
(2) establish oracle groups and users
#/Usr/sbin/groupadd dba
#/Usr/sbin/useradd-g dba oracle
#/Usr/bin/passwd oracle
(3) create the $ ORACLE_HOME directory
# Mkdir/opt
# Mkdir/opt/oracle8i
# Mkdir/opt/oracle8i/u01
# Chown-R oracle. dba/opt
(4) install reacle 8iR2
Log On As an oracle user and unlock the Oracle installation package:
$ Tar zxvf oracle8161.tar.gz
$ Startx start the XWindow interface and open a rxvt terminal window
$ Cd Oracle8iR2
$./RunInstaller
In this case, the Oracle Installation interface is displayed. During installation, select install client/Application User (if the Oracle server is not running on the local machine, there is another dedicated machine ), after installation, configure SQL * Net8 and test whether the connection to the remote server is successful. 5 pages in total.
3. Install the MySQL server and client
Install MySQL packages as root:
# Rpm-ivh MySQL-3.22.32-1.i386.rpm
# Rpm-ivh MySQL-client-3.22.32-1.i386.rpm
# Rpm-ivh MySQL-devel-3.22.32-1.i386.rpm
# Rpm-ivh MySQL-shared-3.22.32-1.i386.rpm
4. Install the database interface module of Perl
Enter as root, and then execute:
# Tar zxvf DBI-1.13.tar.gz
# Cd DBI-1.13
# Perl Makefile. PL
# Make
# Make test
# Make install
# Cd ..
# Rm-rf DBI-1.13
#
# Tar zxvf DBD-Oracle-1.03.tar.gz
# Cd DBD-Oracle-1.03
# Perl Makefile. PL
# Make
# Make test
# Make install
# Cd ..
# Rm-rf DBD-Oracle-1.03
#
# Tar zxvf Msql-Mysql-modules-1.2209.tar.gz
# Cd Msql-Mysql-modules-1.2209
# Perl Makefile. PL
Select 1 (MySQL) and y (Mysql. pm supported)
# Make
# Make test
# Make install
#
5. install Apache + PHP + FastCGI
(1) Unpack the Apache/PHP/FastCGI package:
# Tar zxvf apache_1.3.12.tar.gz
# Tar zxvf php-4.0.0.tar.gz
# Tar mod_fastcgi_2.2.4.tar.gz
(2) Compile PHP4
Configure apache compilation Parameters
# Cd apache_1.3.12
#./Configure -- prefix =/usr/local/apache
Configure PHP compilation Parameters
# Cd ../php-4.0.0
#./Configure -- with-apache = ../apache_1.3.12
> -- With-mysql
> -- With-oracle = $ ORACLE_HOME
> -- With-oci8 = $ ORACLE_HOME
> -- Enable-track-vars
Compile the PHP module:
# Make
# Make install
Create a php. ini parameter file
# Cp php. ini-dist/usr/local/lib/php. ini
# Cd ..
(3) Add the FastCGI module:
# Mv mod_fastcgi_2.2.4 apache_1.3.12/src/modules/fastcgi
(4) Compile and install Apache
# Cd apache_1.3.12
Configure compilation Parameters
#./Configure -- prefix =/usr/local/apache
> -- Activate-module = src/modules/php4/libphp4.a
> -- Activate-module = src/modules/fastcgi/libfastcgi.
Compile Apache
# Make
Install Apache
# Make install
(5) Disable Apache from the original system
#/Etc/rc. d/init. d/httpd stop: 5 pages in total.
(6) Configure Apache parameters:
1. Edit the/usr/local/apache/conf/httpd. conf file and modify the following parameters:
ServerName host. mydomain. name
DocumentRoot "/home/httpd/html"
Options Indexes FollowSymLinks MultiViews Includes
AllowOverride None
Order allow, deny
Allow from all
ScriptAlias/cgi-bin/"/home/httpd/cgi-bin /"
AllowOverride None
Options None
Order allow, deny
Allow from all
DirectoryIndex index.html index. phtml index. php index.htm index.shtml index. fcgi
2. Modify the auto-start Link
# Cd/etc/rc. d/init. d
# Ln-fs/usr/local/apache/bin/apachectl httpd
(7) configure the PHP4.0 parameters:
1. Modify the/usr/local/apache/conf/httpd. conf file and modify the following parameters:
Add a row: AddType application/x-httpd-php. php. phtml. php3
2. Modify the/usr/local/apache/bin/apachectl script to enable support for the Chinese ORACLE environment:
Add the following lines to the 66 rows ("start)") of the file:
Export ORACLE_HOME =/opt/oracle8i/u01
Export ORACLE_BASE =/opt/oracle8i
Export ORACLE_SID = ORCL
Export LD_LIBRARY_PATH = $ ORACLE_HOME/lib
Export ORA_NLS33 = $ ORACLE_HOME/ocommon/nls/admin/data
Export NLS_LANG = "SIMPLIFIED CHINESE_CHINA.ZHS16CGB231280"
3. Modify/usr/local/apache/conf/srm. conf to use environment variables in CGI programs:
PassEnv ORACLE_HOME
PassEnv ORACLE_BASE
PassEnv LD_LIBRARY_PATH
PassEnv NLS_LANG
PassEnv ORACLE_SID
PassEnv PATH
(8) configure the FastCGI execution environment:
1. Modify the/usr/local/apache/conf/httpd. conf file and modify the following parameters:
Add several lines:
########### FastCGI Configures Begin ######################### #
AddHandler fastcgi-script. fcg. fcgi. fpl
SetHandler fastcgi-script
Order deny, allow
Allow from all
Options ExecCGI Indexes Includes
############## FastCGI Configure End ###################### #####
2. Create the fcgi execution directory
# Mkdir/home/httpd/html/fcgi
3. Install the Perl running module of FCGI:
# Tar zxvf FCGI-0.53.tar.gz
# Cd FCGI-0.53
# Perl Makefile. PL
# Make
# Make install: 5 pages in total.
6. Start and Test
1. Start the Apache server:
#/Etc/rc. d/init. d/httpd start
2. Compile the PHP test program:
First test program:/home/httpd/html/t1.php;
The second test is the PHP program connecting PHP to Oracle (the table has been created): Check whether it is a Chinese output;
The third test is the PHP program connected to MySQL (the table has been created ).
3. Compile the FastCGI test code:/home/httpd/html/fcgi/test. fcgi
#! /Usr/bin/perl
Use FCGI;
Use DBI;
$ Dbname = "oracle ";
$ User = "user ";
$ Passwd = "password ";
$ Dbh = "";
While (FCGI: accept ()> = 0 ){
& Parse_form ();
$ Id = $ FORM;
$ Para = $ FORM;
Print "Content-type: text/html ";
Print "";
If (! $ Dbh ){
Print "no oracle, need to connect ";
$ Dbh = DBI-> connect ("dbi: Oracle: $ dbname", $ user, $ passwd );
} Else {
Print "OK, oracle aleady connected ";
}
$ Something = $ dbh-> prepare ("select name from testtable where id = 15 ");
$ Something-> execute;
@ Recs = $ something-> fetchrow_array;
$ Something-> finish;
Print "parameter id =". $ id. "and my name is @ recs [0]";
Print "parameter para =". $ para ."";
}
#### Input parameter processing #######
Sub parse_form {
My ($ buffer );
My ($ pairs );
My (@ pairs );
My ($ name );
My ($ value );
My $ meth = $ ENV;
If ($ meth eq "GET" | $ meth eq "HEAD "){
$ Buffer = $ ENV;
}
Elsif ($ meth eq "POST "){
Read (STDIN, $ buffer, $ ENV );
}
Undef % FORM;
@ Pairs = split (//, $ buffer );
Foreach $ pair (@ pairs ){
($ Name, $ value) = split (/=/, $ pair );
$ Value = ~ Tr/+ //;
$ Value = ~ S/% ([a-fA-F0-9] [a-fA-F0-9])/pack ("C", hex ()/eg;
$ Value = ~ S // g;
If ($ allow_html! = 1 ){
$ Value = ~ S/] |) *> // g;
}
$ FORM = $ value;
}
}
Test whether FastCGI is normal.