Occasional blank pages in Nginx + APC+ PHP-FPM (or PHP-CGI) + WordPress + WP Super Cache

25 03 2014

This is just a quick note on something I found recently that’s quite annoying to debug.  It’s difficult to narrow down the issue because you can’t find any error logs in PHP-FPM nor PHP error log.  So here is the behavior, your site works fine for a short period after starting PHP-FPM.  Then, all of a sudden, you see blank pages in some pages.  If you wait a while and try again, some blank pages will come back.  It appears the problem is gone, but when you refresh again, blank page will show up again.  You can also fix it temporarily by restarting PHP-FPM.  However, you will face the same issue again after the restart.  The annoying part is that you can’t find any error logs anywhere.  The only way to expose the error is setting WP_DEBUG to true in wp-config.php.  It can be set as followed:

define('WP_DEBUG', true);

If you are experiencing the same issue as I do,  you will see an error similar to follow:

Fatal error: Internal Zend error - Missing class information for in .../wp-content/plugins/wp-super-cache/wp-cache-base.php on line 5

Here is the content of this file wp-cache-base.php:

Line 5 points to “class CacheMeta {“.  What it looks like is that APC can’t cope with how this class is dynamically declared.  A workaround is add the following line in your php.ini file.

apc.filters = wp-cache-base

This tells APC to ignore this file so instead of caching the runtime, it gets compiled every time it’s called upon.  The performance penalty is negligible for this small file so it’s safe to use this workaround.

Restart PHP-FPM (or PHP-CGI) now.  The blank pages issue should be gone.  

Good luck! 


Setting up MacPorts on Lion

21 07 2011

Just installed OSX Lion on my MacBook Pro last night and immediately I found my development environment was completely messed up. After the upgrade, all PHP modules I installed previously were gone. Some libraries I installed via MacPorts were gone as well. I tried a few things, “port selfudpate” and “port upgrade outdated”, in an attempt to stabilize the environment with no success. I was getting a lot of dependency issues. That prevented me from installing any more new modules. I read somewhere that installing MacPorts from their Subversion repository should help. I gave it a try and it appeared to have solved my problem.

First of all, check out the trunk from MacPorts, compile and install.
% mkdir -p /opt/mports
% cd /opt/mports
% svn checkout http://svn.macports.org/repository/macports/trunk
% cd /opt/mports/trunk/base
% ./configure --enable-readline
% make
% sudo make install
% make distclean

Then, update MacPorts:
# sudo port selfudpate
# sudo port upgrade outdated

You may still encounter some dependency issues. But at this stage, it should be very easy to resolve by temporarily pulling old libraries from Time Machine. For example, I ran into issue with gettext. The Lion upgrade removed this library /opt/local/lib/libintl.8.dylib that was used by gettext but it did not remove gettext completely. MacPorts was confused and refused to reinstall gettext. I had to go back to Time Machine to restore this file temporarily so I can set up gettext again. If you don’t have Time Machine, it would be difficult to acquire these old libraries. If it happens that you need this file, you can download it here.

You will need to force activate the module after you placed the library.
port -f activate gettext

Now, you can uninstall or upgrade the modules.

If you are still encountering dependency issues, try adding/removing binpath in /opt/local/etc/macports/macports.conf.
binpath /bin:/sbin:/usr/bin:/usr/sbin:/opt/local/bin:/opt/local/sbin:/usr/X11R6/bin

Some modules may need this binpath in order to install but most do not require this change.

A HAL bug?

15 11 2010

This is not related to Solr/Lucene but I have to write it down somewhere so I don’t forget it next time.  I have seen this problem a few times in the past and have always forgotten about it.  Here is the behavior, when you run a Linux VPS environment, SOMETIMES (I have to stress this) hald does not play nice with your CD/DVD virtual drive.  It may ping the drive every second unnecessarily.  For most of the time, you will hardly notice it.  However, on some occasions, it may consume enough CPU and I/O that can push your idle machine to have an extra load of 1.0 or above.  It’s quite annoying when it’s happening in a small VPS where resources is already very limited.  If this is happening in your environment, you will see a process called hald-addon-storage lingers that always consume at least 1% CPU.  To confirm that it really is eating up your resources, you can use the following command to trace the system calls it makes:

strace -t -p 

You may see a bunch of open calls, such as following, on your CD/DVD drive.

EBUSY (Device or resource busy)

So, what’s the solution?  I haven’t found a good solution for it other than stopping this pulling entirely.  Usually, you only use the CD/DVD during OS installation so stopping it shouldn’t create any adverse effect on your environment.  Here is what you should do to stop it:

  • Make sure haldaemon is still running, run following command to find your CD/DVD drive’s UDI
hal-find-by-capability --capability storage.cdrom
  • You should see something like this
  • Now create this file, /etc/hal/fdi/information/media-check-disable-cd.fdi, with following content:


And of course, replace the “info.udi” value with your own value.  Restart haldaemon now and you should be all good.