Skip to content

Commit

Permalink
Merge pull request #481 from igalic/php_admin
Browse files Browse the repository at this point in the history
Support php_admin_(flag|value)s
  • Loading branch information
blkperl committed Dec 13, 2013
2 parents aa6d93a + c02259f commit 498d36e
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,10 @@ This directive must be used with `suphp_engine => on` in the vhost declaration.
}
```

######`php_admin_value` and `php_admin_flag`

Allows per-vhost (and per-directory) setting [`php_admin_value`s or `php_admin_flag`s](http://php.net/manual/en/configuration.changes.php). These flags or values cannot be overwritten by a user, or an application.

######`custom_fragment`

Pass a string of custom configuration directives to be placed at the end of the
Expand Down
4 changes: 4 additions & 0 deletions manifests/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@
$suphp_addhandler = $apache::params::suphp_addhandler,
$suphp_engine = $apache::params::suphp_engine,
$suphp_configpath = $apache::params::suphp_configpath,
$php_admin_flags = [],
$php_admin_values = [],
$no_proxy_uris = [],
$redirect_source = '/',
$redirect_dest = undef,
Expand Down Expand Up @@ -426,6 +428,8 @@
# - $block
# directories fragment:
# - $passenger_enabled
# - $php_admin_flags
# - $php_admin_values
# - $directories (a list of key-value hashes is expected)
# fastcgi fragment:
# - $fastcgi_server
Expand Down
36 changes: 36 additions & 0 deletions spec/defines/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,42 @@
:value => 'on',
:match => [/^ suPHP_Engine on$/],
},
{
:title => 'should accept a php_admin_flags',
:attr => 'php_admin_flags',
:value => { 'php_engine' => 'on' },
:match => [/^ php_admin_flag php_engine on$/],
},
{
:title => 'should accept php_admin_values',
:attr => 'php_admin_values',
:value => { 'open_basedir' => '/srv/web/www.com/:/usr/share/pear/' },
:match => [/^ php_admin_value open_basedir \/srv\/web\/www.com\/:\/usr\/share\/pear\/$/],
},
{
:title => 'should accept php_admin_flags in directories',
:attr => 'directories',
:value => {
'path' => '/srv/www',
'php_admin_flags' => { 'php_engine' => 'on' }
},
:match => [/^ php_admin_flag php_engine on$/],
},
{
:title => 'should accept php_admin_values',
:attr => 'php_admin_values',
:value => { 'open_basedir' => '/srv/web/www.com/:/usr/share/pear/' },
:match => [/^ php_admin_value open_basedir \/srv\/web\/www.com\/:\/usr\/share\/pear\/$/],
},
{
:title => 'should accept php_admin_values in directories',
:attr => 'directories',
:value => {
'path' => '/srv/www',
'php_admin_values' => { 'open_basedir' => '/srv/web/www.com/:/usr/share/pear/' }
},
:match => [/^ php_admin_value open_basedir \/srv\/web\/www.com\/:\/usr\/share\/pear\/$/],
},
{
:title => 'should accept a wsgi script alias',
:attr => 'wsgi_script_aliases',
Expand Down
1 change: 1 addition & 0 deletions templates/vhost.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<%= scope.function_template(['apache/vhost/_setenv.erb']) -%>
<%= scope.function_template(['apache/vhost/_ssl.erb']) -%>
<%= scope.function_template(['apache/vhost/_suphp.erb']) -%>
<%= scope.function_template(['apache/vhost/_php_admin.erb']) -%>
<%= scope.function_template(['apache/vhost/_requestheader.erb']) -%>
<%= scope.function_template(['apache/vhost/_wsgi.erb']) -%>
<%= scope.function_template(['apache/vhost/_custom_fragment.erb']) -%>
Expand Down
11 changes: 11 additions & 0 deletions templates/vhost/_directories.erb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@
<%- if directory['passenger_enabled'] and directory['passenger_enabled'] != '' -%>
PassengerEnabled <%= directory['passenger_enabled'] %>
<%- end -%>
<%- if directory['php_admin_flags'] and ! directory['php_admin_flags'].empty? -%>
<%- directory['php_admin_flags'].each do |flag,value| -%>
<%- value = if value =~ /true|yes|on|1/i then 'on' else 'off' end -%>
php_admin_flag <%= "#{flag} #{value}" %>
<%- end -%>
<%- end -%>
<%- if directory['php_admin_values'] and ! directory['php_admin_values'].empty? -%>
<%- directory['php_admin_values'].each do |key,value| -%>
php_admin_value <%= "#{key} #{value}" %>
<%- end -%>
<%- end -%>
<%- if directory['directoryindex'] and directory['directoryindex'] != '' -%>
DirectoryIndex <%= directory['directoryindex'] %>
<%- end -%>
Expand Down
12 changes: 12 additions & 0 deletions templates/vhost/_php_admin.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<% if @php_admin_values and not @php_admin_values.empty? -%>
<% @php_admin_values.each do |key,value| -%>
php_admin_value <%= key %> <%= value %>
<% end -%>
<% end -%>
<% if @php_admin_flags and not @php_admin_flags.empty? -%>
<% @php_admin_flags.each do |key,flag| -%>
<%# normalize flag -%>
<% if flag =~ /true|yes|on|1/i then flag = 'on' else flag = 'off' end -%>
php_admin_flag <%= key %> <%= flag %>
<% end -%>
<% end -%>

0 comments on commit 498d36e

Please sign in to comment.