-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding php5 module configuration. Includes overriding a few parameter…
…s from the php.ini defaults without editing that file; 'off-by-default', with the ability to turn on php for <Directory> or <Location>. Access control by host or ip is done via the standard access.pp controls.
- Loading branch information
Showing
6 changed files
with
145 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
class apache2::php | ||
( | ||
$phpMemoryLimit, | ||
$phpErrorLog = "/var/log/apache2/php-error_log", | ||
$phpExposePhp = "off", | ||
$phpTimezone = "America/Los_Angeles", | ||
$appDirs = [] | ||
) | ||
{ | ||
include apache2::params | ||
|
||
#validate_re( $phpMemoryLimit, "^[0..9]+[MmGg]" ) | ||
validate_string( $phpMemoryLimit ) | ||
validate_string( $phpErrorLog ) | ||
validate_re( $phpExposePhp, "^(on|off)" ) | ||
validate_string( $phpTimezone ) | ||
validate_array( $appDirs ) | ||
|
||
# install the package | ||
package { $params::phpPackageName : | ||
ensure => latest, | ||
} | ||
|
||
# include the module | ||
apache2::enableModule{ 'php5': | ||
require => Package[ $params::phpPackageName ], | ||
} | ||
|
||
# Pick the template path we're going to use | ||
$mod_path = get_module_path('apache2') | ||
$specific = "$mod_path/templates/$operatingsystem/$operatingsystemrelease$params::phpConfigPath.erb" | ||
$default = "$mod_path/templates/default$params::phpConfigPath.erb" | ||
|
||
# write the config file | ||
file { $params::phpConfigPath : | ||
ensure => file, | ||
content => inline_template( file( $specific, $default ) ), | ||
notify => $apache2::serviceNotify, | ||
require => Package[ $params::phpPackageName ], | ||
} | ||
|
||
# if any apps were specified, create them | ||
class { 'apache2::php::app' : } | ||
if ( is_array( $appDirs ) and size( $appDirs ) > 0 ) { | ||
apache2::php::addAppDir{ $appDirs : } | ||
} | ||
if ( is_array( $appLocs ) and size( $appLocs ) > 0 ) { | ||
apache2::php::addAppLoc{ $appLocs : } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
class apache2::php::app | ||
{ | ||
concat { $params::phpAppsConfigPath : | ||
ensure => present, | ||
notify => $apache2::serviceNotify, | ||
require => Package[ $params::phpPackageName ], | ||
} | ||
|
||
|
||
concat::fragment { "$params::phpAppsConfigPath-fragment-pre" : | ||
target => $params::phpAppsConfigPath, | ||
order => 01, | ||
content => "<IfModule mod_php5.c>\n", | ||
} | ||
|
||
concat::fragment { "$params::phpAppsConfigPath-fragment-post" : | ||
target => $params::phpAppsConfigPath, | ||
order => 99, | ||
content => "</IfModule>\n", | ||
} | ||
} | ||
|
||
define apache2::php::addAppDir | ||
( | ||
$appDir = $name | ||
) | ||
{ | ||
include apache2::params | ||
|
||
validate_string( $appDir ) | ||
|
||
# Pick the template path we're going to use | ||
$mod_path = get_module_path('apache2') | ||
$specific = "$mod_path/templates/$operatingsystem/$operatingsystemrelease$params::phpAppsConfigPath-appDir-frag.erb" | ||
$default = "$mod_path/templates/default$params::phpAppsConfigPath-appDir-frag.erb" | ||
|
||
# write the config file | ||
concat::fragment { $appDir : | ||
target => $params::phpAppsConfigPath, | ||
order => 10, | ||
content => inline_template( file( $specific, $default ) ), | ||
} | ||
|
||
} | ||
|
||
define apache2::php::addAppLoc | ||
( | ||
$appLoc = $name | ||
) | ||
{ | ||
include apache2::params | ||
|
||
validate_string( $appLoc ) | ||
|
||
# Pick the template path we're going to use | ||
$mod_path = get_module_path('apache2') | ||
$specific = "$mod_path/templates/$operatingsystem/$operatingsystemrelease$params::phpAppsConfigPath-appLoc-frag.erb" | ||
$default = "$mod_path/templates/default$params::phpAppsConfigPath-appLoc-frag.erb" | ||
|
||
# write the config file | ||
concat::fragment { $appLoc : | ||
target => $params::phpAppsConfigPath, | ||
order => 10, | ||
content => inline_template( file( $specific, $default ) ), | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<IfModule mod_php5.c> | ||
<% if @phpMemoryLimit -%> | ||
# Set the memory limit | ||
php_admin_value memory_limit <%= @phpMemoryLimit %> | ||
<% end -%> | ||
|
||
# Don't tell folks we're using php | ||
php_admin_value expose_php <%= @phpExposePhp %> | ||
|
||
# Set the timezone | ||
php_value date.timezone <%= @phpTimezone %> | ||
|
||
# Where is the error_log? | ||
php_value error_log <%= @phpErrorLog %> | ||
|
||
# Include the application definition file. | ||
IncludeOptional /etc/apache2/conf.d/php5Apps.conf.inc | ||
</IfModule> |
4 changes: 4 additions & 0 deletions
4
templates/default/etc/apache2/conf.d/php5Apps.conf.inc-appDir-frag.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<Directory "<%= @appDir -%>*"> | ||
# see conf.d/access.conf for other access controls | ||
AddHandler application/x-httpd-php .php | ||
</Directory> |
4 changes: 4 additions & 0 deletions
4
templates/default/etc/apache2/conf.d/php5Apps.conf.inc-appLoc-frag.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<Location "/<%= @appLoc -%>*"> | ||
# see conf.d/access.conf for other access controls | ||
AddHandler application/x-httpd-php .php | ||
</Location> |