 |
|
Oracle Database Tips by Donald Burleson
|
Installing PHP5, Apache and PEAR
This chapter is devoted to the
installation of Apache, PHP5 and PEAR on Linux and Microsoft Windows
2000(R) platforms. It gives a detailed description of installing each
component on each operating system.
Because Apache 2.0 has been in production for more
than a year at the time of this writing (February 2005), it has been
selected as the version of choice for our purposes. Another reason for
choosing Apache 2.0 are numerous reported problems with Apache 1.3 and
the latest versions of PHP5 which were written explicitly for Apache2.
PHP5was
installed as the Apache2 module, not as the CGI component. The CGI or
"Common Gateway Interface" is an old standard that has been abandoned
for years. CGI was the first attempt of creating a dynamic web content
and has been replaced by a variety of mechanisms, such as ASP (Active
Server Pages), JSP (Java Server Pages), and EJB (Enterprise Java
Beans) with Servlets and application servers.
Using a CGI component, the web server has to start
a shell process or thread and execute the component the same way as an
interactive user would. Shortcomings of such an approach are
countless, ranging from performance problems (the shell process for
each access has to be created, paged in, executed and then destroyed)
to various security problems (many shell programs interpret reverse
quotes as "in place command" whose output is stored into a variable,
possibly leading to problems with commands such as rm -rf $HOME).
Executing PHP5 as a module means that the
installation process creates a sharable library which is mapped into
the address space of each Apache thread, thus becoming a part of the
Apache server itself. In other words, when PHP5 is installed as a
module, Apache "learns" how to interpret PHP in addition to
interpreting HTTP requests. No invocation of a shell interpreter is
necessary; the code is efficiently shared and PHP will not interpret
reverse quotes entered into HTML forms, as can be seen from the
following picture:
The error at the top of the form reads as follows:
Exception:oci8 error: [12154: ORA-12154: TNS:could not resolve the
connect identifier specified ] in CONNECT(`ls -l /etc`, 'SYSTEM',
'****', )
When `ls -l /etc` was entered in the database
field of the DBA_Helper, the expression was not interpreted as a shell
command. This limitation does not apply to the command line version,
which will execute the command in reverse quotes as is visible from
the following example:
#!/usr/local/bin/php
<?php
$A=`ls -l /tmp`;
print "$A\n";
?>
When this command is executed, it produces the following
output:
$ ./example32.php
total 240
-rw-r--r-- 1 mgogala
users 67951 Feb 26 21:21 fetchmail.log
drwx------ 3 mgogala users 4096 Feb 26 02:08 gconfd-mgogala
drwx------ 3 root users 4096 Feb 26 10:12 gconfd-root
drwx------ 2 mgogala users 4096 Feb 26 02:08 keyring-XPLgKk
-rw------- 1 mgogala users 58535 Feb 26 21:20 mailfilter.log
srwxr-xr-x 1 mgogala users 0 Feb 26 02:08 mapping-mgogala
drwx------ 2 mgogala users 4096 Feb 26 21:27 orbit-mgogala
drwx------ 2 root users 4096 Feb 26 10:12 orbit-root
-rw------- 1 mgogala users 133 Feb 26 21:21 procmail.log
-rw------- 1 nobody 4294967295 0 Feb 26 21:27
sess_jjhh8ss4qqil5fd30cam6noca0
-rw-r--r-- 1 mgogala users 54913 Feb 26 21:30 snap.jpg
drwx------ 2 mgogala users 4096 Feb 26 02:08 ssh-llTnpa4746
drwxr-xr-x 2 mgogala users 4096 Feb 26 21:31 svao3.tmp
srwxr-xr-x 1 mgogala users 0 Feb 26 02:15 xmms_mgogala.0
-rw------- 1 mgogala users 11948 Feb 26 21:37
xses-mgogala.B3qoba
The command line version of PHP suffers from the same security
problems as other scripting interpreters. It is, however, invaluable
for testing and debugging PHP scripts.
Of course, Oracle must not be forgotten. The
availability of an Oracle client is a prerequisite for using PHP5 with
Oracle. On some supported platforms there is also a product called
Zend Core for Oracle which is, essentially, a pre-built PHP
environment which doesn't require Oracle client installed. More
information about Zend Core for Oracle can be found on the Oracle
Technology Network at:
http://www.oracle.com/technology/tech/php/zendcore
Many bugs with PHP5 and OCI8 driver were fixed in
the Zend Core for Oracle. Unfortunately, on Linux, Zend Core for Oracle
is supported only on the commercial Red Hat and SuSE versions. If your
version is not one of those, you must build PHP from source.
The Oracle server I use on Linux is Oracle 10g.
Yet, on Windows 2000, I use the Oracle 9.2 client to access the
database on Linux. The following two machines were used for testing
the software and examples for this book:
-
A no-name PC with a AMD Athlon 2000XP 1800MHZ,
512MB RAM, 200GB of disk space and the Red Hat Fedora Core 3 Linux
operating system.
-
A HP Vectra with a 233MHZ Intel CPU and 192MB RAM
with the Windows 2000 operating system and 40GB of disk space.
The first machine was also used as an Oracle
database server.
The remainder of this chapter covers the following
installations:
-
Installation of the Apache2 web server on Linux
from the source
-
Installation of PHP5 on Linux from the source
-
Installation of PEAR modules on Linux from the
Internet.
-
Installation of the Apache2 web server on
Microsoft Windows 2000 from the binary distribution.
-
Installation of PHP5 on Microsoft Windows 2000
from the binary distribution.
-
Configuration of PEAR software and installation
of PEAR modules on Microsoft Windows 2000.
I chose to install Apache2 and PHP5 on Linux from
the source instead of using the RPM or DEB distribution because while
both Apache2 and PHP5 can be installed from the binary distribution,
PHP5 has to be installed from the source if the OCI8 module is
needed. Installation of the Apache web server is extremely simple in
both cases and only one program is needed to successfully install
PHP5.
See
code depot for complete scripts
This is an excerpt from the book
Easy Oracle PHP. You can get it
for more than 30% by buying it directly from the publisher and get
instant HTML-DB scripts from the code depot:
 |
Easy Oracle PHP
Create Dynamic Web Pages with Oracle Data
Includes online HTML-DB code depot
Buy it now for 30% off
- Only $19.95
|
HTML-DB support:
 |
For HTML-DB development support just call to gat an
Oracle Certified professional for all HTML-DB development
projects. |
|