Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
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?
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.
Related
I am developing a Laravel 9.x app in Windows 10. My current version of PHP is PHP 8.1.5 (cli) (built: Apr 12 2022 17:38:57) (ZTS Visual C++ 2019 x64). Is this a thread-safe or not-thread-safe version? How can I tell? When should I prefer a thread-safe over a not-thread-safe version?
I've tried researching this issue here on StackOverflow but the questions/answers I see all seem to be a decade or more old - like this - and I strongly suspect that I might get a different answer if I asked the question today simply because the technology has changed in the intervening years. Is that a reasonable assumption? (At the very least, my current version of PHP evidently uses a newer compiler, VC++ 2019, rather than VC6 or VC9.)
I have no idea yet what my production environment is going to be or even IF the app I'm developing will ever go to a production environment since it's just an app I'm writing to (re-)learn Laravel. I may put it in production as a demonstration of a working Laravel app when the time comes but whether it will be on a hosting service or Netlify or something else, I just don't know at this point.
Just to give you some context, this issue only came up because I am trying to learn how to step through my Laravel source code to debug problems and this apparently requires me to add XDebug to XAMPP. The instructions I found for installing XDebug point me to here and recommend that I download the Windows binaries for my version of PHP. There are no binaries of 8.1.5 so I don't know if one of the binaries for 8.1 would work or if I'd be better to use 8.1 thread-safe or 8.1 not-thread-safe. If it would be better to upgrade my PHP first to 8.2, I still don't know if thread-safe or not-thread-safe is a better choice.
Can someone enlighten me on these matters?
Is this a thread-safe or not-thread-safe version? How can I tell?
You can use the good old phpinfo() function and lookup for the Thread Safety column.
If you have your PHP setup in PATH environment, you can even get it via CLI using a quick command php -i | grep Thread
When should I prefer a thread-safe over a not-thread-safe version?
As per PHP official documentation
If you choose to run PHP as a CGI binary, then you won't need thread safety, because the binary is invoked at each request. For multithreaded webservers, such as IIS5 and IIS6, you should use the threaded version of PHP.
I have no idea yet what my production environment is going to be ...
Generally, there is no difference on TS or NTS code execution. It's more towards the webserver.
If I am not mistaken, by default, XAMPP uses Apache Handler, so it will likely be a thread safe build. And yes, the Xdebug binary for PHP8.1 will just work fine.
Technically, NTS should be slightly faster because it doesn't need to cater for thread safety.
Personally, I think it doesn't matter, unless you want to spend slightly more time to tinker around the webserver switching to FastCGI or PHP-FPM, since you are still in development phase, I think stick to the default setup and focusing on getting it up is more efficient.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I want to install Wordpress on my server and i found at their site (https://wordpress.org/about/requirements/) that the recommended requirement is php 7.2 (as a note it say its also support 5.4 but its discouraged, ) .
On my server i have ubuntu 16.04 and php 7.0. (sudo access).
My questions:
1) Will it work smoothly/at all or should i expect hard times to come with php 7.0.
2) I have few existing PHP projects (non-Wordpress), should i expect hard times to come if i upgrade or nothing was totally deprecated.
3) Does ubunto 16.04 have php 7.2 on the official repositories? (what i found on Google was mainly how to use ppa and I'm not sure if this info is up to date)
4) how can i check the above?
thanks
1) Will it work smoothly/at all or should i expect hard times to come with php 7.0.
Will work fine on PHP 7.0 and according to benchmarks will run faster twice than php 5.6.
Here is some interesting information about Wordpress on various PHP's versions:
What’s New in PHP 7.2
See the section: "What Does PHP 7.2 Mean for WordPress Users?"
It does cover 7.0 too, it's dated 4 March 2018
2) I have few existing PHP projects (non-Wordpress), should i expect hard times to come if i upgrade or nothing was totally deprecated.
Assuming your non-WP projects are written in PHP 5.6 you may have some issues.
Some parts of your code may need minor fixes.
See the official documentation: Migrating from PHP 5.6.x to PHP 7.0.x
3) Does ubunto 16.04 have php 7.2 on the official repositories? (what i found on Google was mainly how to use ppa and I'm not sure if this info is up to date)
Not that I'm aware of at the time of writing. If using ppa is an issue for you you then -standing at the informations above- you can run smooth on 7.0
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I am having trouble installing a home personal LAMP development server in Windows 8.1.
I tried to manually install Apache, MySQL, and PHP on Windows 8.1. It appears that both Apache and MySQL installed correctly because I can do "select databases" in MySQL, and localhost said something to the effect of "If you are seeing this message it means Apache installed correctly".
When I try to start the Apache2 service it says:
The requested operation has failed.
But, the service started after I installed it just fine. Only after a reboot did it start giving me this error and refusing to start.
I wonder why this so troublesome? I followed the instructions perfectly but it didn't give me the results that I was told to expect.
Specifications
OPERATING SYSTEM:
Windows 8.1 64-bit
APACHE SERVER:
httpd-2.0.65-win32-x86-openssl-0.9.8y.msi
MYSQL SERVER:
mysql-installer-community-5.6.19.0.msi
PHP for Windows:
php-5.3.28-Win32-VC9-x86.msi
VC9 x86 Thread Safe (2013-Dec-12 01:59:01)
Some final notes
IIS is not installed on this machine.
Firewall is disabled as 3dmasters recommends
I'm not an Apache expert, which is why on a previous system I used WAMP, but I remember when I installed it in 2009, even with a turnkey "package" that was supposed to eliminate problems, I still had problems of compatibility and configuration after the install. I eventually had success with WAMP and used it for learning PHP.
I am aware that there are pre-made packages like XAMPP and WAMP, but I don't want to use them this time, unless somebody can tell me unequivocally that there is absolutely no way even a seasoned programmer/computer specialist/network administrator can manually install Apache/MySQL/PHP on Windows 8.1.
In 3dmasters' tutorial video he is using VirtualBox and the no-ssl version of Apache. Again, his tutorial seems great and perhaps others were able to get up and running the first time with his instructions. However, I followed his instructions fairly close and it didn't work for me. It may be useful to note that Both of the sources (the most recent I could find) I used for the install were published last summer (2013). In McMillian's article, he summarizes the various concurrent problems that may be causing the "The requested operation has failed" error:
"The problem seems to by [sic] that there are numerous versions of Apache
and PHP. Most combinations of them are incompatible with each other.
Support does not seem to have been kept remotely up to date and the
documentation is terrible. Vital information is missing and in places
it seems to be inaccurate. This paper describes what worked mid
2013."
Thus, there were conflicts that at least one person knew about and was able to articulate and write about it. Yet I have found no other resources that address this in a step-by-step "this is what you should do, and this is why" along with, "don't do this because" manner. The closest admonishment of that sort was to make sure you are installing "thread safe" versions of the software, which I am.
Sources
Installing Apache 2.2.22, Php 5.3.26 and Mysql 5.6.12 Microsoft
Publisher: 3dmasters
Published: Jun 28, 2013
https://www.youtube.com/watch?v=UKbEzmMliNM
Installing Apache and PHP on Windows
Author: John McMillan
Published: July 25, 2013
http://johnrmcmillan.wordpress.com/2013/07/25/installing-apache-and-php-on-windows./
You are using an Apache 2.0 VC6 build with a PHP 5.3 VC9 build. Those builds have to at least match; you can't have Apache VC6 load a PHP VC9 module/extension. And I'm not even sure if Apache 2.0 can load PHP5 above 5.2 at all.
Is there a reason for these older versions?
But, the service started after I installed it just fine. Only after a reboot did it start giving me this error and refusing to start
Open the command line in Admin mode (right click cmd.exe, select Run as admin) and execute:
httpd -t
httpd -k start
It will output the problem.
If it says something about not being able to bind to port 80, check for the Services outlined in this guide:
Opening Up Port 80 For Apache to Use On Windows
unless somebody can tell me unequivocally that there is absolutely no way even a seasoned programmer/computer specialist/network administrator can manually install Apache/MySQL/PHP on Windows 8.1
It will take at least a few days to a few weeks if you really want to get it working fully, and correct for all edge-cases. Otherwise you should check out Xampp, WampServer, WampDeveloper Pro (not free), EasyPHP.
You shouldn't use the binaries from apache.org with the latest PHP builds. They use different CRT, furthermore - apache.org still uses VC6 and that is legacy. You can fetch a newer apache build from http://www.apachelounge.com/ and the corresponding PHP from http://windows.php.net/ . Be sure that the builds use the same CRT.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I'd like to install the 'pthreads' PHP extension on Ubuntu. I'm using Ubuntu 12.04.1 LTS. And I can upgrade if needed. I really don't want to compile anything from source. For example recompile PHP from source sounds like a horrible idea to me.
In my view, the best option is to install this extension with aptitude command. For example like aptitude install php5-mysql. Another good idea is to use pecl pecl install pthreads. But is does not work for me because of the following error:
checking checking for ZTS... configure: error: pthreads requires ZTS, please re-compile PHP with ZTS enabled
Let me explain why I don't like the idea to recompile PHP from source:
I guess I should uninstall original PHP package then and all the dependencies. Because if I compile it over standard PHP then any packages update would overwrite my changes. And yes, another option is to keep PHP from updating. Anyway this introduces some extra work and makes the setup more complicated. We work in the distributed team. And I don't want other people to deal with this complicated setup on production servers.
I want to install updates on servers. And I don't want to recompile PHP because of security fixes etc.
I don't want to compile anything on production servers and do this many times. Then I should build my own packages and update them with new versions etc. Sorry but I'm not smart enough to do this. May be in 2-3 years but not now. Because there are a lot of things to keep in mind here. For example how, to replace standard PHP package with custom package while still satisfying all dependencies.
Some references:
Dynamically Configure PHP for Thread Safety --enable-maintainer-zts, or use YUM to install pThreads?
How to use Pthreads PHP extension (in Ubuntu) - Some talks about what I'm going to do here.
Building pthreads
This article seems to be old and not actual. I'll keep it for reference only. And I guess it should be read as 'PHP was not thread safe 3 years ago'.
Don’t Believe The Lies: PHP Isn’t Thread-Safe Yet
ZTS: [Z]end [T]hread [S]afety.
ZTS is a compile time option that cannot be enabled at runtime. It allows the PHP interpreter, which usually executes in a single thread, to be executed in many, each with their own isolated instance of the interpreter.
The only option for you appears to be a fresh build, and then using package building tools for your distribution.
I'm not able to advise on the creation of a deb directly, however, creating an rpm is quite trivial, https://github.com/krakjoe/spex there's a starting place for that, you can then use alien to turn an RPM into a deb if you are not able to find out how to create deb packages directly.
Building from source is going to be inescapable, unless you can find some repository with a thread safe build of PHP, with a complete build environment. To that end, the information http://pthreads.org/building may be of use to you. It really isn't that hard to build PHP, nor does it take many hours, on modern hardware you can have a build in less than a minute. You can and should take the opportunity to trim the fat from your installation.
On a side note, the article you reference about PHP not being thread safe is from 2008, it's very wrong. The core is thread safe, there are a few extensions that are inherently unsafe ( not abstracted badly, but fundamentally unsuitable ).
It seems, Ubuntu doesn't have a package for the thread-safe PHP in the official repositories.
Pthreads extension requires ZTS. Thus, you have two options:
compile it yourself:
find a .deb package somewhere, e.g. repositories of the other Debian-like systems.
I'd compile and package it myself using "checkintsall" utility. Thus, Apt will have ability to keep track of PHP version. I would also request Canonical for a package for ZTS PHP.
I'm currently about to install PHP for an Apache/Windows-based development environment, but it seems I'm about to fall at the first hurdle: Choosing the right package to install.
PHP is available in no less than four flavours:
VC9 x86 Non Thread Safe
VC9 x86 Thread Safe
VC6 x86 Non Thread Safe
VC6 x86 Thread Safe
What's the difference between these versions in a practical sense?
If this wasn't complicated enough, version 5.3 of PHP is only available in VC9 (with 5.2 coming with the VC6 packages). And yet, according to the PHP site, you should not use VC9 with Apache... So why does Apache get the older version?
It's all very confusing and I'd like some help understanding the choices.
After a lot of research, I've managed to find my own answers to this question.
In its most basic form, the answer is: What version of PHP you should install comes down what webserver you are running.
Here's a deeper explanation of the terms used in picking a version of PHP based on what I learned:
VC6 vs VC9
Firstly, different versions of Apache for Windows are compiled with different compilers. For example, the versions on Apache.org are designed to be compiled using Microsoft Visual C++ 6, also known as VC6. This compiler is very popular, but also very old. (It dates back to 1998.)
There are different versions of Apache made for different compilers. For example, the versions available for download from ApacheLounge.com are designed to be compiled with the popular and more much recent compiler, Microsoft Visual C++ 9 from 2008. Also known as VC9.
(Note: These two compilers are the two most popular options. So while it's possible to have a VC7, VC8, etc. compiled version of Apache, it's unlikely that you'll come across them.)
The use of this more recent compiler (VC9) is important because the latest versions of PHP are only being distributed in VC9 form (although older versions are still available for VC6).
On top of that, according to ApacheLounge there are numerous improvements when using a version of Apache compiled with VC9, "in areas like Performance, MemoryManagement and Stability".
If that wasn't enough, the developers of PHP made the following statement on their site:
Windows users: please mind that we do
no longer provide builds created with
Visual Studio C++ 6 (VC6). It is
impossible to maintain a high quality
and safe build of PHP for Windows
using this unmaintained compiler.
We recommend the VC9 Apache builds as
provided by ApacheLounge.
All PHP users should note that the PHP
5.2 series is NOT supported anymore. All users are strongly encouraged to
upgrade to PHP 5.3.6.
In all, this is an extremely compelling argument to use VC9 versions of Apache and PHP, if you ask me.
So if you're using a version of Apache from the official Apache site, it will be compiled with VC6, and as such, you should use the older version of PHP for that compiler. If you're using a version of Apache compiled with VC9, like the one available on ApacheLounge.com, you can use the latest version of PHP (for VC9).
For me, running a local development environment, it would be preferable to have the latest version of PHP, so a VC9 version of Apache is required, so I can use the VC9 version of PHP.
Thread Safe vs Non Thread Safe
Once again this comes down to your webserver. By default Apache is installed on Windows as Module, but it can be changed to run as FastCGI. There's plenty of differences between the two, but essentially FastCGI is more modern, faster, more robust, and more resource hungry. For someone running a local development environment, FastCGI might be overkill, but apparently lots of hosting companies run as FastCGI for the reasons I've stated, so there are good arguments for doing so in a development environment.
If you're running Apache (or IIS) as FastCGI (or CGI) then you want the Non Thread Safe version of PHP. If you're running Apache as default (as a Module), then you'll want the more traditional Thread Safe version.
Please note: This all only applies to Windows users.
I'm not going to bother with FastCGI (unless someone convinces me otherwise), so for me, I want the VC9 Thread Safe version of PHP.
And that's it.
Further reading:
Official statement regarding PHP and VC6
Difference between PHP thread safe and non thread safe binaries
FastCGI at Wikipedia
FastCGI for IIS
Visual C++ at Wikipedia
Compile your own PHP (explanation of VC6/VC9)
Personally, I use a virtualised LAMP server. Every hosting service I use is on some flavour of Linux, and there are too many differences between WAMP and LAMP. Then I just use the default tasksel LAMP server for that version of Linux.
My actual setup right now is with VMWare (Fusion on Mac, Player on Windows). I have 3 VMs - one for PHP5.3 with Ubuntu 10.04 LTS, and another for PHP 5.1 on Ubuntu 8.04 LTS. (One of the hosts I use is on RedHat, which currently supports only PHP 5.1). I have a third VM for RubyOnRails dev.
In other words, I try to get my development environment as close to my production environment as possible. So work out what version of Apache and PHP is on your host, and use that as your guide.