Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
php-fpm and httpd-vhosts minimal examples for Webfaction (see and
# This is a minimal configuration example for httpd virtual host and php-fpm
# I put here the mod_fastcgi configuration even if it should be on a separate file
# Remember to use the right port number
NameVirtualHost *:12345
<IfModule mod_fastcgi.c>
# "fake" php handler
AddHandler php5-fcgi .php
Action php5-fcgi /fcgi-bin/php5.external
# remember that this file does not really exist
# Alias to the fcgi location
Alias /fcgi-bin/php5.external /php5.external
# you have to create the sockets directory
# idle-timeout value should be something more than request_terminate_timeout
# defined in php-fpm.conf
FastCgiExternalServer /php5.external -socket /home/username/webapps/custom_apache/sockets/php5-fpm.socket -pass-header Authorization -appConnTimeout 30 -idle-timeout 310
# we catch the fake, non-existing cgi script
<Location /fcgi-bin/php5.external>
# 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
# set the right port here
<VirtualHost *:12345>
DocumentRoot "/home/username/webapps/yourwebsite"
ErrorLog "logs/"
CustomLog "logs/" common
ScriptAlias /cgi-bin/ "/home/username/webapps/custom_apache/cgi-bin/"
<Directory /home/username/webapps/yourwebsite>
Order allow,deny
Allow from all
AllowOverride All
<Directory "/home/username/webapps/custom_apache/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
; This is a minimal, working but mostly useless example of php-fpm configuration
; It is used for a dev website that I only visit and it is designed to spare memory
; replace "username" with your Webfaction username
pid = /home/username/webapps/custom_apache/run/
error_log = /home/username/webapps/custom_apache/logs/fpm.log
log_level = error
; this group of directives generates a warning on php-fpm start
; I prefer to keep them anyway
listen.owner = username = username
listen.mode = 0660
user = username
group = username
; here it is: low memory consumption but mostly non visitable website
pm = dynamic
pm.max_children = 7
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 4
pm.max_requests = 0
; always set this value to something less than -idle-timeout mod_fastcgi value
request_terminate_timeout = 305
slowlog = /home/username/webapps/custom_apache/logs/fpm-slow.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.