Skip to content

Instantly share code, notes, and snippets.

@tunght13488
Created September 18, 2013 06:32
Show Gist options
  • Save tunght13488/6605290 to your computer and use it in GitHub Desktop.
Save tunght13488/6605290 to your computer and use it in GitHub Desktop.
Apache & PHP-FPM
# Configure all that stuff needed for using PHP-FPM as FastCGI
# Set handlers for PHP files.
# application/x-httpd-php phtml pht php
# application/x-httpd-php3 php3
# application/x-httpd-php4 php4
# application/x-httpd-php5 php
<FilesMatch ".+\.ph(p[345]?|t|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
# application/x-httpd-php-source phps
<FilesMatch ".+\.phps$">
SetHandler application/x-httpd-php-source
# Deny access to raw php sources by default
# To re-enable it's recommended to enable access to the files
# only in specific virtual host or directory
Order Deny,Allow
Deny from all
</FilesMatch>
# Deny access to files without filename (e.g. '.php')
<FilesMatch "^\.ph(p[345]?|t|tml|ps)$">
Order Deny,Allow
Deny from all
</FilesMatch>
# Define Action and Alias needed for FastCGI external server.
Action application/x-httpd-php /fcgi-bin/php5-fpm virtual
Alias /fcgi-bin/php5-fpm /fcgi-bin-php5-fpm
<Location /fcgi-bin/php5-fpm>
# here we prevent direct access to this Location url,
# env=REDIRECT_STATUS will let us use this fcgi-bin url
# only after an internal redirect (by Action upper)
Order Deny,Allow
Deny from All
Allow from env=REDIRECT_STATUS
</Location>
FastCgiExternalServer /fcgi-bin-php5-fpm -socket /usr/local/var/run/php5-fpm.sock -pass-header Authorization -idle-timeout 180
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment