Installing php-mbstring on RHEL6

I wanted to install the mbstring PHP extension on Red Hat Enterprise Linux 6. But to my surprise, it wasn't there:

# yum install php-mbstring
Loaded plugins: rhnplugin
Setting up Install Process
No package php-mbstring available.
Error: Nothing to do

That's because the package is in the RHEL Server Optional repository.

I went into RHN and enabled the repository:

After doing yum update I could do yum install php-mbstring with no problems.


Installing PHP 5.2 (or 5.3) on RHEL5 the easy way

Just replace the stock PHP with one from the IUS Community project.

rpm -Uvh ius-release-1.0-6.ius.el5.noarch.rpm
yum install yum-plugin-replace
rpm -qa | grep php
yum replace php --replace-with php52
/sbin/service httpd restart



Performance presentation, Des Moines Web Geeks

Matt Nuzum, the webmaster of, invited me to speak at the Des Moines Web Geeks meeting last night. The venue, Impromptu Studios, was a bit hard to find. There were no signs for Impromptu Studios, but after lurking in dark alleyways for a while I eventually discovered what should have been obvious from the beginning: enter the furniture store with the "Closed" sign on the front and go up the stairs past the disused lavatory with a sign on the door saying "Beware of the Leopard."

The group was great and we talked for about an hour and half about bottlenecks and optimization. I even went home with a Django book!

Since this was a diverse group I tried to talk about things that everyone has to deal with (bottlenecks for storage, network, memory and CPU) rather than anything Drupal-specific.

As promised, last night's slides: Performance, Scalability on the Server Side (PDF, 1MB).

Installing APC on RHEL5

Here's how to install APC on RHEL5.

# yum install php-pear php-devel httpd-devel
# pecl install apc
# echo "" > /etc/php.d/apc.ini
# service httpd restart

Check for the apc section in your phpinfo() page. If it's not there:

# tail /var/log/httpd/error_log
[Tue Aug 12 15:43:59 2008] [notice] Digest: done
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/' - /usr/lib/php/modules/ cannot open shared object file: Permission denied in Unknown on line 0

SELinux is preventing the extension from loading, I'll bet. Let's check:

# tail /var/log/messages
Aug 12 15:42:40 mybox yum: Installed: httpd-devel - 2.2.3-11.el5_1.3.i386
Aug 12 15:44:01 mybox setroubleshoot: SELinux is preventing the httpd from using potentially mislabeled files (./ For complete SELinux messages. run sealert -l 9e4bbfa8-327b-4bb2-94df-f154045a1ef1

Let's view the security contexts for our PHP extensions:

# ls -Z /usr/lib/php/modules
-rwxr-xr-x  root root root:object_r:tmp_t    
-rwxr-xr-x  root root system_u:object_r:textrel_shlib_t
-rwxr-xr-x  root root system_u:object_r:textrel_shlib_t

Yup. Notice how the security context is missing (it's tmp_t for Let's fix that.

# restorecon /usr/lib/php/modules/
]# ls -Z /usr/lib/php/modules
-rwxr-xr-x  root root system_u:object_r:textrel_shlib_t
-rwxr-xr-x  root root system_u:object_r:textrel_shlib_t
-rwxr-xr-x  root root system_u:object_r:textrel_shlib_t

Now let's try again:

# service httpd restart


P.S. On x86_64, is in /usr/lib64/php/modules.


Subscribe to RSS - PHP