Resolution of trouble with CentOS 4 + PHP 5.1 + Zend Optimizer

I have a server running CentOS 4.4 updated with the PHP 5.1.6 from the testing repository. When I tried to install Zend Optimizer 3.0.2, I ran into this problem:

Failed loading [path]/ZendOptimizer. so: [path]/ZendOptimizer. so: undefined symbol: match

Then, when I tried to downgrade and install Zend Optimizer 3.0.1, I ran into this problem:

Failed loading [path]/ [path]/ failed to map segment from shared object: Permission denied

I noticed some talk about SELinux being a possible culprit, but rather than disable SELinux, I decided to try and solve the problem.

This article about SELinux and ColdFusion MX in Red Hat Linux 4 had the information I needed to quickly solve the problem. Basically, I needed to change the security context of the Zend extension manager and optimizer files so that Zend runs in the same security domain as the web server (in my case, Apache).

Here's what I did (note, I installed Zend Optimizer in a non-standard location -- /usr/include/php/Zend rather than /usr/local/Zend):

chdir /usr/include/php/Zend/lib
chcon -R --reference=/usr/sbin/httpd *.so
service httpd restart

Et voila!
Zend Working Screen Cap