diff --git a/lang/php5/Portfile b/lang/php5/Portfile
index 3cdae33..8083dcf 100644
--- a/lang/php5/Portfile
+++ b/lang/php5/Portfile
@@ -103,7 +103,7 @@ platform darwin 10 {
         LIBS=-lresolv
 }
 
-variant no_web conflicts apache apache2 fastcgi description {Don't include any web server support} {}
+variant no_web conflicts apache apache2 fastcgi fpm  description {Don't include any web server support} {}
 
 # Build an Apache 1 module. On Mac OS X, it uses Apple's provided Apache 1 server.
 # On other platforms, the MacPorts apache port is used. Keep the options here
@@ -150,6 +150,26 @@ variant fastcgi conflicts no_web description {Add FastCGI web server binary} {
     }
 }
 
+# FPM options
+variant fpm conflicts no_web description {Add FPM (Fast Process Management) web server binary} {
+    depends_lib-append      port:libevent
+
+    set fpm_pidfile         ${prefix}/var/run/${my_name}-fpm.pid
+    set fpm_conf_installed  0
+
+    startupitem.create      yes
+    startupitem.name        php-fpm
+    startupitem.executable  ${prefix}/sbin/php-fpm --fpm-config ${phpinidir}/php-fpm.conf
+    startupitem.pidfile     auto ${fpm_pidfile}
+
+    if { ![variant_isset apache] && ![variant_isset apache2] } {
+        configure.args-delete \
+            --disable-fpm
+        configure.args-append \
+            --enable-fpm
+    }
+}
+
 foreach {old_variant new_port} {
     gmp             gmp
     imap            imap
@@ -185,7 +205,7 @@ variant ipc description {Add semaphore, shared memory and IPC functions} {
         --enable-sysvmsg
 }
 
-if {![variant_isset apache] && ![variant_isset apache2] && ![variant_isset fastcgi] && ![variant_isset no_web]} {
+if {![variant_isset apache] && ![variant_isset apache2] && ![variant_isset fastcgi] && ![variant_isset fpm] && ![variant_isset no_web]} {
     default_variants +apache2
 }
 
@@ -288,6 +308,40 @@ post-destroot {
         # conflict with the cli version.
         xinstall -m 755 ${worksrcpath}/sapi/cgi/php-cgi ${destroot}${prefix}/bin
     }
+
+    if { [variant_isset fpm] } {
+        # if we were also building an apache module, we didn't compile FPM at that time
+        # so we do it here. This shouldn't be necessary, but is done for http://bugs.php.net/bug.php?id=52419
+        if { [variant_isset apache] } {
+            if { ![variant_isset macosx] && (![info exists os.subplatform] || ${os.subplatform} != "macosx") } {
+                configure.args-delete \
+                    --with-apxs=${prefix}/sbin/apxs
+            } else {
+                configure.args-delete \
+                    --with-apxs=/usr/sbin/apxs
+            }
+        }
+        if { [variant_isset apache2] } {
+            configure.args-delete \
+                --with-apxs2=${prefix}/apache2/bin/apxs
+        }
+        
+        if { [variant_isset apache] || [variant_isset apache2] } {
+            configure.args-delete \
+                --disable-fpm
+            configure.args-append \
+                --enable-fpm
+                
+            ui_msg "$UI_PREFIX Configuring ${name} again for FPM"
+            command_exec configure
+            ui_msg "$UI_PREFIX Building ${name} again for FPM"
+            command_exec build
+            ui_msg "$UI_PREFIX Staging ${name} FPM into destroot"
+        }
+        
+        # Copy the FPM binary to the bin dir
+        xinstall -m 755 ${worksrcpath}/sapi/fpm/php-fpm ${destroot}${prefix}/sbin
+    }
     
     #file rename ${destroot}${prefix}/etc/pear.conf ${destroot}${prefix}/etc/pear.conf.sample
     
@@ -297,6 +351,13 @@ post-destroot {
         php.ini-development \
         php.ini-production \
         ${destroot}${phpinidir}
+
+    if { [variant_isset fpm] } {
+      if {![file exists ${phpinidir}/php-fpm.conf]} {
+          # Only install php-fpm.conf if doesn't exist so we don't overwrite user's file by mistake
+          xinstall -m 644 ${worksrcpath}/sapi/fpm/php-fpm.conf ${destroot}${phpinidir}
+      }
+    }
     
     # Copy mysqlnd headers.
     xinstall -d ${destroot}${prefix}/include/php/ext/mysqlnd
@@ -328,6 +389,13 @@ post-activate {
         ui_msg "${phpinidir}/php.ini-production (if this is a production server)."
     }
     
+    if { [variant_isset fpm] } {
+      ui_msg ""
+      ui_msg "FPM configuration file installed to ${phpinidir}/php-fpm.conf."
+      ui_msg "You will need to configure the pm.min_spare_servers and pm.max_spare_servers"
+      ui_msg "parameters before you can start php-fpm"
+    }
+
     if {![variant_isset no_web]} {
         ui_msg ""
         ui_msg "If this is your first install, you need to activate PHP in your web server."
