Merge pull request from Icinga/fix/fpm-apache22-config

FPM Config: Support Apache < 2.4
This commit is contained in:
Markus Frosch 2017-12-04 14:09:46 +01:00 committed by GitHub
commit 208e49a616
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 16 deletions
doc
modules/setup/library/Setup/Webserver
packages/files/apache

View File

@ -282,7 +282,8 @@ updated the config file for icingaweb2 with defaults for FPM.
Check `/etc/httpd/conf.d/icingaweb2.conf` or `/etc/apache2/conf.d/icingaweb2.conf`. Check `/etc/httpd/conf.d/icingaweb2.conf` or `/etc/apache2/conf.d/icingaweb2.conf`.
And `*.rpm*` `*.dpkg*` files there with updates. And `*.rpm*` `*.dpkg*` files there with updates.
Make sure that the `FilesMatch` part is included for Apache. Make sure that the `FilesMatch` part is included for Apache >= 2.4. For Apache < 2.4 you have to include the
`LocationMatch` block.
Also see the example from icingacli: Also see the example from icingacli:
``` ```

View File

@ -10,14 +10,19 @@ use Icinga\Module\Setup\Webserver;
*/ */
class Apache extends Webserver class Apache extends Webserver
{ {
/**
* @return array
*/
protected function getTemplate() protected function getTemplate()
{ {
return <<<'EOD' return <<<'EOD'
Alias {urlPath} "{documentRoot}" Alias {urlPath} "{documentRoot}"
# Remove comments if you want to use PHP FPM and your Apache version is older than 2.4
#<IfVersion < 2.4>
# # Forward PHP requests to FPM
# <LocationMatch "^{urlPath}/(.*\.php)$">
# ProxyPassMatch "fcgi://127.0.0.1:9000/{documentRoot}/$1"
# </LocationMatch>
#</IfVersion>
<Directory "{documentRoot}"> <Directory "{documentRoot}">
Options SymLinksIfOwnerMatch Options SymLinksIfOwnerMatch
AllowOverride None AllowOverride None
@ -55,13 +60,15 @@ Alias {urlPath} "{documentRoot}"
DirectoryIndex error_norewrite.html DirectoryIndex error_norewrite.html
ErrorDocument 404 {urlPath}/error_norewrite.html ErrorDocument 404 {urlPath}/error_norewrite.html
</IfModule> </IfModule>
# forwarding PHP requests to FPM # Remove comments if you want to use PHP FPM and your Apache version is greater than or equal to 2.4
# remove comments if you want to use FPM # <IfVersion >= 2.4>
#<FilesMatch "\.php$"> # # Forward PHP requests to FPM
# SetHandler "proxy:fcgi://127.0.0.1:9000" # <FilesMatch "\.php$">
# ErrorDocument 503 {urlPath}/error_unavailable.html # SetHandler "proxy:fcgi://127.0.0.1:9000"
#</FilesMatch> # ErrorDocument 503 {urlPath}/error_unavailable.html
# </FilesMatch>
# </IfVersion>
</Directory> </Directory>
EOD; EOD;
} }

View File

@ -1,5 +1,12 @@
Alias /icingaweb2 "/usr/share/icingaweb2/public" Alias /icingaweb2 "/usr/share/icingaweb2/public"
<IfVersion < 2.4>
# Forward PHP requests to FPM
<LocationMatch "^/icingaweb2/(.*\.php)$">
ProxyPassMatch "fcgi://127.0.0.1:9000/usr/share/icingaweb2/public/$1"
</LocationMatch>
</IfVersion>
<Directory "/usr/share/icingaweb2/public"> <Directory "/usr/share/icingaweb2/public">
Options SymLinksIfOwnerMatch Options SymLinksIfOwnerMatch
AllowOverride None AllowOverride None
@ -38,9 +45,11 @@ Alias /icingaweb2 "/usr/share/icingaweb2/public"
ErrorDocument 404 /icingaweb2/error_norewrite.html ErrorDocument 404 /icingaweb2/error_norewrite.html
</IfModule> </IfModule>
# Forward PHP requests to FPM <IfVersion >= 2.4>
<FilesMatch "\.php$"> # Forward PHP requests to FPM
SetHandler "proxy:fcgi://127.0.0.1:9000" <FilesMatch "\.php$">
ErrorDocument 503 /icingaweb2/error_unavailable.html SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch> ErrorDocument 503 /icingaweb2/error_unavailable.html
</FilesMatch>
</IfVersion>
</Directory> </Directory>