doumanju2533 2012-03-11 02:50
浏览 72

最后,PHP 5.4线程安全吗? [关闭]

The PHP community recently announced the release 5.4. So, here is my first question: Is this version finally thread safe?

I’ve read a lot of posts here and around on the Net about this hot topic (PHP tread safety) and I must admit that I’m a little bit confused.

As of today, my poor understanding on this subject is that the “thread safe” versions of PHP could be used on a multi threaded server such as Apache2-mpm-Worker (or IIS on Windows) when the none thread safe PHP versions should be used on a multi processes server such as Apache2-mpm-Prefork while it’s also my understanding that PHP by itself can’t start multiple threads.

I currently use PHP 5.3.10 on a Windows 7-64 system with WampServer2.2d-64 where phpinfo() states: Thread Safety : Enabled and Apache 2.2.21 Loaded modules: mod_php5 and also on another Ubuntu 10.04.3 LTS (64 bit) system with PHP 5.3.2-1ubuntu4.14 where phpinfo() states Tread Safety: disabled and Apache 2.2.14 loaded Modules mod_php5. I thought using mod_php5 automatically loaded a thread safe version of PHP (but I guess I'm wrong).

So, here is my second question: Is PHP (any version) truly Thread Safe yes or no?

So my third question is: how to enable the thread safety option on my Ubuntu system?

And my last question on this subject is: is there a difference in execution times between the thread safe and non thread safe PHP/Apache versions?

PS: one additional question: How to install PHP 5.3.10 on Ubuntu since this package isn’t proposed by Synaptic?

  • 写回答

1条回答 默认 最新

  • douduo2407 2012-03-11 04:01
    关注

    Is any version / 5.4 finally thread safe?

    A caveated Yes. See the obtaining PHP FAQ and the Windows download page. Not all extensions are thread safe and bugs exist. Most Linux distros supply the non-threaded version, including the Ubuntu ones.

    how to enable the thread safety option on my Ubuntu system.

    You can get the packages apache2-mpm-worker and apache2-threaded-dev from the ubuntu repositories. You will need to configure and build the threaded version from source (hence the dev kit). Again some basic extensions are not thread safe and can't be used.

    is there a difference in execution times between the thread safe and non thread safe PHP/Apache versions?

    Yes some, but if you are that interested in performance then you should by looking at lighttpd, or other alternatives.

    How to install PHP 5.3.10 on Ubuntu

    10.04-3 LTS supports 5.3.2. Precise Pangolin will support PHP 5.3.10, but this is still in development. You can try building this source set on your current version, but at your own risk.

    评论

报告相同问题?

悬赏问题

  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助