How to install PHP pthreads extension on Ubuntu? [closed] - php

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.

Related

Questions about installing php [closed]

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 6 years ago.
Improve this question
I'd like to be able to run PHP application on my own windows desktop.
What are my options?
accodring to this reference, I have to install visual studio 2015 to able to do it. Is it the really necessary?
Why do they mention compiling php? it's a scripting language so am I still supposed to pre-compile it before running it?
Is Visual Studio the only editor or there are other suggested IDEs?
Do I have to run it on IIS, can't I install apache server on my desktop and run the php application on it?
The instructions you find on the wiki are for building PHP from source, but you don't have to do that to use PHP on Windows.
You can use one of the WAMP/XAMPP packages mentioned in the comments. That's definitely a quick and convenient way to get it working on your system. But if you really just want to put PHP on your Windows machine without using one of those, it really isn't too hard.
Based on your questions, including:
Why do they mention compiling php?
I think I can safely assume that you don't want to compile PHP. Fortunately, you don't have to.
Just go to the PHP for Windows download page and find the version that will work on your system. The "Which version do I choose?" in the left panel will help you figure out which one you need. These are pretty much ready to use, just extract it where you want it (I usually just do C:\PHP).
You will need to have the appropriate C++ redistributable installed before it will work. There are also links to those on the PHP for Windows page that I linked above. If you chose PHP 7 (why not?) it will be the VC14 version.
After you have installed the C++ redistributable and extracted the PHP zip file you downloaded, add the new PHP directory to your Windows path, and you'll be able to use PHP on the command line. You can test that it's working properly with php -v (displays the installed version) in a cmd window.
To configure your PHP installation, start with one of the provided ini files, either php.ini-development or php.ini-production. Make a copy of the one you want to use and rename it to php.ini.
Of course, this is only PHP. If you want to use it to with Apache or some other web server, you'll need to install that separately and configure it to use your PHP installation. It's not difficult after you have some experience with it, but I remember it being pretty frustrating to get it working the first time. The advantage to using XAMPP or similar is that includes Apache and MySQL with one installer. If you're just starting out, that's definitely the easiest way to get going.
As far as IDEs, there are various ones that support PHP. There are some free ones that are fine, if that matters to you, but all you really need is a good text editor.

Finally, is PHP 5.4 Thread Safe? [closed]

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.

Compile PHP on Linux or use apt-get / yum?

I have been compiling PHP for years with the configuration options I want. I compile extensions I use from source. Is there an advantage to doing this versus installing it from a package manager like apt-get or yum. I assumed it would also give me a leaner binary. I noticed that their are PHP modules in the repos such as "php53-gd". What if there wasn't a package available for something I wanted such as cURL for PHP?
I understand the disadvantages of compiling such as needing to download/install dependencies based on my configuration options. I'm not really concerned with that.
So the question is:
Compile PHP on Linux or just use apt-get / yum? Can I get all the things I need from the repos? Does anyone out there still compile it from source?
Any insight is appreciated! Thanks.
I compile from source every time. It's not hard to corral the mentioned issues with regards to compiling manually. For example, my ./configure settings are saved to a file which is version controlled, so when a new version of PHP is stable and I am ready to make the switch, I download and extract the file, then run this command:
./configure `sh /path/to/my/configure/php.sh`
Not too difficult. And because it's in version control, I can add notes as to why a module was added or removed.
Another benefit of manual compilation is it allows me to keep the PHP footprint as minimal as possible. I pass the --disable-all flag, then add the modules I need. However, there is a downside to this minimalist approach, recently I needed to install Magento, so I had to recompile with --enable-hash and --with-mcyrpt flags. Even though I needed to add new flags, it wasn't difficult to add to the configure file and recompile.
Compiling from source has a few quirks:
There are hundreds of config parameters and flags. And you might not know the optimal ones that need to be used.
if you rely on apt-get's PHP, then you can be assured that you will get the latest patches and security updates if you set up auto-upgrade on your server.
the configuration of php.ini varies a lot. Sometimes your OS may decide some defaults for you which may work better with the rest of the system.
installing extensions like xdebug or other packages are a lot easier with apt.
However, it's worth compiling php from scratch if you want to learn. Also if you don't use some portions of it, you can always disable them in configuration - but then again it might not make much difference to performance.
I compiled php for specific needs only, like :
very small hard disk space so required a minimalist php version
and/or
need only a few specific modules or extensions
and/or
needed for a specific application
and/or
needed to optimize performances: when compiling on the machine where it's used, this allows some performance improvements, if using compile options to get a real tuned version for your system,
and/or
needed multiple and different php versions on the same machine.
and/or
I had a specific nux distro like only a busybox, so no other options than compiling.
But for common usage, e.g. in 80% of the cases, it's not worth spending time to compile and better using the repository version. But I learned a lot by compiling.
Personally, it's a matter of opinion. If you are in a hurry, apt-get it, if you have time to learn and possibly need to reinstall 20 times...compile it.
There are tons of guides out there for PHP compiling. It has a ton of flags for configuration, especially for GD and other libraries. Personally if this is for learning and development, just get LAMP or use apt-get...especially if you need to use Apache
I feel the primary reason for compiling is to have latest version binary (stable or nightly). package managers (most distors) are often annoyingly slow in this respect.
The other reason is that its very common problem that production systems are not wholesale upgraded using package managers. Even if that can be easy. Since package managers create dependency chains and you may not want to upgrade those items. So just to pick one item, compiling is an option. It keeps everything else as it is. You ofcourse have to always study the upgrade issues and make sure nothing else will fail.

