如何在 PHP MAMP 中启用流程控制扩展 (PCNTL)?

发布于 2024-10-20 16:54:13 字数 152 浏览 9 评论 0 原文

我有 MAMP 并且我需要在我当前的设备上启用 -pcntl MAMP 安装。

我怎样才能这样做呢?

I have MAMP and I need to enable -pcntl on my current MAMP installation.

How can I do so?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

掩饰不了的爱 2024-10-27 16:54:13

有一种方法可以将 PCNTL 编译为扩展并将其链接到现有的 PHP 版本,但它有点深入。

我正在 Mac OS X v10.6 (Snow Leopard) (64 ) 上执行以下操作;bit),使用 MAMP 和 PHP 版本 5.3.6。如果您的版本号不同,请记住更改以下行中的 PHP 版本号!

请注意,make 是必需的,Mac OS X 上默认情况下不安装它。您需要通过 Mac 开发者工具 安装此工具。

首先,下载与您在 MAMP 中使用的版本相匹配的 PHP 源代码的 tar 文件(例如,我的版本是 5.3.6),您可以在 不支持的历史版本。解压并CD到php-[version]/ext/pcntl,eg:

wget http://museum.php.net/php5/php-5.3.6.tar.gz
tar xvf php-5.3.6.tar.gz
cd php-5.3.6/ext/pcntl

然后需要在pcntl目录下运行phpize,这是MAMP自带的二进制文件:

cd php-5.3.6/ext/pcntl
/Applications/MAMP/bin/php/php5.3.6/bin/phpize

这会创建一堆准备编译扩展所需的文件。

我们现在需要添加一些标志来告诉它使用 32 位和 64 位双架构编译库,因为 MAMP PHP 就是这样构建的。如果不这样做,编译的共享对象将无法工作。

MACOSX_DEPLOYMENT_TARGET=10.6
CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp"
CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe"
CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe"
LDFLAGS="-arch i386 -arch x86_64 -bind_at_load"
export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET

然后我们可以运行 ./configuremake 来构建我们的共享对象:

./configure
make

这会将一个名为 pcntl.so 的文件放入模块中 目录。将此文件复制到 MAMP 的 PHP 扩展目录:

cp modules/pcntl.so /Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/

最后,编辑 PHP INI 文件以包含扩展:

echo "extension=pcntl.so" >> /Applications/MAMP/bin/php/php5.3.6/conf/php.ini

现在应该启用 PCNTL。要检查它是否已添加,只需运行:

/Applications/MAMP/bin/php/php5.3.6/bin/php --ri pcntl

输出:

pcntl

pcntl support => enabled

如果您看到它,则说明已成功!如果出现任何问题,您只需从 MAMP PHP 扩展目录中删除 pcntl.so 文件并删除 INI 设置,然后重试。

There is a way of compiling PCNTL as an extension and linking it in to an existing PHP build, but it's a bit in-depth.

I'm doing the following on Mac OS X v10.6 (Snow Leopard) (64 bit), with MAMP and PHP version 5.3.6. Remember to change PHP version numbers in the following lines if yours is different!

Please note that make is required, which isn't installed by default on Mac OS X. You need to install this via Mac developer tools.

First, download a tar of the PHP source code that matches the version you are using in MAMP (e.g., mine is 5.3.6), which you can do at Unsupported Historical Releases. Untar and CD to php-[version]/ext/pcntl, e.g.:

wget http://museum.php.net/php5/php-5.3.6.tar.gz
tar xvf php-5.3.6.tar.gz
cd php-5.3.6/ext/pcntl

You then need to run phpize in the pcntl directory, which is a binary file that comes with MAMP:

cd php-5.3.6/ext/pcntl
/Applications/MAMP/bin/php/php5.3.6/bin/phpize

This creates a bunch of files that are needed for preparing a extension for compiling.

We now need to add some flags to tell it to compile the library with dual 32-bit and 64-bit architecture, as the MAMP PHP has been built this way. If you don't do this, the compiled shared objects won't work.

MACOSX_DEPLOYMENT_TARGET=10.6
CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp"
CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe"
CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe"
LDFLAGS="-arch i386 -arch x86_64 -bind_at_load"
export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET

We can then run ./configure and make to build our shared object:

./configure
make

