Ticket #26039: php-fpm.diff

File php-fpm.diff, 4.5 KB (added by andy@…, 14 years ago)

updated patch

  • lang/php5/Portfile

    diff --git a/lang/php5/Portfile b/lang/php5/Portfile
    index 3cdae33..8083dcf 100644
    a b platform darwin 10 { 
    103103        LIBS=-lresolv
    104104}
    105105
    106 variant no_web conflicts apache apache2 fastcgi description {Don't include any web server support} {}
     106variant no_web conflicts apache apache2 fastcgi fpm  description {Don't include any web server support} {}
    107107
    108108# Build an Apache 1 module. On Mac OS X, it uses Apple's provided Apache 1 server.
    109109# On other platforms, the MacPorts apache port is used. Keep the options here
    variant fastcgi conflicts no_web description {Add FastCGI web server binary} { 
    150150    }
    151151}
    152152
     153# FPM options
     154variant fpm conflicts no_web description {Add FPM (Fast Process Management) web server binary} {
     155    depends_lib-append      port:libevent
     156
     157    set fpm_pidfile         ${prefix}/var/run/${my_name}-fpm.pid
     158    set fpm_conf_installed  0
     159
     160    startupitem.create      yes
     161    startupitem.name        php-fpm
     162    startupitem.executable  ${prefix}/sbin/php-fpm --fpm-config ${phpinidir}/php-fpm.conf
     163    startupitem.pidfile     auto ${fpm_pidfile}
     164
     165    if { ![variant_isset apache] && ![variant_isset apache2] } {
     166        configure.args-delete \
     167            --disable-fpm
     168        configure.args-append \
     169            --enable-fpm
     170    }
     171}
     172
    153173foreach {old_variant new_port} {
    154174    gmp             gmp
    155175    imap            imap
    variant ipc description {Add semaphore, shared memory and IPC functions} { 
    185205        --enable-sysvmsg
    186206}
    187207
    188 if {![variant_isset apache] && ![variant_isset apache2] && ![variant_isset fastcgi] && ![variant_isset no_web]} {
     208if {![variant_isset apache] && ![variant_isset apache2] && ![variant_isset fastcgi] && ![variant_isset fpm] && ![variant_isset no_web]} {
    189209    default_variants +apache2
    190210}
    191211
    post-destroot { 
    288308        # conflict with the cli version.
    289309        xinstall -m 755 ${worksrcpath}/sapi/cgi/php-cgi ${destroot}${prefix}/bin
    290310    }
     311
     312    if { [variant_isset fpm] } {
     313        # if we were also building an apache module, we didn't compile FPM at that time
     314        # so we do it here. This shouldn't be necessary, but is done for http://bugs.php.net/bug.php?id=52419
     315        if { [variant_isset apache] } {
     316            if { ![variant_isset macosx] && (![info exists os.subplatform] || ${os.subplatform} != "macosx") } {
     317                configure.args-delete \
     318                    --with-apxs=${prefix}/sbin/apxs
     319            } else {
     320                configure.args-delete \
     321                    --with-apxs=/usr/sbin/apxs
     322            }
     323        }
     324        if { [variant_isset apache2] } {
     325            configure.args-delete \
     326                --with-apxs2=${prefix}/apache2/bin/apxs
     327        }
     328       
     329        if { [variant_isset apache] || [variant_isset apache2] } {
     330            configure.args-delete \
     331                --disable-fpm
     332            configure.args-append \
     333                --enable-fpm
     334               
     335            ui_msg "$UI_PREFIX Configuring ${name} again for FPM"
     336            command_exec configure
     337            ui_msg "$UI_PREFIX Building ${name} again for FPM"
     338            command_exec build
     339            ui_msg "$UI_PREFIX Staging ${name} FPM into destroot"
     340        }
     341       
     342        # Copy the FPM binary to the bin dir
     343        xinstall -m 755 ${worksrcpath}/sapi/fpm/php-fpm ${destroot}${prefix}/sbin
     344    }
    291345   
    292346    #file rename ${destroot}${prefix}/etc/pear.conf ${destroot}${prefix}/etc/pear.conf.sample
    293347   
    post-destroot { 
    297351        php.ini-development \
    298352        php.ini-production \
    299353        ${destroot}${phpinidir}
     354
     355    if { [variant_isset fpm] } {
     356      if {![file exists ${phpinidir}/php-fpm.conf]} {
     357          # Only install php-fpm.conf if doesn't exist so we don't overwrite user's file by mistake
     358          xinstall -m 644 ${worksrcpath}/sapi/fpm/php-fpm.conf ${destroot}${phpinidir}
     359      }
     360    }
    300361   
    301362    # Copy mysqlnd headers.
    302363    xinstall -d ${destroot}${prefix}/include/php/ext/mysqlnd
    post-activate { 
    328389        ui_msg "${phpinidir}/php.ini-production (if this is a production server)."
    329390    }
    330391   
     392    if { [variant_isset fpm] } {
     393      ui_msg ""
     394      ui_msg "FPM configuration file installed to ${phpinidir}/php-fpm.conf."
     395      ui_msg "You will need to configure the pm.min_spare_servers and pm.max_spare_servers"
     396      ui_msg "parameters before you can start php-fpm"
     397    }
     398
    331399    if {![variant_isset no_web]} {
    332400        ui_msg ""
    333401        ui_msg "If this is your first install, you need to activate PHP in your web server."