By cj on Apr 24, 2014
OTN have posted an updated guide for installing PHP on Oracle HTTP Server. Check it out!
Using PHP-FPM is a great way to integrate with Oracle Fusion Middleware.
I've published some vanilla PHP 5.4.0 RPMs to make new feature testing easier.
Along with all the PHP 5.4 goodies, the php-fpm "FastCGI Process Manager" is available for the first time on oss.oracle.com. Php-fpm is an alternative FastCGI interface to PHP with various extra features such as load dependent spawning of processes. (For other features, see php-fpm.org). Php-fpm has been getting more and more traction in the PHP community and the EXPERIMENTAL flag was removed in PHP 5.4. You might want to test it out.
To use php-fpm with the default Apache web server, first install Oracle Linux 5.8 (64bit) using Oracle's free, public yum repository public-yum.oracle.com.
Install Apache, if not already installed:
yum install httpd
Download and install the PHP 5.4 RPMs from oss.oracle.com/projects/php:
rpm -i php54-common-5.4.0-1.el5.x86_64.rpm php54-fpm-5.4.0-1.el5.x86_64.rpm
Other extensions can also be installed, depending on the functionality you want to test.
Download and build FastCGI for Apache:
wget http://www.fastcgi.com/dist/mod_fastcgi-current.tar.gz tar -zxf mod_fastcgi-current.tar.gz cd mod_fastcgi-2.4.6 cp Makefile.AP2 Makefile make top_dir=/usr/lib64/httpd
Install FastCGI as root:
make top_dir=/usr/lib64/httpd install
/etc/httpd/conf/httpd.conf and comment out any
existing references to PHP you might previously have added for
# LoadModule php5_module modules/libphp5.so # AddType application/x-httpd-php .php
Add the php-fpm configuration to
LoadModule fastcgi_module modules/mod_fastcgi.so <IfModule mod_fastcgi.c> FastCGIExternalServer /usr/sbin/php-fpm -host 127.0.0.1:9000 AddHandler php-fastcgi .php #<LocationMatch "/status"> # SetHandler php-fastcgi-virt # Action php-fastcgi-virt /usr/sbin/php-fpm.fcgi virtual #</LocationMatch> Action php-fastcgi /usr/sbin/php-fpm.fcgi ScriptAlias /usr/sbin/php-fpm.fcgi /usr/sbin/php-fpm <Directory /usr/sbin> Options ExecCGI FollowSymLinks SetHandler fastcgi-script Order allow,deny Allow from all </Directory> </IfModule>
Start php-fpm and Apache:
service php-fpm start service httpd start
Test it out with your favorite script or create a file
<?php phpinfo(); ?>
Save it in
/var/www/html/pi.php or in
$HOME/public_html/pi.php, if you have configured
In a browser load
This will show the PHP configuration values.
To test php-fpm's built-in statistics, edit
and uncomment the four lines of the
<LocationMatch "/status"> SetHandler php-fastcgi-virt Action php-fastcgi-virt /usr/sbin/php-fpm.fcgi virtual </LocationMatch>
/etc/php-fpm.conf and uncomment the line:
pm.status_path = /status
Restart php-fpm and Apache:
service php-fpm restart service httpd restart
Run some load on the system:
ab -c 10 -t 60 http://localhost/pi.php
http://localhost/status gives you the status of the server:
pool: www process manager: dynamic start time: 13/Mar/2012:14:25:53 -0700 start since: 26 accepted conn: 50001 listen queue: 0 max listen queue: 6 listen queue len: 128 idle processes: 2 active processes: 1 total processes: 3 max active processes: 5 max children reached: 1
php-fpm.conf file documents other output formats
for the statistics. It also shows the extensive functionality
available with php-fpm.
Php-fpm is commonly used in conjunction with the nginx webserver. For this, you will need to compile nginx yourself. Because php-fpm is installed and managed separately from the webserver, the php-fpm RPM will still be usable. Now that Apache 2.4 has been released with claims of improved performance, it will be interesting to see if web server popularity swings back towards Apache.
Finally, remember that the PHP RPMs on oss.oracle.com are for testing purposes only. They are not supported.
Update: In the Underground PHP & Oracle Manual, I simplified the httpd.conf options to this (note PHP was installed in a different location):
<IfModule mod_fastcgi.c> FastCGIExternalServer /opt/php544/sbin/php-fpm -host 127.0.0.1:9000 AddHandler php-fastcgi .php Action php-fastcgi /mycgi ScriptAlias /mycgi /opt/php544/sbin/php-fpm </IfModule>
Here are some key resources for working with PHP and Oracle technologies.
Oracle : Oracle Technology Network (OTN)
Homepage : The PHP Developer Center -- downloads, how-tos, sample code and discussion forums brought to you by OTN.
Read : PHP Articles -- a collection of informative articles on OTN.
PHP Oracle Database Extension : OCI8 is the most available and scalable PHP adapter for the Oracle database. It is included with PHP, and is also separately downloadable for upgrading older PHP releases. OCI8 works with PHP 4 and PHP 5, and will compile with Oracle 9iR2, 10g and 11g client libraries. Oracle's standard cross-version compatibility and connectivity is applicable, so OCI8 can connect to older or newer databases, locally or remotely. The latest OCI8 release includes support for Oracle Database 11g Database Resident Connection Pooling (DRCP), and for Fast Application Notification (FAN) [whitepaper here], and also has support for Oracle's authentication and end-to-end tracing meta data attributes [article here]. These features improve scalability and availabilty of the OCI8 extension.
The OCI8 extension can also be used with the Oracle In-Memory Database Cache.
Book : The Underground PHP & Oracle Manual -- the definitive, free guide to using PHP with Oracle Database.
Read : PHP & High Scalability -- covers enabling DRCP and FAN for PHP applications.
Read : PHP Web Auditing, Authorization and Monitoring with Oracle Database -- learn how to audit individual web users, automatically apply rules to individual web users to restrict data access, and monitor and trace database usage per application user.
Forum : The Oracle & PHP forum -- technical discussion forum for using PHP with Oracle.
Blog : PHP and Oracle: Christopher Jones -- The latest news on PHP and Oracle.
Database : Oracle Express Edition Database -- an entry-level, small-footprint database based on the standard Oracle Database code base that's free to develop, deploy, and distribute; fast to download; and simple to administer.
PHP OCI8 works with Oracle Database XE the same way it works with the other editions of Oracle Database.
Oracle Database XE is a great starter database for:
Database : MySQL -- The world's most popular open source database. MySQL Community Edition is the freely downloadable version. Commercial customers have the flexibility of choosing from multiple editions to meet specific business and technical requirements. Also available for free is the MySQL Workbench for SQL Authoring, System Administration, and schema modeling.
Recent additions to MySQL include semi synchronous replication, direct memcached-to-InnoDB access, multi-threaded replication, and enhanced partitioning. See What's new in MySQL 5.6
PHP's mysqli or PDO_mysql extensions can be used to access MySQL.
Homepage : Using MySQL With PHP -- Articles and downloads
Forum : PHP and MySQL forum -- The place to ask questions
Blog : Planet MySQL -- The latest MySQL news from the community
Blog : Johannes Schlüter -- A member of the MySQL connector team and the current PHP Release Master.
Blog : Me Talking Out Loud -- Ligaya Turmelle, a member of MySQL Support. (and contributer to The PHP Anthology: 101 Essential Tips, Tricks & Hacks)
Blog : Internet Super Hero -- Ulf Wendel, a member of the MySQL connector team.
Database : Oracle Berkeley DB 11g -- provides the complex data management features found in enterprise class databases. These facilities include high throughput, low-latency reads, non-blocking writes, high concurrency, data scalability, in-memory caching, ACID transactions, automatic and catastrophic recovery when the application, system or hardware fails, high availability and replication in an application configurable package. Simply configure the library and use the particular features available to satisfy your particular application needs. Berkeley DB can be configured to address any application need from the hand-held device to the datacenter, from a local storage solution to a world-wide distributed one, from kilobytes to petabytes.
Berkeley DB's SQL API allows PHP's sqlite3 and PDO_sqlite extensions to be used.
Berkeley DB also includes source code for a php_db4 extension.
IDE : NetBeans -- lets you develop desktop, mobile and web applications using Java, PHP, C/C++ and more. Runs on Windows, Linux, Mac OS X and Solaris. NetBeans IDE is open-source and free.
Understand: NetBeans PHP features -- All the great features that NetBeans has for PHP developers
Learn: NetBeans PHP Learning Trail -- the best way to learn how to use NetBeans
Virtualize : Oracle VM VirtualBox -- powerful Cross-platform Virtualization Software for x86-based systems. "Cross-platform" means that it installs on Windows, Linux, Mac OS X and Solaris x86 computers. And "Virtualization Software" means that you can create and run multiple Virtual Machines, running different operating systems, on the same computer at the same time. For example, you can run Windows and Linux on your Mac, run Linux and Solaris on your Windows PC, or run Windows on your Linux systems.
Oracle VM VirtualBox is available as Open Source or pre-built Binaries for Windows, Linux, Mac OS X and Solaris.
OTN hosts some pre-built Developer VMs , including an Oracle Tuxedo Web Application Server VM showing PHP support. There is also a Zend Server VM for PHP created by Zend. Zend Server is a complete, Oracle-enabled, enterprise-ready Web Application Server for running and managing PHP applications that require a high level of reliability, performance and security. Zend Server is available in community and supported editions.
Operating system : Oracle Linux -- free to download and distribute. As one of the most widely deployed operating systems today, Linux is increasingly being adopted for cloud-based solutions. Oracle Linux is the most complete and integrated solution available and delivers higher performance and better reliability at up to 7 times lower cost than Red Hat. Why Choose Oracle Linux over Red Hat Linux?
Oracle Linux 5.6 and 6 introduced PHP 5.3 packages. Subscribers to the Unbreakable Linux Network have access to an additional pre-built PHP OCI8 RPM, and also direct access to an RPM for installing Zend Server .
Users of older Linux 5 releases can get PHP 5.3 RPMs from oss.oracle.com .
Application Server : Oracle Tuxedo -- provides a robust, grid enabled platform for developing enterprise applications. It provides mainframe-class scale and performance on open, distributed systems for software written in C, C++, COBOL, PHP, Python and Ruby. Oracle Tuxedo provides cost-effective reliability, extreme scalability and throughput of hundreds of thousands of transactions per second. Functionality like Web services, SCA programming model, metadata driven application development make it simple to develop and integrate applications written in many programming languages.
PHP applications can be hosted on the Tuxedo platform without requiring any code changes and can leverage high availability, scalability and integration capabilities.
The whitepaper Oracle Tuxedo - An Enterprise Platform for Dynamic Languages explains the architecture and features. A Tuxedo Demo VM for VirtualBox is available for immediate testing.
Client Libraries : Oracle Instant Client -- a small footprint set of libraries that allows applications and tools to connect to an existing Oracle Database. Oracle OCI, OCCI, Pro*C, ODBC, and JDBC applications work without modification.
The PHP OCI8 extension can be built with Oracle Instant Client to connect to a remote database.
Instant Client is provided under a separate OTN Development and Distribution License for Instant Client that allows most licensees to download, redistribute, and deploy in production environments, without charge.
The Oracle Tuxedo team have posted an Oracle Tuxedo 220.127.116.11 Web Application Server Demo for PHP. It is a VirtualBox VM so you can immediately test it out. The free VM is available from OTN's Pre-Built Developer VMs page.
Oracle Tuxedo provides a scalable and highly available mid tier platform capable of managing and integrating heterogeneous applications. This overview datasheet explains its capabilities: "Oracle Tuxedo provides a service-oriented infrastructure for efficiently routing, dispatching, and managing requests, events, and application queues across system processes and application services". A raft of other material is on the Tuxedo landing page. There is also a new white paper on PHP being reviewed at this very moment.
The VM uses Oracle Linux 5.6. It has PHP 5.3 and Oracle Tuxedo 18.104.22.168 installed and configured. The SALT and TSAM components of Tuxedo are also available.
Tuxedo's PHP support comes in the form of a new mod_tuxedo module for Apache 2.2 (or Oracle HTTP Server). This handles all PHP scripts, executing them using managed PHP processes. Existing applications can run normally:
Tuxedo also lets PHP be exposed as a web service:
The tutorial manual provided inside the VM steps through using PHP in both ways. The NetBeans IDE, Oracle Database XE and MySQL are included on the VM to make it easier to carry out your own further experiments with Tuxedo and PHP.
Tuxedo has been around for a long time and has an established customer base. If you look at Oracle Database's big TPC-C benchmark's you can see Tuxedo was involved. It's even certified on Exalogic. The new dynamic language support in Tuxedo is going to open up "Enterprise" infrastructure, making it easy to integrate modern solutions in a heterogeneous environment.
When I get back from the Dutch PHP and PHP|Tek conferences, which run back to back from next week, I plan to write up more details about using Tuxedo and PHP.
Update: a new whitepaper is available: Oracle Tuxedo: An Enterprise Platform for Dynamic Languages.