Install PHP packages and configure PHP INI files, for using PHP from the CLI, the Apache httpd module or FastCGI.
The module is very Red Hat Enterprise Linux focused, as the defaults try to change everything in ways which are typical for RHEL, but should also work on other distributions and might be possible to port if needed.
php::cli
: Simple class to install PHP's Command Line Interfacephp::fpm::daemon
: Simple class to install PHP's FastCGI Process Managerphp::fpm::conf
: PHP FPM pool configuration definitionphp::ini
: Definition to create php.ini filesphp::mod_php5
: Simple class to install PHP's Apache httpd modulephp::module
: Definition to manage separately packaged PHP modulesphp::module::ini
: Definition to manage the ini files of separate modules
Create php.ini
files for different uses, but based on the same template :
php::ini { '/etc/php.ini':
display_errors => 'On',
memory_limit => '256M',
}
php::ini { '/etc/httpd/conf/php.ini':
mail_add_x_header => 'Off',
# For the parent directory
require => Package['httpd'],
}
Install the PHP command line interface :
include php::cli
Install the PHP Apache httpd module, using its own php configuration file (you will need mod_env in apache for this to work) :
class { 'php::mod_php5': inifile => '/etc/httpd/conf/php.ini' }
Install PHP modules which don't have any configuration :
php::module { [ 'ldap', 'mcrypt' ]: }
Configure PHP modules, which must be installed with php::module first :
php::module { [ 'pecl-apc', 'xml' ]: }
php::module::ini { 'pecl-apc':
settings => {
'apc.enabled' => '1',
'apc.shm_segments' => '1',
'apc.shm_size' => '64',
}
}
php::module::ini { 'xmlreader': pkgname => 'xml' }
php::module::ini { 'xmlwriter': ensure => absent }
Install PHP FastCGI Process Manager with a single pool to be used with nginx. Note that we reuse the 'www' name to overwrite the example configuration :
include php::fpm::daemon
php::fpm::conf { 'www':
listen => '127.0.0.1:9001',
user => 'nginx',
# For the user to exist
require => Package['nginx'],
}
Then from the nginx configuration :
# PHP FastCGI backend
upstream wwwbackend {
server 127.0.0.1:9001;
}
# Proxy PHP requests to the FastCGI backend
location ~ \.php$ {
# Don't bother PHP if the file doesn't exist, return the built in
# 404 page (this also avoids "No input file specified" error pages)
if (!-f $request_filename) { return 404; }
include /etc/nginx/fastcgi.conf;
fastcgi_pass wwwbackend;
}