PHP and the build process (/.configure, make and install): orientation, please

I'm a newbie and after I've successfully learnt enough to build my simple but useful web services, I managed to put myself in a position where I need to configure my own PHP build.
The problem is I don't really know what build means --never built anything either.
My broad question is:
Any good step by step tutorial that doesn't just say "must have dependencies"?
My specific question is:
For instance, one that shows how to build PHP with odbc, then rebuild (configure.nice and make nice?) with imap in addition.
If someone finds a PHP bundle that comes with odbc, great; with odbc & imap, better. But I'm really looking for someone to show me how to fish. Please.
Thnx.
A.
Gazler is correct, for a simple setup, you can just configure Ubuntu through the repositories via apt-get. For RHEL-based systems - yum would be the equivalent. However, if you are wanting to know more of how to compile from scratch (which would give you more control over installation), then you can do so.
Basics of compiling an application:
Download source from website (such as PHP, www.php.net)
untar the source (tar -xzvf source.tar.gz)
cd source
Configure the source (./configure [install-option-flags])
Compile source (make)
Test Install (doesn't actually install) - make test
Install the software (make install)
Step 4 is a very broad step. You will need to figure out what options you want to configure - see PHP Core Configuration Options.
Requirements for installing PHP will differ between environments, so that's too broad to cover in one answer, however, you will at least need a c-compiler to compile the source. Usually gcc is my choice, and is usually installed already. On Ubuntu (Debian-based) use apt-get install build-essential or search and install via yum on RHEL-based systems, I believe it would be something like yum install gcc.
You will probably run into dependencies issues as you compile, as I said its a very broad step, however, once you figure out the requirements that you need, you should be good to go, so long as you document your steps for your environment.
Again, the easiest way to go is to install via your software repository (apt-get, yum, emerge, pacman, etc), but these don't give you as much leverage on controlling your environment installation, whereas building from source gives you all the configuration control that you'd need.
You haven't mentioned what distro you are on, On ubuntu you can do:
sudo apt-get install lamp-server^ php5-imap php5-odbc
That should be enough to get you started and configured.

After compiling PHP from source are the devel libraries still needed?

After compiling PHP from source are the devel libraries still needed?
For example, I am building a newer version of PHP from source than is on our dev servers. I installed alot of [extension i.e. mysql, postgresql, curl, etc]-devel packages in order for the configure from the dev server setup to work. Do i still need these after php has compiled? For example could I make a distro and then distribute the PHP distro to another server without needing these devel dependencies?
I am a bit of a noob to this.
You don't need to ship the devel-libraries.
But my advice is to take some time and learn how the build system of your linux distribution works. And then build a new php package that can be installed by the package manager.
Take a look at how the "original" php packages were built for the distribution. Most likely you can simply copy and edit the existing rule file(s) and then make a new version of that package. This way you take advantage of the dependency mechanisms and the package manager will not remove/overwrite your version so easily when an update shows up in the "official" repositories.

Categories