【问题标题】:PHP-FPM NGinx Pthreads Linux installationPHP-FPM NGinx Pthreads Linux 安装
【发布时间】:2023-10-17 15:23:02
【问题描述】:

我正在尝试实现多个上传功能(一次上传到多个地方)。 我在 Windows(XAMPP + PThreads DLL)上成功实现了这一点,但是在安装 PHP-FPM+php-pecl-pthreads.x86_64 并扩展 Thread 类时,我得到了错误:

include(Thread.php): failed to open stream: No such file or directory

我尝试添加所有与 php.ini 相关的 pthreads.so:

/usr/lib64/php/modules/pthreads.so
/usr/lib64/php-zts/modules/pthreads.so
/usr/lib64/libpthread.so
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/32/libmudflapth.so
/lib64/libpthread-2.12.so

但我得到了

undefined symbol: core_globals_id in Unknown on line 0

在我的 phpinfo 上,我看到线程安全被禁用。

有没有人实现了这个功能,并且可以阐明如何一次上传到多个地方/在 linux 上成功安装 pthreads。

谢谢, 丹尼

【问题讨论】:

    标签: multithreading file-upload pthreads php


    【解决方案1】:

    对于 debian/ubuntu

    1. 下载php源码(确保你有deb-src)

    apt-get source php5

    1. 去那个目录

    cd php5*

    1. 转到分机目录

    cd ext

    1. 下载 pthreads

    git clone https://github.com/krakjoe/pthreads.git

    1. 重建配置设置

    cd .. && ./buildconf --force

    1. 确保配置选项中有 pthreads

    ./configure --help | grep pthre

    1. 运行配置(根据您的设置更改路径)

    ./configure --enable-debug --enable-maintainer-zts --enable-pthreads --prefix=/usr --with-config-file-path=/etc --with-apxs2=/usr/bin/apxs2 --enable-fpm

    1. 如果需要,请访问 this 了解有关用户/组特定选项的更多信息。

    make -j2

    make -j2 install

    1. 现在您将使用 pthreads 支持编译 php。验证这一点:

    php -m | grep pthreads

    1. 制作初始化脚本

    copy sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

    1. usergroup更改为nginx在/etc/init.d/php-fpm中使用的用户名。

    service nginx restart

    1. 去你的 nginx 公共傻瓜

    cd <your-nginx-public-folder>

    1. touch phpinfo.php && echo "<?php phpinfo();" >> phpinfo.php

    2. 进入浏览器并在http://<your url>/phpinfo.php刚刚创建的php文件中搜索pthreads

    【讨论】:

    • 以防万一其他人试图实现同样的目标 - 我成功地使用 guzzle 上传了多个文件...可能是更简单的解决方案但是谢谢!