This puts a file called pcntl.so in the modules directory. Copy this file to your MAMP's PHP extensions directory:

cp modules/pcntl.so /Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/

Finally, edit the PHP INI file to include the extension:

echo "extension=pcntl.so" >> /Applications/MAMP/bin/php/php5.3.6/conf/php.ini

PCNTL should now be enabled. To check to see whether it has been added, just run:

/Applications/MAMP/bin/php/php5.3.6/bin/php --ri pcntl

Output:

pcntl

pcntl support => enabled

If you see that, it's worked! If anything has gone wrong you can just remove the pcntl.so file from the MAMP PHP extensions directory and remove the INI setting, and try again.

洒一地阳光 2024-10-27 16:54:13

如果您安装了 Homebrew(可执行 brew)你的 Mac 那么你应该能够做到:

brew install php53-pcntl

不过我不是 MAMP 专家。

brew install php53-pcntl
brew info php53-pcntl

输出:

Warning: php53-pcntl-5.3.25 already installed

php53-pcntl: stable 5.3.25
http://php.net/manual/en/book.pcntl.php
/usr/local/Cellar/php53-pcntl/5.3.23 (3 files, 32K)
  Built from source
/usr/local/Cellar/php53-pcntl/5.3.25 (3 files, 32K) *
  Built from source
https://github.com/josegonzalez/homebrew-php/commits/master/Formula/php53-pcntl.rb
==> Dependencies
Build: autoconf
Required: php53
==> Options
--without-config-file
    Do not add ext-pcntl.ini to /usr/local/etc/php/5.3/conf.d
--without-homebrew-php
    Ignore homebrew PHP and use default instead
==> Caveats
To finish installing pcntl for PHP 5.3:
  * /usr/local/etc/php/5.3/conf.d/ext-pcntl.ini was created,
    do not forget to remove it upon extension removal.
  * Restart your webserver.
  * Write a PHP page that calls "phpinfo();"
  * Load it in a browser and look for the info on the pcntl module.
  * If you see it, you have been successful!

If you have Homebrew (executable brew) installed on your Mac then you should be able to do:

brew install php53-pcntl

I am no expert on MAMP though.

brew install php53-pcntl
brew info php53-pcntl

Output:

Warning: php53-pcntl-5.3.25 already installed

php53-pcntl: stable 5.3.25
http://php.net/manual/en/book.pcntl.php
/usr/local/Cellar/php53-pcntl/5.3.23 (3 files, 32K)
  Built from source
/usr/local/Cellar/php53-pcntl/5.3.25 (3 files, 32K) *
  Built from source
https://github.com/josegonzalez/homebrew-php/commits/master/Formula/php53-pcntl.rb
==> Dependencies
Build: autoconf
Required: php53
==> Options
--without-config-file
    Do not add ext-pcntl.ini to /usr/local/etc/php/5.3/conf.d
--without-homebrew-php
    Ignore homebrew PHP and use default instead
==> Caveats
To finish installing pcntl for PHP 5.3:
  * /usr/local/etc/php/5.3/conf.d/ext-pcntl.ini was created,
    do not forget to remove it upon extension removal.
  * Restart your webserver.
  * Write a PHP page that calls "phpinfo();"
  * Load it in a browser and look for the info on the pcntl module.
  * If you see it, you have been successful!
此岸叶落 2024-10-27 16:54:13

为了让我的生活更轻松,我从另一篇文章中创建了一个脚本。我用它向 MAMP 添加了扩展 pcntl、sysvmsg、sysvshm、sysvsem 等。要使用它,cd 到扩展目录或将该目录作为参数传递给脚本。示例:./addExtension.sh php-5.3.6/ext/pcntl

#!/bin/bash
DIR=$1
MAMP_PHP=$2
if [ -z "$DIR" ]
then
  DIR=`pwd`
fi

if [ -z "$MAMP_PHP" ]
then
  MAMP_PHP='/Applications/MAMP/bin/php/php5.3.6'
fi

