Ticket #26039: php-fpm-v3.diff

File php-fpm-v3.diff, 4.4 KB (added by andy@…, 14 years ago)
  • lang/php5/Portfile

    diff --git a/lang/php5/Portfile b/lang/php5/Portfile
    index 3cdae33..50e6733 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/php-fpm.pid
     158    set fpm_conf_installed  0
     159   
     160    patchfiles-append       patch-fpm-conf.diff
     161
     162    startupitem.create      yes
     163    startupitem.name        php-fpm
     164    startupitem.executable  ${prefix}/sbin/php-fpm --fpm-config ${phpinidir}/php-fpm.conf
     165    startupitem.pidfile     auto ${fpm_pidfile}
     166
     167    if { ![variant_isset apache] && ![variant_isset apache2] } {
     168        configure.args-delete \
     169            --disable-fpm
     170        configure.args-append \
     171            --enable-fpm
     172    }
     173}
     174
    153175foreach {old_variant new_port} {
    154176    gmp             gmp
    155177    imap            imap
    variant ipc description {Add semaphore, shared memory and IPC functions} { 
    185207        --enable-sysvmsg
    186208}
    187209
    188 if {![variant_isset apache] && ![variant_isset apache2] && ![variant_isset fastcgi] && ![variant_isset no_web]} {
     210if {![variant_isset apache] && ![variant_isset apache2] && ![variant_isset fastcgi] && ![variant_isset fpm] && ![variant_isset no_web]} {
    189211    default_variants +apache2
    190212}
    191213
    post-destroot { 
    288310        # conflict with the cli version.
    289311        xinstall -m 755 ${worksrcpath}/sapi/cgi/php-cgi ${destroot}${prefix}/bin
    290312    }
     313
     314    if { [variant_isset fpm] } {
     315        # if we were also building an apache module, we didn't compile FPM at that time
     316        # so we do it here. This shouldn't be necessary, but is done for http://bugs.php.net/bug.php?id=52419
     317        if { [variant_isset apache] } {
     318            if { ![variant_isset macosx] && (![info exists os.subplatform] || ${os.subplatform} != "macosx") } {
     319                configure.args-delete \
     320                    --with-apxs=${prefix}/sbin/apxs
     321            } else {
     322                configure.args-delete \
     323                    --with-apxs=/usr/sbin/apxs
     324            }
     325        }
     326        if { [variant_isset apache2] } {
     327            configure.args-delete \
     328                --with-apxs2=${prefix}/apache2/bin/apxs
     329        }
     330       
     331        if { [variant_isset apache] || [variant_isset apache2] } {
     332            configure.args-delete \
     333                --disable-fpm
     334            configure.args-append \
     335                --enable-fpm
     336               
     337            ui_msg "$UI_PREFIX Configuring ${name} again for FPM"
     338            command_exec configure
     339            ui_msg "$UI_PREFIX Building ${name} again for FPM"
     340            command_exec build
     341            ui_msg "$UI_PREFIX Staging ${name} FPM into destroot"
     342        }
     343       
     344        # Copy the FPM binary to the bin dir
     345        xinstall -m 755 ${worksrcpath}/sapi/fpm/php-fpm ${destroot}${prefix}/sbin
     346    }
    291347   
    292348    #file rename ${destroot}${prefix}/etc/pear.conf ${destroot}${prefix}/etc/pear.conf.sample
    293349   
    post-destroot { 
    297353        php.ini-development \
    298354        php.ini-production \
    299355        ${destroot}${phpinidir}
     356
     357    if { [variant_isset fpm] } {
     358      if {![file exists ${phpinidir}/php-fpm.conf]} {
     359          # Only install php-fpm.conf if doesn't exist so we don't overwrite user's file by mistake
     360          xinstall -m 644 ${worksrcpath}/sapi/fpm/php-fpm.conf ${destroot}${phpinidir}
     361      }
     362    }
    300363   
    301364    # Copy mysqlnd headers.
    302365    xinstall -d ${destroot}${prefix}/include/php/ext/mysqlnd
    post-activate { 
    328391        ui_msg "${phpinidir}/php.ini-production (if this is a production server)."
    329392    }
    330393   
     394    if { [variant_isset fpm] } {
     395      ui_msg ""
     396      ui_msg "FPM configuration file installed to ${phpinidir}/php-fpm.conf."
     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."