Skip to content

Instantly share code, notes, and snippets.

@NicolasGoeddel
Last active August 20, 2020 21:06
Show Gist options
  • Save NicolasGoeddel/9d16e65c064d4a8b901ff7dd55566a18 to your computer and use it in GitHub Desktop.
Save NicolasGoeddel/9d16e65c064d4a8b901ff7dd55566a18 to your computer and use it in GitHub Desktop.
Easy to use configuration for php-fpm
# Example:
# Use PHPHandler php-fpm-matomo.sock
#
<Macro PHPHandler $socket>
<IfModule setenvif_module>
SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
</IfModule>
<FilesMatch ".+\.ph(p[3457]?|t|tml)$">
<If "-f %{SCRIPT_FILENAME}">
SetHandler "proxy:unix:/run/php/$socket|fcgi://localhost"
</If>
</FilesMatch>
<FilesMatch ".+\.phps$">
Require all denied
</FilesMatch>
# Deny access to files without filename (e.g. '.php')
<FilesMatch "^\.ph(p[3457]?|t|tml|ps)$">
Require all denied
</FilesMatch>
</Macro>
# Example:
# Use PHPAliasSock /matomo /home/matomo/www/matomo php-fpm-matomo.sock
#
<Macro PHPAliasSock $alias $directory $socket>
Alias $alias $directory
<Directory "$directory">
Options +FollowSymLinks
AllowOverride All
Require all granted
Allow from all
<IfModule mod_dav.c>
Dav off
</IfModule>
Use PHPHandler $socket
</Directory>
RewriteRule ^$alias(/.*)?$ "-" [L]
</Macro>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment