Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 

 

 

Oracle Database Tips by Donald Burleson


 

Installing PHP5 on Linux

As was the case with the Apache2 web server, PHP5 needs to be downloaded from the http://www.php.net  site. Because no binary distribution exists with the OCI8 module enabled, the source file will also need downloaded, compressed with gzip, and this time named "php-5.0.3.tar.gz". The download page looks like this:

As was the case with Apache, versions of PHP are also guaranteed to have changed since this book was written. You should download the latest version as it usually has the most important bugs fixed.

Same as before, the distribution should be unpacked by  using  tar -zxvf, command shown below:

$ tar -zxvf php-5.0.3.tar.gz

The output of this command is very verbose and creates the directory, php-5.0.3, with all the necessary subdirectories and unpacked distribution.

This directory contains the well known configure script introduced during the Apache2 installation.  For PHP, the script is significantly more complicated. If the user wants to link PHP5 with Oracle, the ORACLE_HOME environment variable needs defined and exported with the following command:

export ORACLEHOME=/oracle/product/10g

This command is necessary because the script will look for the Oracle libraries during the installation process. Therefore, execute the "configure" script:

./configure --with-apxs2=/opt/apache/bin/apxs --with-config-file-path=/usr/local/lib/php --with-oci8 --enable-sigchild --without-sqlite --disable-mysql

Use the following command to explain the configuration options:

--with-apxs2=/opt/apache/bin/apxs 

This option tells the configure process the location of the Apache2 configuration script. If linking to Apache 1.3, use "--with-apxs" instead of "--with-apxs2". Using this script, the installation program can find the various configuration parameters needed for installing itself as an Apache2 module. 

In the case of our installation, "apxs" is a Perl script residing in /opt/apache/bin.  This can be checked by issuing the following command:

$ file /opt/apache/bin/apxs
/opt/apache/bin/apxs: perl script text executable 

--with-config-file-path=/usr/local/lib/php

This option tells the installation process where the newly linked PHP5module should look for the initialization file, called "php.ini":

--with-oci8 --enable-sigchild

Those two options tell the installer to enable the OCI8 module and the SIGCHLD delivery. Essentially, the SIGCHLD stops executing the database query when the httpd process stops executing the PHP5 script for any reason, such as the user pressing the browser "stop" button. For this to be successful, ORACLE_HOME must be defined.

The remaining options are here to disable SQLLite and MySQL bindings, which are unnecessary given the fact that we want to use PHP5 with Oracle RDBMS. As was the case with the Apache2 installation, the configuration script for PHP5 is rather complex and has numerous options that can be seen by executing ./configure –help,. It is also useful to read the documentation about installing PHP on the  PHP site, http://www.php.net .  That site contains a regular cornucopia of tremendously useful information.

The "configure" script is not specific to Apache or PHP, it is a FSF's GNU script; characteristic for GNU software. Many open source products use the configure script.  The result of the "configure" script is the file called "Makefile", which is an input for the make program.

Now, the user can simply execute "make". This will start compiling and linking and, if everything is correct, the end of the output will look like this:

Zend/zend_compile.lo Zend/zend_constants.lo Zend/zend_dynamic_array.lo Zend/zend_execute_API.lo Zend/zend_highlight.lo Zend/zend_llist.lo Zend/zend_opcode.lo Zend/zend_operators.lo Zend/zend_ptr_stack.lo Zend/zend_stack.lo Zend/zend_variables.lo Zend/zend.lo Zend/zend_API.lo Zend/zend_extensions.lo Zend/zend_hash.lo Zend/zend_list.lo Zend/zend_indent.lo Zend/zend_builtin_functions.lo Zend/zend_sprintf.lo Zend/zend_ini.lo Zend/zend_qsort.lo Zend/zend_multibyte.lo Zend/zend_ts_hash.lo Zend/zend_stream.lo Zend/zend_iterators.lo Zend/zend_interfaces.lo Zend/zend_exceptions.lo Zend/zend_strtod.lo Zend/zend_objects.lo Zend/zend_object_handlers.lo Zend/zend_objects_API.lo Zend/zend_mm.lo Zend/zend_default_classes.lo Zend/zend_reflection_api.lo Zend/zend_execute.lo sapi/cli/php_cli.lo sapi/cli/getopt.lo main/internal_functions_cli.lo -lcrypt -lcrypt -lresolv -lm -ldl -lnsl -lxml2 -lz -lm -lxml2 -lz -lm -ldl -lm -lnsl -lirc -lclntsh -lxml2 -lz -lm -lcrypt -lxml2 -lz -lm -lcrypt  -o sapi/cli/php

Build complete.

(It is safe to ignore warnings about tempnam and tmpnam).

PHP5 can now be installed. As was the case for Apache, root privilege is needed for the installation. As both programs follow GNU conventions, the installation is performed by issuing the "make install" command with root privilege.

$ su - root
Password:
[root@medo ~]# cd /tmp/php-5.0.3
[root@medo php-5.0.3]# make install

