PHP
Versions
Currently, OKD provides versions , 5.6, and of PHP.
These images come in two flavors, depending on your needs:
RHEL 7
RHEL 7 Based Images
The RHEL 7 images are available through the Red Hat Registry:
CentOS 7 Based Images
CentOS images for PHP 5.5 and 5.6 are available on Docker Hub:
To use these images, you can either access them directly from these image registries or push them into your . Additionally, you can create an image stream that points to the image, either in your container image registry or at the external location. Your OKD resources can then reference the image stream.
You can find for all the provided OKD images.
Build Process
S2I produces ready-to-run images by injecting source code into a container and letting the container prepare that source code for execution. It performs the following steps:
Starts a container from the builder image.
Downloads the application source.
Streams the scripts and application sources into the builder image container.
Runs the assemble script (from the builder image).
See for a detailed overview of the build process.
The PHP image supports a number of environment variables which can be set to control the configuration and behavior of the PHP runtime.
To set these environment variables as part of your image, you can place them into a .s2i/environment file inside your source code repository, or define them in of the build configuration’s definition.
You can also set environment variables to be used with an existing image when creating new applications, or by such as deployment configurations.
The following environment variables set their equivalent property value in the php.ini file:
Variable Name | Description | Default |
---|---|---|
Informs PHP of the errors, warnings, and notices for which you would like it to take action. | E_ALL & ~E_NOTICE | |
| Controls if and where PHP outputs errors, notices, and warnings. | ON |
| Causes any display errors that occur during PHP’s startup sequence to be handled separately from display errors. | OFF |
| Stores the last error/warning message in | OFF |
| Links errors to documentation that is related to the error. | ON |
Path for PHP source files. | .:/opt/openshift/src:/opt/rh/php55/root/usr/share/pear | |
| Location for session data files. | /tmp/sessions |
| Path that defines the document root for your application (for example, /public). |
The following environment variable sets its equivalent property value in the opcache.ini file:
You can also override the entire directory used to load the PHP configuration by setting:
Variable Name | Description |
---|---|
| Sets the path to the php.ini file. |
| Path to scan for additional .ini configuration files |
You can use a custom composer repository mirror URL to download packages instead of the default ‘packagist.org’:
If the **DocumentRoot**
of the application is nested in the source directory /opt/openshift/src, you can provide your own .htaccess file to override the default Apache behavior and specify how application requests should be handled. The .htaccess file must be located at the root of the application source.
Accessing Logs
Access logs are streamed to standard out and as such they can be viewed using the command. Error logs are stored in the /tmp/error_log file, which can be viewed using the oc rsh
command to access the container.
Hot deployment allows you to quickly make and deploy changes to your application without having to generate a new S2I build. In order to immediately pick up changes made in your application source code, you must run your built image with the **OPCACHE_REVALIDATE_FREQ=0**
environment variable.
For example, see the command. You can use the oc env
command to update environment variables of existing objects.
You should only use this option while developing or debugging; it is not recommended to turn this on in your production environment. |
To change your source code in a running pod, use the command to enter the container:
After you enter into the running container, your current directory is set to /opt/app-root/src, where the source code is located.