PHP Packages for Oracle Linux
This page describes PHP and related packages for current releases of Oracle Linux. For Oracle Linux 8, the packages are provided via AppStream modules and are covered under Oracle Linux support. Consult the Application Stream Module Life Cycle appendix in the Managing Software in Oracle Linux manual for support timelines. For Oracle Linux 7, these packages are published in developer repositories, for which support is limited to package installation assistance only.
Available PHP Releases
| PHP Version | Oracle Linux Release | Repository/Module Name |
|---|---|---|
| 8.0 | Oracle Linux 9 | OL9 AppStream / php:8.0 |
| 8.0 | Oracle Linux 8 | OL8 AppStream / php:8.0 |
| 7.4 | Oracle Linux 8 | OL8 AppStream / php:7.4 |
| 7.3 | Oracle Linux 8 | OL8 AppStream / php:7.3 |
| 7.2 | Oracle Linux 8 | OL8 AppStream / php:7.2 |
| 7.4 | Oracle Linux 7 | OL7 Developer / php74 |
Installation on Oracle Linux 7
These are the steps to install PHP.
Set up Required Repositories
To configure the yum repositories shown above on your system, install the repository setup packageoracle-php-release-el7. After installing this package, the default enabled repository is that for the latest available PHP release. To install the repository setup package for Oracle Linux 7:
$ sudo yum install -y oracle-php-release-el7
Installing PHP
Then, to install the latest available release of PHP on Oracle Linux 7:
$ sudo yum install -y php
Updating PHP
If you have PHP already installed, and a newer release has been published, make sure you update oracle-php-release-el7 first.
$ sudo yum update oracle-php-release-el7
$ sudo yum update php
Connecting PHP to Oracle Database with the PHP OCI8 Extension
The PHP OCI8 database extention enables access to Oracle Database with support for SQL, PL/SQL, bind variables, large object (LOB) types as well connection pooling and result caching features of Oracle Database. Read this blog post for a complete example connecting a PHP 7.4 application to Oracle Database.
Installing PHP OCI8
Each PHP release has its own repository on Oracle Linux yum server and each of those repositories also contains a corresponding RPM for the OCI8 extension, built for a specific major release of Oracle Instant Client. These RPMs follow this naming scheme: php-oci8 . For example, on Oracle Linux 7, the PHP OCI8 RPM for PHP 7.4 is built with Instant Client 19c and is named: php-oci8-19c. To install it:
$ sudo yum install php-oci8-19c
About Oracle Instant Client
PHP OCI8 depends on Oracle Instant Client. Starting with Oracle Instant Client 21c, yum/dnf configuration files are delivered via the packages oracle-instantclient-release-el8 and oracle-instantclient-release-el7, respectively. Oracle Instant Client packages up to release 19c are in the ol7_oracle_instantclient and ol8_oracle_instantclient repositories, configured with release packages oracle-release-el7 and oracle-release-el8. Assuming you have enabled the repository for Oracle Instant Client appropriate for your Oracle Linux release, it will be installed as a dependency. More details about Oracle Instant Client on this yum server.
Installing PHP on Oracle Linux 8 via AppStream Modules
Oracle Linux 8 introduces the concept of Application Streams, where multiple versions of user-space components can be delivered and updated more frequently than the core operating system packages in RPM format or groups of related RPMs called Modules. Oracle Linux 8 offers several independently updated versions of PHP via Module Streams. For mode details, please refer to the documentation.
To list available Module Streams for PHP:
$ dnf module list php
To install PHP 7.4 :
$ sudo dnf install @php:7.4
Installing PHP OCI8 on Oracle Linux 8
To install the PHP OCI8 on Oracle Linux 8, enable both the php:7.4 and the php-oci8 modules.
$ sudo dnf install oraclelinux-developer-release-el8 oracle-instantclient-release-el8
$ sudo dnf module enable php:7.4 php-oci8
$ sudo dnf install php-oci8-21c
Installation on Oracle Linux 9
To install the latest available release of PHP on Oracle Linux 9:
$ sudo dnf install php
PHP in Containers
- PHP Command Line Interface tool (PHP CLI)
- PHP via FastCGI Process Manager (FPM)
- PHP via Apache HTTP Server with mod_php
- Variants of each of the above with Oracle Database connectivity via PHP-OCI8
- Example Dockerfiles for PHP: Oracle Linux 8, Oracle Linux 7
- PHP container images on GitHub Container registry: Oracle Linux 8, Oracle Linux 7
Getting Help
For help with PHP on Oracle Linux, please visit the PHP space in the Oracle Developer Community.
Setting up PHP with Lighttpd¶
In all our tests it has shown better performance than Apache 1.3.x + mod_php4. See http://www.lighttpd.net/benchmark/ for the results.
Does it support opcode cachers?¶
like APC, TurckMM, XCache and friends
YES! Even if their docs say they do not work in CGI. Under lighttpd, PHP is usually run as FastCGI which supports those opcode cachers like mod_php4 in Apache.
- http://pecl.php.net/apc
- http://eaccelerator.net/ (Successor of Turck mmCache)
- XCache, XCache FAQ (new, well tested, running with FastCGI)
You might be interested in reading the Support for FASTCGI mode? thread from eAccelerator Open Discussion Forum.
Installation¶
Windows¶
PHP in CGI Mode¶
DevelWin32 is recommended to build your own native _WIN32 lighttpd.
Alternatively, install the out-dated, third-party, unmaintained, not-recommended Lighttpd for Windows. Then you need to edit C:\lighttpd\etc\lighttpd.conf, uncomment the "mod_cgi" line and add this line:
cgi.assign = ( ".php" => "c:/php/php-cgi.exe" )
Be careful, there cannot be any space in the path to PHP-CGI in the above snippet. Save lighttpd.conf and restart lighttpd. Open your browser and go to http://localhost/, you should have a welcome page. You can put your PHP files in C:\lighttpd\htdocs - To test PHP, just create a file named index.php, save it in the Lighttpd root directory (C:\lighttpd\htdocs) and paste this content into this file:
Accessing http://localhost/, you should get a page that lists all PHP variables and information.
Please note that FastCGI doesn't work on Windows at this time. Good luck!
Update: DevelWin32 _WIN32 prototype supports FastCGI.
PHP in Fast CGI Mode¶
DevelWin32 is recommended to build your own native _WIN32 lighttpd.
Alternatively, download the out-dated, third-party, unmaintained, not-recommended Lighttpd for Windows from http://lighttpd.dtech.hu/
Download the latest PHP for Windows (VC9, Non Thread Safe) from http://windows.php.net/download/
Unpack the distribution so you have a directory structure similar to this:
c:\LightTPD c:\PHP (be sure to rename php.ini-production to php.ini)
Open c:\LightTPD\lighttpd.conf and uncomment the line "mod_fastcgi".
WARNING ABOUT PORT: Many guides suggest setting PHP to port 9000. The XDebug extension uses port 9000 by default.
Around line 150 of lighttpd.conf (you can search for "fastcgi module"), uncomment the following lines and alter them to match the following:
#### fastcgi module ## read fastcgi.txt for more info ## for PHP don't forget to set cgi.fix_pathinfo = 1 in the php.ini ## . and PHP_FCGI_MAX_REQUESTS = 0 environment variable in system properties fastcgi.server = ( ".php" => ( "localhost" => ( "host" => "127.0.0.1", "port" => 9123 ) ) ) ## map multiple extensions to the same fastcgi server fastcgi.map-extensions = ( ".php3" => ".php", ".php4" => ".php", ".php5" => ".php", ".phps" => ".php", ".phtml" => ".php" )
Host and port points to the ip address and port where the fastcgi daemon (in this case, PHP-CGI) will be listening.
There's also a bug in the Windows version that requires another edit in lighttpd.conf. Around line 50, change the following lines:
#### include important configuration files ## include path variables include "variables.conf" ## include mimetype mapping file include "mimetype.conf" ## include virtual hosts (optional) #include "vhosts.conf"
#### include important configuration files ## include path variables include "c:/lighttpd/conf/variables.conf" ## include mimetype mapping file include "c:/lighttpd/conf/mimetype.conf" ## include virtual hosts (optional) #include "c:/lighttpd/conf/vhosts.conf"
Next start the php-cgi daemon from the php directory:
c:\php\php-cgi.exe -b 127.0.0.1:9123
And then (re)start the LightTPD web server.
cd c:\lighttpd && lighttpd.exe -f conf\lighttpd.conf -m modules
You can put your PHP files in C:\lighttpd\htdocs. Lighttpd builds for Windows have an index.php in this folder for testing purposes.
Accessing http://localhost/, you should get a page that lists all PHP variables and information.
Once you have tested the configuration, you should stop PHP and Lighttpd with the following command BEFORE proceeding:
taskkill /f /IM lighttpd.exe && taskkill /f /IM php-cgi.exe
Starting PHP-FastCGI and Lighttpd with a batch file¶
If all is OK you could write a batch file to start/stop the server and the PHP daemon at the same time. Please note that you should have the RunHiddenConsole.exe in your path, also this files should be placed in c:\LightTPD
@ECHO OFF ECHO Starting PHP FastCGI. cd c:\php set PHP_FCGI_MAX_REQUESTS=0 RunHiddenConsole.exe c:\PHP\php-cgi.exe -b 127.0.0.1:9123 ECHO Starting LightTPD. ECHO. cd c:\lighttpd lighttpd.exe -v ECHO. lighttpd.exe -f conf\lighttpd.conf -m modules EXIT
@ECHO OFF ECHO Stopping LightTPD. taskkill /f /IM lighttpd.exe ECHO Stopping PHP FastCGI. taskkill /f /IM php-cgi.exe ECHO. EXIT
Running PHP-FastCGI and Lighttpd as services¶
The "winsw--bin.exe" needs to be saved to the folder containing php-cgi.exe (usually c:\php), and needs to be renamed "pwinsw.exe".
Pwinsw.exe then needs to be copied to the Lighttpd folder (usually c:\lighttpd) and renamed to lwinsw.exe (Letter L, not I).
In the PHP folder, create an xml file "pwinsw.xml" with the following content:
PHP PHP PHP C:\php\php-cgi.exe C:\php\php-stop.cmd C:\lighttpd\logs roll -b 127.0.0.1:9123 -cc:\php\php.ini
In the PHP folder, also create a batch file "php-stop.cmd" with the following content:
taskkill /f /IM php-cgi.exe
In the Lighttpd folder, create an xml file "lwinsw.xml" (Letter L, not letter I) with the following content:
Lighttpd Lighttpd Lighttpd C:\lighttpd\lighttpd.exe C:\lighttpd\lighttpd-stop.cmd C:\lighttpd\logs roll -fc:/lighttpd/conf/lighttpd.conf -mc:/lighttpd/modules -D
In the Lighttpd folder, also create a batch file "lighttpd-stop.cmd" with the following content:
taskkill /f /IM lighttpd.exe
Open a command prompt and run the following command:
c:\lighttpd\lwinsw.exe install && c:\php\pwinsw.exe install && net start Lighttpd && net start PHP
If there are any services named "Lighttpd" or "PHP", or if both copies of winsw.exe are named "winsw.exe" and not "lwinsw.exe" and"pwinsw.exe", this step will fail.
At this point, the Lighttpd and PHP services should now be installed.
Start Lighttpd: net start lighttpd Stop Lighttpd: net stop lighttpd Check Lighttpd status: c:\lighttpd\lwinsw.exe status Start PHP: net start PHP Stop PHP: net stop PHP Check PHP status: c:\PHP\pwinsw.exe status
You can now visit http://localhost/ and you should see the PHP information page.
Unix Systems¶
'''Startingpoint:''' Lighttpd is already [wiki:TutorialInstallation installed and working]
First of all you need a PHP which is providing FastCGI support. Depending on your
distribution you might already have it:
!Arch Linux¶
FreeBSD¶
#!ShellExample $ cd /usr/ports/lang/php5 # make install clean
Be sure to check the "Build FPM version" option in the configuration screen. If you don't see the configuration screen, you're either using an old version of ports tree, or need to execute "make config". If you're using PHP 4 or an early version of PHP 5, you may have to use www/php4-cgi or a similar port instead of the new master port.
PC-BSD¶
Download the self-executable setup wizard, double-click the file, and follow the instructions of the setup wizard. You will have a "www" directory under your home directory to put your web pages. You'll have the possibility to launch lighttpd at system startup automatically, and to support one or several users. Once you're done, just open http://localhost/ in your favorite browser and you should see the welcome screen.
Gentoo¶
Make sure the USE flag 'cgi' is enabled.
#!ShellExample $ emerge -av dev-lang/php
If it is not, add the USE flag your /etc/make.conf or just to the dev-lang/php ebuild.
#!ShellExample # echo dev-lang/php cgi >> /etc/portage/package.use
XCache is also in the official tree (as of 2007-02-03), so emerge dev-php5/xcache should simply work out-of-the-box as well.
Debian / Ubuntu¶
Debian/Ubuntu provides a fastcgi enabled version.
#!ShellExample # apt-get install php4-cgi
If you're using php5-cgi, all you need is change your "bin-path" at your configuration (Debian uses /usr/bin/php4-cgi as default).
pkgsrc (NetBSD, DragonFlyBSD and others)¶
PKG_OPTIONS.php = fastcgi
to your mk.conf. PHP can found in www/php4 and lang/php5. The fastcgi binary is located in /usr/pkg/libexec/cgi-bin/php
Others¶
Download a source tar-ball from http://www.php.net/ and configure it with at least this settings:
#!ShellExample $ ./configure \ --enable-fastcgi \ --enable-discard-path \ --enable-force-cgi-redirect
If you want to have the same PHP as you are using in a mod_php configuration somewhere else call
- copy the configure options from the output of the script
- remove the ` --with-apxs@` and ` --with-apxs2 `@ options
- add the three options from above.
Build PHP now by callings `@make ` and ` make install `@ and see if you can find a php binary which is responding:
#!ShellExample $ php -v PHP 5.0.3 (cgi-fcgi) (built: Dec 21 2004 12:59:18) Copyright (c) 1997-2004 The PHP Group Zend Engine v2.0.3, Copyright (c) 1998-2004 Zend Technologies with eAccelerator v0.9.3, Copyright (c) 2004-2005 eAccelerator, by eAccelerator
or something like this. The ` (cgi-fcgi) ` is the important part. The binary might also be called `@php-cgi `@.
so do something like php-cgi -v to see the (cgi-fcgi) banner.
#!ShellExample $ php-cgi -v PHP 4.4.2 (cgi-fcgi) (built: Jul 21 2006 15:45:58) Copyright (c) 1997-2006 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
If you still can't find it follow this hint:
#!ShellExample $ ls sapi/cgi/php*
Configuration¶
cgi.fix_pathinfo = 1
to your php.ini, and make sure mod_fastcgi is loaded in your lighttpd.conf:
server.modules = ( "mod_fastcgi", )
Then add this basic section to the same file:
fastcgi.server = ( ".php" => (( "bin-path" => "/path/to/php-cgi", "socket" => "/tmp/php.socket" )))
A little bit more advance is this setting which tries the tune some more options. If you need PATH_INFO the broken-scriptfilename is
for you.
fastcgi.server = ( ".php" => (( "bin-path" => "/path/to/php-cgi", "socket" => "/tmp/php.socket", "max-procs" => 2, "bin-environment" => ( "PHP_FCGI_CHILDREN" => "16", "PHP_FCGI_MAX_REQUESTS" => "10000" ), "bin-copy-environment" => ( "PATH", "SHELL", "USER" ), "broken-scriptfilename" => "enable" )))
It is important to set '''"max-procs"''' to 1 if you're using any php opcode cacher, unless you know what you're doing. Increase PHP_FCGI_CHILDREN if you want more childs serving the request.
- Docs:Configuration
- Docs:ModFastCGI
and use
http://trac.lighttpd.net/trac/browser/tags/lighttpd-1.4.11/doc/lighttpd.conf as starting point for the configuration.
Per directory PHP Config¶
If you're used to use Apache .htaccess files to set PHP options for each directory, see HowToPhpHtaccess :
''When using a cgi version of php (plain old cgi or fast-cgi) apache can't pass
any php settings from htaccess files it parses. This can be solved by giving
each user its own php.ini file, but I didn't like that solution.
This extension parses these configuration files (in most cases .htaccess) and
changes the settings. It will search all directories for a configuration file
from the docroot until the directory where the request scripts is found. A cache
is implemented to minimize the performance impact.''
htscanner (windows DLLs are available at pecl4win.php.net)
You can use the htscanner extension to solve this problem when you move from mod_php to fast-cgi. You can find the extension here http://pecl.php.net/htscanner (windows DLLs are available here http://pecl4win.php.net)
See the README file for more information.
See Also¶
- How to setup fastcgi and php with individual permissions
- How to setup PHP and Lighty in FreeBSD
- Handy External Spawning FastCGI PHP Processes in FreeBSD
- Using a PHP to control remote linking
- X-LIGHTTPD-send-file (or X-Sendfile): See what it can do for you on large file-downloads
External links¶
- Howto: Lighttpd FasCGI PHP, MySQL chroot jail installation under Debian Linux
- lighttpd php-fastcgi config with its own php.ini
| RunHiddenConsole.zip (1,01 КБ) RunHiddenConsole.zip | Run Hidden Console (Helper Application for Win32 fastCGI batch) | Аноним, 2007-08-21 00:24 |