This installs PHP5 in the proper places to be used as an Apache2 module. The command line executables are installed in the "/usr/local/bin" directory because no "--prefix" argument is given to install it elsewhere.

The installation is not yet quite finished. If no prefix argument is given to the "configure" script, the Apache httpd.conf file which resides in the "conf" subdirectory of /opt/apache or /usr/local/conf  on some installations will need to be edited.  The user should then instruct Apache to load PHP5 as a module and should tell the server what to do with files that have ".php" suffixes. This is done by entering the following two lines in the httpd.conf:

LoadModule php5_module        modules/libphp5.so
AddType application/x-httpd-php  .php .php4 .php3 .php5

If this was performed correctly, the Apache server can be started by issuing the following command:

/opt/apache/bin/apachectl start

To verify that everything was done correctly, put the following script into a directory known to the Apache server:

First.php
<?php
    phpinfo();
?>

The usual name for this script is first.php. Here is what the result should look like:

This page contains all the necessary information about the new Apache2/PHP5 installation. The page itself is very large and shows the detailed specification of each installed module and the environment variable.

When the browser window is scrolled down, there should be a part with information about the OCI8 module and should look like the picture shown in Figure 8.6.

The information about the OCI8 module contains the ORACLE_HOME that was used to link PHP and the Oracle version that PHP is linked with.  There is also information for other modules like PCRE or XML. All environment variables such as $_session and $_serve are also shown.

There is only one thing that was not properly explained in the text above. When talking about where to put the script invoking the phpinfo() function, the phrase "directory known to Apache" was used.  Well, how is a directory made known to Apache?

The answer is "by putting it into the httpd.conf file".   On my server, the directory "/mydoc" is defined like this:

Alias /mydoc "/usr/local/mydoc/"
<Directory "/usr/local/mydoc">
allow from all
Options Indexes FollowSymLinks
</Directory>

The script is then placed on /usr/local/mydoc and invoked by pointing the browser to http://localhost/mydoc/first.php.

The installation of PHP5 is almost done. The php.ini with PHP5 parameters needs created. This is done by searching the source tree to find where the distribution was unpacked and where the "configure" script was run from:

find /tmp/php-5.0.3 -name "php.ini-*" -print
/tmp/php-5.0.3/php.ini-recommended
/tmp/php-5.0.3/php.ini-dist

Now, either the distribution ".ini" file or the recommended "ini" file to /usr/local/lib/php/php.ini can be copied, and the  installation is done.  For the parameters to take effect, restart the Apache server like this:

cp /tmp/php-5.0.3/php.ini-dist /usr/local/lib/php/php.ini
/opt/apache/bin/apachectl restart

Restarting the Apache server must be done as root, as is the case with any manipulation of system software.

Now, PHP is installed with the OCI8 enabled. What would be different if PHP5 was installed using the packaged Apache2 server that comes with the Linux distribution?  The only two things that would be different is the location of the "apxs" script given to the PHP "configure" script, and on Fedora Core 3, the httpd-devel package needs to be installed as well as httpd.  The "apxs" script would then be in /usr/sbin. Everything else would be the same.

This section would not be complete if the most important PHP parameters were not mentioned. The parameters that determine resource consumption are widely considered to be the most important of all parameters.  Here is the section that defines the resource consumption:

;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;

max_execution_time = 30     ; Maximum execution time of each script, in seconds

max_input_time = 60      ; Maximum amount of time each script may spend parsing request data

memory_limit = 8M      ; Maximum amount of memory a script may consume(8MB)

The parameter, max_execution_time, defines the maximum execution time for the PHP5 script. The time can be exceeded by setting the scripts own execution time limit.  The script can set its own time limit by invoking the set_time_limitfunction.  The syntax is very simple:

void set_time_limit( int seconds )

Setting the time limit to zero turns off the time limitations.  Setting the max_execution_timeparameter to zero also turns off the time limit for all PHP scripts on the system. It is recommended that the limit is adjusted on the per-script basis, rather than globally, for all scripts.

If the script attempts to execute a database query that needs more than this to complete, the PHP5 engine will kill the query when the time expires. This parameter imposes the upper limit on your form response time. If the PHP5 engine is to be used for executing long running jobs, this parameter must be adjusted.

The maximum memory that the script can consume is normally 8M and I have never had any need to increase it.  Be aware that Apache processes with PHP5 and Oracle can get quite large. Below is a picture produced by a Linux OS monitor, showing how large this process can become:

Each process takes 28.3 MB, and can grow if the process is actively executing a script that makes use of Oracle RDBMS. Oracle's PGA ("Private Global Area") can consume additional memory for sorting, hashing or storing cursor data and is not included into this memory limit. The memory limit in the parameter file is calculated as the combined size of all program variables. Please, be careful with increasing this memory limit as Apache processes may become enormous and may page the system to death.

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.

 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster
 
 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.