Okay, so I had an earlier problem with PIL that is still unresolved. Someone else had this problem and had success by removing the old JPEG library. I can't really do that on my machine, however, as it's RHEL and so many things are dependent on libjpeg and libjpeg-devel (when I tried yum remove libjpeg just to see, there were a total of 252 packages that would have been removed!)
I have jpeg-8 installed in /usr/local/lib. It's correctly being used by python, but not by apache. Here's a list from lsof:
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
httpd xxxxx root mem REG 253,3 xxxxx0 xxxxx34 /usr/lib64/libjpeg.so.62.0.0
python xxxxx jordan DEL REG 253,3 xxxxx63 /usr/local/lib/libjpeg.so.8.0.0
httpd xxxxx apache mem REG 253,3 xxxxx0 xxxxx34 /usr/lib64/libjpeg.so.62.0.0
httpd xxxxx apache mem REG 253,3 xxxxx0 xxxxx34 /usr/lib64/libjpeg.so.62.0.0
httpd xxxxx apache mem REG 253,3 xxxxx0 xxxxx34 /usr/lib64/libjpeg.so.62.0.0
httpd xxxxx apache mem REG 253,3 xxxxx0 xxxxx34 /usr/lib64/libjpeg.so.62.0.0
httpd xxxxx apache mem REG 253,3 xxxxx0 xxxxx34 /usr/lib64/libjpeg.so.62.0.0
httpd xxxxx apache mem REG 253,3 xxxxx0 xxxxx34 /usr/lib64/libjpeg.so.62.0.0
httpd xxxxx apache mem REG 253,3 xxxxx0 xxxxx34 /usr/lib64/libjpeg.so.62.0.0
httpd xxxxx apache mem REG 253,3 xxxxx0 xxxxx34 /usr/lib64/libjpeg.so.62.0.0
So, here's what I'm wondering. Given that I can't uninstall libjpeg-6b, is there any way I can force apache to use libjpeg-8 instead?
Okay, so a recent run of lsof
shows that apache is now loading libjpeg.so.8.0.0 also but still running into errors, which suggests that it is still using the 62 version. Is there some way to give the 8 version precedence instead?
UPDATE #1
Running ldd
against all of the modules in lib64/modules came up with no reference to libjpeg. Running ldd
on PIL's _imaging.so file showed that it is using the new version of libjpeg. I'm pretty sure there is only one version of PIL on my system -- I've done a pretty thorough search.
Does anyone out there know which programs or modules tied to httpd or python are likely to load libjpeg? I know that something is loading it via apache since it is showing up in lsof
.
There is a way, but since it is a different version of the jpeg library, you are likely going to break whatever it is that is getting to load the old library first.
The problem likely is that you are loading PHP into the same Apache installation and it is preloading a PHP extension module which has a dependency on the older version of the jpeg library. Because PHP is taking precedence over what Python gets to do, you are stuck with that wrong library.
So, try disabling mod_php so it isn't loaded into Apache. If your problem goes away you know it is that. If it does work and you don't need PHP then leave it permanently disabled. If you do need PHP, then change to using PHP under fastcgi instead, that way you avoid PHP being loaded into Apache processes themselves. Alternatively, you will need to update/rebuild PHP to use the same jpeg version.
Now for the hack to preload the different version of jpeg library, but that likely will not work or cause later problems. This hack is to change the init scripts for Apache such that it sets:
LD_PRELOAD=/some/path/libjpeg.so.8.0.0
export LD_PRELOAD
This tells operating system to preload that library into process address space before it does anything.
BTW, if it is PHP, the reason you aren't finding it with ldd is that the PHP extension modules are installed in a different directory to where the Apache module is.
来源:https://stackoverflow.com/questions/2173103/is-it-possible-to-control-which-libraries-apache-uses