如何在MAMP上启用pthread [英] how to enable pthreads on MAMP

查看:156
本文介绍了如何在MAMP上启用pthread的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Mac OS X Mavericks,并在MAMP中运行php脚本.我正在运行的某些php脚本要求使用 pthreads .

I'm using a Mac with OS X Mavericks, and running php scripts within MAMP. Some of the php scripts I'm running require the use of pthreads.

任何人都可以提供有关在Mac上安装或启用pthread的分步说明吗?

Can anyone provide step-by-step instructions on installing or enabling pthreads on a Mac?

我已经在Google上进行了广泛的搜索,并且发现了很少甚至没有相关的文档.我发现的全部是,我可能不一定必须从源代码重新编译php,或者只是将几个标志添加到php.ini中,或者也许我只能使用pecl等.在终端中,我尝试了pecl install pthreads并收到了此错误:

I have Googled extensively and have found little-to-no documentation on this. All I have found is that I may or may not have to recompile php from source, or maybe just add a couple flags to php.ini, or maybe I can just use pecl, etc. In terminal, I tried pecl install pthreads and received this error:

无法安装,频道"pecl.php.net"的php_dir无法由当前用户写入

Cannot install, php_dir for channel "pecl.php.net" is not writeable by the current user

在这一点上,我几乎迷失了.我想避免在可能的情况下使用WAMP切换到Windows计算机.

I'm pretty much lost at this point. I want to avoid switching to my Windows machine with WAMP if possible.

推荐答案

我不是Mac用户,但是Mac和UNIX的构建过程相同,因此我可以为您提供帮助.

I'm not a Mac user, however the build process is the same for Mac and unix, so I can help you with that.

配置当前安装:

无法安装,频道"pecl.php.net"的php_dir无法由当前用户写入

Cannot install, php_dir for channel "pecl.php.net" is not writeable by the current user

这是pecl安装失败的原因,也许检查php_dir的配置.

This is the reason pecl install failure, maybe check the configuration for php_dir.

您可以使用以下方法确定设置的值:

You can ascertain the value of the setting with:

pecl config-get php_dir

pecl config-get php_dir

我不熟悉MAMP,但是可能没有PHP的线程安全构建是这种情况.

I am unfamiliar with MAMP, but it is probably the case that you do not have a Thread Safe build of PHP.

您可以通过以下方法确定这一点:

You can ascertain this with:

php -i | grep线程

php -i | grep Thread

您应该期望:

线程安全=>启用

Thread Safety => enabled

如果启用了线程安全,则应该是在php_dir上修复权限才能解决问题.

If you have Thread Safety enabled, it should be the case that fixing the permissions on php_dir will fix your problem.

如果不这样做,则必须重新构建或从其他来源安装PHP的Thread Safe构建.

If you do not, you will have to rebuild, or install from another source, a Thread Safe build of PHP.

最后一个选择是构建自己,因为这意味着您会错过上游提供的更新,尽管我不太熟悉,无法确定是否存在维护良好的线程安全构建,所以我认为是.

The last option is to build yourself, since this means you will miss out on updates provided by upstream, though I'm not familiar enough to know for sure if there is a well maintained thread safe build, I will assume that there is.

要构建自己的系统,您需要用新的安装程序覆盖当前安装,将源代码下载到PHP以获取所需的版本(建议使用5.5+版本,最新的稳定版本,最好一直使用).

To build yourself you will need to overwrite your current installation with a new one, download the sources to PHP for your desired version (5.5+ recommended, latest stable, all the time is best).

您将要确定当前构建启用了哪些扩展,并决定要在新构建中启用哪些扩展.

You will want to ascertain which extensions are enabled for your current build and decide which you want to enable in your new build.

要确定启用了哪些扩展名:

To ascertain which extensions are enabled:

php -m

php -m

记下以下内容:

php -m> enabled-extensions

php -m > enabled-extensions

配置版本

要将构建配置为线程安全",请使用以下配置选项:

