Welcome to the world of PHP-FPM within openshift.
Currently this cartridge works well the boekkooi NGINX cartridge.
You can add this cartridge to your application using:
rhc cartridge add -a myapp http://cartreflect-claytondev.rhcloud.com/github/boekkooi/openshift-cartridge-php
If you want to install a specific PHP version you can add --env OPENSHIFT_PHP_VERSION=<version>
to the command.
For example to install PHP 5.5.22 you can use:
rhc cartridge add -a myapp --env OPENSHIFT_PHP_VERSION=5.5.22 http://cartreflect-claytondev.rhcloud.com/github/boekkooi/openshift-cartridge-php
Currently this cartridge has the following versions:
- PHP 7.0.7
- PHP 5.6.22
- PHP 5.6.16
- PHP 5.5.36
- PHP 5.5.22
If you need another version you can compile it yourself and submit a PR to get it integrated.
For the best result with this cartridge you are advised to create a .openshift/action_hooks/build
and add the following to it:
#!/bin/bash
set -e
# Build PHP extra's
# Update conf/ini files and install pecl extensions
${OPENSHIFT_PHP_DIR}/bin/control build
Now it's time to configure nginx edit your .openshift/nginx.conf.erb
and add the following within the server
section:
# pass the PHP scripts to PHP-FPM
location ~ \.php$ {
fastcgi_pass unix:<%= ENV['OPENSHIFT_PHP_SOCKET'] %>;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include <%= ENV['OPENSHIFT_NGINX_DIR'] %>/usr/nginx-<%= ENV['OPENSHIFT_NGINX_VERSION'] %>/conf/fastcgi_params;
}
If you have created .openshift/action_hooks/build
you can fully customize the PHP configuration.
In your application create the following directories:
.openshift/cli/
.openshift/fpm/
In the cli
directory create the php.ini.erb
file and copy the content from conf/php.ini.erb
into it.
Now you can customize the cli php configuration.
In the fpm
directory create the php.ini.erb
file and copy the content from conf/php-fpm.ini.erb
into it.
Also create the php-fpm.conf.erb
file and copy the content from conf/php-fpm.conf.erb
into it.
Now you can customize the php-fpm configuration.
Composer is installed by default and can be used by simply ssh to your application and typing in composer
.
So where is PEAR? It's not there! Why? Read The rise of Composer and the fall of PEAR.
If you really need PEAR then download it your self using php go-pear.phar
and pray it work. Any PR's related to PEAR or failure to install it will be ignored
If you have created .openshift/action_hooks/build
you can create the .openshift/php-pecl.txt
to auto install pecl extensions.
This file must constain have a pecl extension name and version per line for example:
apcu 4.0.7
mongo 1.6.5
Note for Openshift online: even though the scripts should automatically add the extension declaration in the php.ini files, if you have custom ini.erb files the extension declaration might be overwritten when they are deployed. In that case you must declare the extension manually in your .ini.erb files.
There is special support for phalcon you can simply install it by adding the following to your .openshift/php-pecl.txt
file.
phalcon 1.3.4
Don't forget to change your .openshift/nginx.conf.erb
according to the phalcon nginx installation notes.
Be aware that to compile phalcon 2.x you need a medium gear because 1GB of RAM is required
To compile a new version you will first need a openshift application.
rhc create-app nginx http://cartreflect-claytondev.rhcloud.com/github/boekkooi/openshift-cartridge-nginx
Now clone the repository and create a php
folder. Now copy the usr/compile
directory from this repository.
Now set the versions you need to compile in the php/compile/versions
file. Commit and push the application repository.
SSH into your app and go to the compile folder (cd ${OPENSHIFT_REPO_DIR}/php/compile
) and start compiling by running the following commands:
./libs
./php
Once compiling is done you can download the php-{version}.tar.gz
from you application.
Place the archive into the openshift-cartridge-php/usr
folder.
Last but not least edit the openshift-cartridge-php/manifest.yml
and add the versions.
(Make sure you have Git LFS installed.)
Now commit and push to your openshift-cartridge-php
repo and create a PR.
To use your own fork make sure you change LFS_ENDPOINT
in openshift-cartridge-php/bin/setup
and use:
rhc cartridge add -a myapp http://cartreflect-claytondev.rhcloud.com/github/<user>/openshift-cartridge-php
Updating this cartridge is not as easy as I would like because openshift online won't allow updates for downloaded cartridges. To update the cartridge you can do the following:
rhc cartridge remove -a myapp --confirm php
rhc cartridge add -a myapp http://cartreflect-claytondev.rhcloud.com/github/<user>/openshift-cartridge-php
This will remove the old version and install the latest version.