Skip to content

Instantly share code, notes, and snippets.

@jbanety
Last active February 6, 2024 02:50
Show Gist options
  • Star 39 You must be signed in to star a gist
  • Fork 19 You must be signed in to fork a gist
  • Save jbanety/35d01689608ad89777d349f65c7b39c9 to your computer and use it in GitHub Desktop.
Save jbanety/35d01689608ad89777d349f65c7b39c9 to your computer and use it in GitHub Desktop.
(Updated) Build PCNTL ext for MAMP PHP 7.4.2
#!/bin/bash
PHP_VERSION=7.4.2
# Command lines tools
xcode-select --install
# Install dependencies
brew install wget autoconf openssl lzlib curl imap-uw readline postgresql gettext libxslt libiconv bison pkg-config krb5 bzip2 openldap tidy-html5
# Dirs
mkdir -p /Applications/MAMP/bin/php/php$PHP_VERSION/include
cd /Applications/MAMP/bin/php/php$PHP_VERSION/include
# Download PHP 7 sources
wget http://fr2.php.net/get/php-$PHP_VERSION.tar.bz2/from/this/mirror -O php-$PHP_VERSION.tar.bz2
# Extract
tar -xjvf php-$PHP_VERSION.tar.bz2
mv php-$PHP_VERSION php
# Configure PHP
cd /Applications/MAMP/bin/php/php$PHP_VERSION/include/php/php-$PHP_VERSION
PKG_CONFIG=/usr/local/opt/pkg-config/bin/pkg-config PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/opt/krb5/lib/pkgconfig:/usr/local/opt/openssl/lib/pkgconfig:/usr/local/opt/icu4c/lib/pkgconfig YACC=/usr/local/opt/bison/bin/bison ./configure --prefix=/Applications/MAMP/bin/php/php$PHP_VERSION --exec-prefix=/Applications/MAMP/bin/php/php$PHP_VERSION --sysconfdir=/Applications/MAMP/bin/php/php$PHP_VERSION/conf --with-config-file-path=/Applications/MAMP/bin/php/php$PHP_VERSION/conf --enable-gd --with-jpeg --with-zlib --with-zlib-dir=/usr/local/opt/lzlib --enable-ftp --with-bz2=/usr/local/opt/bzip2 --with-ldap --with-mysqli=mysqlnd --enable-mbstring=all --with-curl=/usr/local/opt/curl --enable-sockets --enable-bcmath --with-imap=shared,/usr/local/opt/imap-uw --enable-soap --with-kerberos --enable-calendar --with-pgsql=shared,/usr/local/opt/postgresql --enable-exif --with-gettext=shared,/usr/local/opt/gettext --with-xsl=/usr/local/opt/libxslt --with-pdo-mysql=mysqlnd --with-pdo-pgsql=shared,/usr/local/opt/postgresql --with-openssl=/usr/local/opt/openssl --with-iconv=/usr/local/opt/libiconv --enable-opcache --enable-intl --with-tidy=/usr/local/opt/tidy-html5 --with-readline=/usr/local/opt/readline --with-mhash --with-ldap=/usr/local/opt/openldap
# Add MAMP's PHP binaries to PATH
export PATH=/Applications/MAMP/bin/php/php$PHP_VERSION/bin/:$PATH
# Phpize
cd /Applications/MAMP/bin/php/php$PHP_VERSION/include/php/php-$PHP_VERSION/ext/pcntl
phpize
# Build
./configure
make
# Install ext
cp modules/pcntl.so /Applications/MAMP/bin/php/php$PHP_VERSION/lib/php/extensions/$(ls /Applications/MAMP/bin/php/php$PHP_VERSION/lib/php/extensions)
echo "extension=pcntl.so" >> /Applications/MAMP/bin/php/php$PHP_VERSION/conf/php.ini
@lazy-tortoise
Copy link

thanks!

@uwaeae
Copy link

uwaeae commented Jun 15, 2017

thanks a lot!!!

@royduin
Copy link

royduin commented Oct 27, 2017

Thanks 😎

@whitebookie
Copy link

Awesome, thank you

@glitterlip
Copy link

thanks

@jsheffers
Copy link

I got to the step where you run ./configure and I get the message "No such file or directory". Any ideas?

@neowh
Copy link

neowh commented Apr 26, 2018

thanks a lot!!!

@the94air
Copy link

the94air commented Oct 7, 2018

Working with php7.2.1 . Thanks!

@TuVanDev
Copy link

Working with php 7.1.20. Thanks.

@Lotuashvili
Copy link

Thank you! 👍

@bastiaansenglenn
Copy link

Worked with php 7.2.14. Thanks a lot!

@ahorovit
Copy link

ahorovit commented Apr 18, 2019

There are a couple updates needed here:

  1. homebrew/dupes was deprecated, so the dependencies here shouldn't include 'homebrew/dupes/libiconv'
    Linuxbrew/brew#701

  2. The "# Configure PHP" step does not quite work because this directory is not present:
    /Applications/MAMP/bin/php/php7.1.1/include/php/php-7.1.1
    --> the configure executable is in /Applications/MAMP/bin/php/php7.1.1/include/php though

@dmarklund
Copy link

Worked like a charm. Thanks!

@hanv11
Copy link

hanv11 commented Jul 25, 2019

Worked with php 7.3.1. Thanks a lot! 👍

@shafiqmirza
Copy link

It worked. Thanks for the help.

@a2sc
Copy link

a2sc commented Mar 30, 2020

Thanks! Worked with PHP 7.4

@jbanety
Copy link
Author

jbanety commented Mar 30, 2020

Hi, I updated the script to work with latest MAMP PHP version (7.4.2)

@maisen20
Copy link

maisen20 commented Jun 2, 2020

wow perfect, thank you!

@jbanety
Copy link
Author

jbanety commented Jun 2, 2020

@maisen20 👍

@MMTE
Copy link

MMTE commented Jun 23, 2020

thanks worked on php 7.4.1 !

@jEstevezRod
Copy link

worked like a charm for php 7.4.2!

@kryzhnii
Copy link

Amazing!

@khanakia
Copy link

khanakia commented Feb 5, 2021

You can download the precompiled extensions from here https://github.com/khanakiaphp/mamp_extensions

@heitorglockner1
Copy link

Beatiful. Thanks

@xwiz
Copy link

xwiz commented Aug 14, 2022

Has anyone done this for PHP8?

@smobiler
Copy link

smobiler commented Feb 6, 2024

Worked with php 7.3.33. Thanks a lot! 👍👍👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment