From d0950668153776b73b4e02a62d5435a77773cdde Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 23 Jul 2020 21:29:11 +0100 Subject: [PATCH] Use a separate FPM pool for each mediawiki site --- cookbooks/mediawiki/recipes/default.rb | 2 +- cookbooks/mediawiki/resources/site.rb | 10 ++++++++++ cookbooks/mediawiki/templates/default/apache.erb | 7 ++++--- cookbooks/wiki/recipes/default.rb | 2 ++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/cookbooks/mediawiki/recipes/default.rb b/cookbooks/mediawiki/recipes/default.rb index 08e7d73d0..2f9437760 100644 --- a/cookbooks/mediawiki/recipes/default.rb +++ b/cookbooks/mediawiki/recipes/default.rb @@ -23,7 +23,7 @@ include_recipe "apt" include_recipe "git" include_recipe "memcached" include_recipe "mysql" -include_recipe "php::apache" +include_recipe "php::fpm" # Mediawiki Base Requirements package %w[ diff --git a/cookbooks/mediawiki/resources/site.rb b/cookbooks/mediawiki/resources/site.rb index e6c42df7f..de0651f35 100644 --- a/cookbooks/mediawiki/resources/site.rb +++ b/cookbooks/mediawiki/resources/site.rb @@ -43,6 +43,7 @@ property :private_site, :kind_of => [TrueClass, FalseClass], :default => false property :recaptcha_public_key, :kind_of => String property :recaptcha_private_key, :kind_of => String property :extra_file_extensions, :kind_of => [String, Array], :default => [] +property :fpm_max_children, :kind_of => Integer, :default => 5 property :reload_apache, :kind_of => [TrueClass, FalseClass], :default => true action :create do @@ -517,6 +518,15 @@ action :create do domains [new_resource.site] + Array(new_resource.aliases) end + php_fpm new_resource.site do + pm_max_children new_resource.fpm_max_children + php_admin_values "open_basedir" => "#{site_directory}/:/usr/share/php/:/dev/null:/tmp/" + php_values "memory_limit" => "500M", + "max_execution_time" => "240", + "upload_max_filesize" => "70M", + "post_max_size" => "100M" + end + apache_site new_resource.site do cookbook "mediawiki" template "apache.erb" diff --git a/cookbooks/mediawiki/templates/default/apache.erb b/cookbooks/mediawiki/templates/default/apache.erb index 586f2391e..8c5224a4a 100644 --- a/cookbooks/mediawiki/templates/default/apache.erb +++ b/cookbooks/mediawiki/templates/default/apache.erb @@ -32,9 +32,6 @@ DocumentRoot <%= @directory %> - ProxyFCGISetEnvIf "true" PHP_ADMIN_VALUE "open_basedir=<%= @directory %>/:/usr/share/php/:/dev/null:/tmp/" - ProxyFCGISetEnvIf "true" PHP_VALUE "memory_limit=500M\nmax_execution_time=240\nupload_max_filesize=70M\npost_max_size=100M" - RewriteCond %{SERVER_NAME} !=<%= @name %> RewriteRule ^/(.*)$ https://<%= @name %>/$1 [R=permanent] @@ -93,6 +90,10 @@ > Options -Indexes Require all granted + + + SetHandler "proxy:unix:/run/php/<%= @name %>.sock|fcgi://127.0.0.1" + /w/images/> diff --git a/cookbooks/wiki/recipes/default.rb b/cookbooks/wiki/recipes/default.rb index 4a13e3256..064f686cf 100644 --- a/cookbooks/wiki/recipes/default.rb +++ b/cookbooks/wiki/recipes/default.rb @@ -33,6 +33,8 @@ mediawiki_site "wiki.openstreetmap.org" do "wiki.openstreetmap.pro", "wiki.openstreetmaps.org"] directory "/srv/wiki.openstreetmap.org" + fpm_max_children 25 + database_name "wiki" database_user "wiki-user" database_password passwords["database"] -- 2.39.5