Configuring the Build

To configure the build to be Thread Safe use the following configure option:

-enable-maintainer-zts

--enable-maintainer-zts

您将要设置新安装的前缀以与旧安装匹配:

You will want to set the prefix of the new installation to match the old with:

-prefix =/old/prefix

--prefix=/old/prefix

如果您当前的php二进制文件位于/usr/local/bin/php,则前缀为/usr/local. 如果您当前的php二进制文件位于/usr/bin/php,则前缀为/usr.

If your current php binary is at /usr/local/bin/php, then the prefix is /usr/local. If your current php binary is at /usr/bin/php, then the prefix is /usr.

您还需要匹配当前的构建配置目录并扫描目录设置:

You will also want to match your current builds configuration directory and scan directory settings:

-with-config-file-path =/old/config/path

--with-config-file-path=/old/config/path

如果您当前的php.ini位于/usr/lib/php.ini,则路径为/usr/lib 如果您当前的php.ini位于/etc/php.ini,则路径为/etc

If your current php.ini is at /usr/lib/php.ini, then the path is /usr/lib If your current php.ini is at /etc/php.ini, then the path is /etc

例如,如果在启动时使用扫描目录,则目录为/etc/php.d

If you are using scan directories at startup, for example, you have the directory /etc/php.d

-with-config-file-scan-dir =/etc/php.d

--with-config-file-scan-dir=/etc/php.d

如果您当前的扫描目录是/etc/php.d,则目录是/etc/php.d

If your current scan directory is /etc/php.d, then the dir is /etc/php.d

要配置扩展名,请参考开始时列出的列表,请使用以下命令:

To configure extensions, referencing the list you made at the beginning, use the command:

./configure --help

./configure --help

要弄清楚这些开关,请启用您选择的扩展.如果列表中包含pecl中的扩展名,则可以在构建完成后使用pecl命令安装这些扩展名.

To figure out the switches enable your chosen extensions. If there are extensions in the list that are in pecl, you can install those after the build is complete with the pecl command.

通常:

  • --enable-extname:不依赖外部库
  • --with-extname:依赖于外部库
  • --enable-extname: no dependencies on external libraries
  • --with-extname: dependent on external libraries

configure之后,我们必须运行make,如果您有多个处理器或内核,则可能要使用多个作业:

After configure we have to run make, if you have multiple processors or cores, you might want to use multiple jobs:

make -j8

make -j8

将允许make并行运行(最多8个作业),这大大加快了构建速度.使用尽可能多的作业.

Will allow make to run in parallel (maximum of 8 jobs), this speeds up builds considerably. Use as many jobs as you have cores.

make期间,如果发生故障,则很明显与故障有关,如果您可以找到库的名称(通常会引起故障的扩展名很有用),则通常可以解决通过为导致故障的库安装开发包来解决错误.

During make, if a failure occurs it will be obvious what the failure relates to, if you can spot the name of a library (usually the name of the extension that causes failure is helpful), then you can usually resolve the error by installing the development package for the library that caused the failure.

开发软件包包含标头和或静态库,通常情况下,软件包维护者会从常规软件包中忽略这些内容以减轻重量,因此可以安装libxml2软件包,但不安装标头.

A development package contains headers and or static libraries, it is usually the case that package maintainers omit this stuff from normal packages to save weight, so you can have the libxml2 package installed but not have headers.

make完成后,您将准备好要安装的构建,请确保您具有前缀权限并执行

When make completes you will have your build ready for installation, make sure you have permissions for the prefix and execute

进行安装

Pecl扩展

您现在应该能够安装所需的PECL扩展

Pecl Extensions

You should now be able to install the PECL extensions that you require with

pecl安装扩展名

pecl install extname

pthreads

您现在可以使用PECL或从github安装:

pthreads

You can now install with PECL or from github:

pecl安装pthreads

pecl install pthreads

这篇关于如何在MAMP上启用pthread的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