Welcome to the world of PHP-FPM within openshift.
Current 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-phpIf 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-phpCurrently this cartridge has the following versions:
- PHP 5.5.22
- PHP 5.6.6
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 adviced to create a .openshift/action_hooks/build and add the following to it:
#!/bin/bash
set -e
# Build PHP extra's
# Update conf/ini filesand install pecl extensions
${OPENSHIFT_PHP_DIR}/bin/control buildNow 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.ini.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
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 --enable-phalcon
Don't forget to change your .openshift/nginx.conf.erb according to the phalcon nginx installation notes.
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-phpNow 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
./libs_packageOnce compiling is done you can download the php-{version}.tar.gz from you application.
Extract the php-{version} from the archive and place them into the openshift-cartridge-php/usr folder.
Last but not least edit the openshift-cartridge-php/manifest.yml and add the versions.
All done just commit and push to your openshift-cartridge-php repo and use:
rhc cartridge add -a myapp http://cartreflect-claytondev.rhcloud.com/github/<user>/openshift-cartridge-phpUpdating this catridge 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-phpThis will remove the old version and install the latest version.