EXTENSION=${DIR##*/}

echo Extension: $EXTENSION

cd $DIR

eval "${MAMP_PHP}/bin/phpize"


MACOSX_DEPLOYMENT_TARGET=10.6
CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp"
CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe"
CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe"
LDFLAGS="-arch i386 -arch x86_64 -bind_at_load"
export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET

./configure
make

cp modules/${EXTENSION}.so "${MAMP_PHP}/lib/php/extensions/no-debug-non-zts-20090626/"

PHP_INI_PATH="${MAMP_PHP}/conf/php.ini"
sed -e "/extension=${EXTENSION}.so/ d" $PHP_INI_PATH > TMP
mv TMP $PHP_INI_PATH
echo "extension=${EXTENSION}.so" >> $PHP_INI_PATH

eval "${MAMP_PHP}/bin/php --ri ${EXTENSION}"

Just to make my life easier, I made a script from the other post. I used it to add extensions pcntl, sysvmsg, sysvshm, sysvsem and others to MAMP. To use it, cd to the extension directory or pass the directory as an argument to the script. Example: ./addExtension.sh php-5.3.6/ext/pcntl

#!/bin/bash
DIR=$1
MAMP_PHP=$2
if [ -z "$DIR" ]
then
  DIR=`pwd`
fi

if [ -z "$MAMP_PHP" ]
then
  MAMP_PHP='/Applications/MAMP/bin/php/php5.3.6'
fi

EXTENSION=${DIR##*/}

echo Extension: $EXTENSION

cd $DIR

eval "${MAMP_PHP}/bin/phpize"


MACOSX_DEPLOYMENT_TARGET=10.6
CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp"
CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe"
CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe"
LDFLAGS="-arch i386 -arch x86_64 -bind_at_load"
export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET

./configure
make

cp modules/${EXTENSION}.so "${MAMP_PHP}/lib/php/extensions/no-debug-non-zts-20090626/"

PHP_INI_PATH="${MAMP_PHP}/conf/php.ini"
sed -e "/extension=${EXTENSION}.so/ d" $PHP_INI_PATH > TMP
mv TMP $PHP_INI_PATH
echo "extension=${EXTENSION}.so" >> $PHP_INI_PATH

eval "${MAMP_PHP}/bin/php --ri ${EXTENSION}"
九八野马 2024-10-27 16:54:13

我通过使用 MacPorts 解决了这个问题。

我运行了命令:

sudo port install php5-pcntl

I solved the problem by using MacPorts.

I ran the command:

sudo port install php5-pcntl
十年九夏 2024-10-27 16:54:13

我发现一些适用于 Mac OS X v10.10 (Yosemite) 的说明略有不同和使用 PHP 5.6.2 的 MAMP。

在这里找到了说明:
如何让 Artisan Tinker 工作在 OS X 10 MAMP 中

wget http://museum.php.net/php5/php-5.6.2.tar.gz
tar -xzvf php-5.6.2.tar.gz
mv php-5.6.2 php
mkdir -p /Applications/MAMP/bin/php/php5.6.2/include
mv php /Applications/MAMP/bin/php/php5.6.2/include

cd /Applications/MAMP/bin/php/php5.6.2/include/php
./configure

MACOSX_DEPLOYMENT_TARGET=10.10
CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp"
CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe"
CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe"
LDFLAGS="-arch i386 -arch x86_64 -bind_at_load"
export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET

cd ext/pcntl
phpize
./configure
make
cp modules/pcntl.so /Applications/MAMP/bin/php/php5.6.2/lib/php/extensions/no-debug-non-zts-20131226

I found some slightly different instructions that worked for Mac OS X v10.10 (Yosemite) and MAMP using PHP 5.6.2.

Instructions were found here:
How to get Artisan Tinker Working in OS X 10 MAMP

wget http://museum.php.net/php5/php-5.6.2.tar.gz
tar -xzvf php-5.6.2.tar.gz
mv php-5.6.2 php
mkdir -p /Applications/MAMP/bin/php/php5.6.2/include
mv php /Applications/MAMP/bin/php/php5.6.2/include

cd /Applications/MAMP/bin/php/php5.6.2/include/php
./configure

MACOSX_DEPLOYMENT_TARGET=10.10
CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp"
CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe"
CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe"
LDFLAGS="-arch i386 -arch x86_64 -bind_at_load"
export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET

cd ext/pcntl
phpize
./configure
make
cp modules/pcntl.so /Applications/MAMP/bin/php/php5.6.2/lib/php/extensions/no-debug-non-zts-20131226
指尖凝香 2024-10-27 16:54:13
  1. 不支持的历史版本下载 PHP 实现

  2. tar -xzvf php-7.3.8.tar.gz(我们将输出的文件夹命名为PhpSrcFolder

  3. 确保您的 MAMP bin 目录已存在路径 → 回显 $PATH。您将需要它拥有的额外工具才能执行此操作。 (如果您的 $PATH 中已经有 mamp 的 bin,请跳到步骤 5。)

  4. 您可以将 MAMP 的 bin 添加到您的路径,如下所示,我们首先从 ~/.profile< 中 grep MAMP 使用的 PHP 版本/code> (PS:MAMP在后者中为php添加别名),然后我们根据使用的版本将MAMP bin添加到PATH中。

    export PHP_VERSION=`grep "alias php" ~/.profile |切 -d"/" -f6 |切-c4-`
    \# 指向您的 php.ini 文件夹以使用相同的 php 设置
    导出 PHPRC="/Library/Application Support/appsolute/MAMP PRO/conf/"
    导出 PATH=/Applications/MAMP/bin/php/php$PHP_VERSION/bin:$PATH
    
    ### PS:关闭并重新打开终端
    

  5. PhpSrcFolder/ext/pcntl 复制到 /Applications/MAMP/bin/php/php7.3.8/include/php/ext/pcntl

  6. 进入 / applications/MAMP/bin/php/php7.3.8/include/php/ext/pcntl 然后运行 ​​phpize 命令。请注意,您还需要安装 Xcode 和相关工具。

  7. 然后您应该能够运行 ./configure &&制作&&进行安装。这将在 /Applications/MAMP/bin/php/php7.3.8/include/php/ext/pcntl/modules/pcntl.so 中构建扩展,将其复制并粘贴到 /应用程序/MAMP/bin/php/php7.3.8/lib/php/extensions/no-debug-non-zts-20180731/pcntl.so

  8. 现在,编辑 php.ini 并像启用任何其他扩展一样启用该模块。通过运行 which php 获取加载的 php.ini 路径:/Library/Application Support/appsolute/MAMP PRO/conf/php7.3.8.ini 并重新检查它是否具有 pcntl 扩展名:

    [pcntl]
    
    扩展名=pcntl.so
    

  1. Download a PHP implementation from Unsupported Historical Releases

  2. tar -xzvf php-7.3.8.tar.gz (we will name the outputted folder PhpSrcFolder)

  3. Make sure you've got the MAMP bin directory in your path → echo $PATH. You'll need the extra tools it has in order to do this. (Skip to step 5 if you already have mamp's bin in you $PATH.)

  4. you can add MAMP's bin to your path as follow, we first grep the version of PHP's used by MAMP from ~/.profile (PS: MAMP add alias to php in the latter), then we add the MAMP bin to PATH in accordance with the version used.

    export PHP_VERSION=`grep "alias php" ~/.profile | cut -d"/" -f6 | cut -c4-`
    \# point to your php.ini folder to use the same php setting
    export PHPRC="/Library/Application Support/appsolute/MAMP PRO/conf/"
    export PATH=/Applications/MAMP/bin/php/php$PHP_VERSION/bin:$PATH
    
    ### PS: close and reopen terminal
    
  5. Copy PhpSrcFolder/ext/pcntl to /Applications/MAMP/bin/php/php7.3.8/include/php/ext/pcntl

  6. Go into /Applications/MAMP/bin/php/php7.3.8/include/php/ext/pcntl and then run the phpize command. Note that you'll also need to have Xcode and related tools installed.

  7. You should then be able to run ./configure && make && make install. This will build the extension in /Applications/MAMP/bin/php/php7.3.8/include/php/ext/pcntl/modules/pcntl.so, copy it and paste it in /Applications/MAMP/bin/php/php7.3.8/lib/php/extensions/no-debug-non-zts-20180731/pcntl.so

  8. Now, edit the php.ini and enable the module like you would any of the other extensions. Get path of php.ini loaded by running which phpfor me its : /Library/Application Support/appsolute/MAMP PRO/conf/php7.3.8.ini and recheck that it has the pcntl extension:

    [pcntl]
    
    extension=pcntl.so
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文