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.

[ Submitted by John on Tue, 2011-03-01 11:00. | | ]

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

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


wget http://dl.iuscommunity.org/pub/ius/stable/Redhat/5.5/x86_64/ius-release-1.0-6.ius.el5.noarch.rpm
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

Done!

[ Submitted by John on Mon, 2010-11-08 09:27. | | ]

Performance presentation, Des Moines Web Geeks

Matt Nuzum, the webmaster of ubuntu.com, 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).

[ Submitted by John on Tue, 2009-09-22 09:07. | | ]

Installing APC on RHEL5

Here's how to install APC on RHEL5.
# yum install php-pear php-devel httpd-devel
# pecl install apc
# echo "extension=apc.so" > /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/apc.so' - /usr/lib/php/modules/apc.so: 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 (./apc.so). 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 apc.so
-rwxr-xr-x root root system_u:object_r:textrel_shlib_t dbase.so
-rwxr-xr-x root root system_u:object_r:textrel_shlib_t gd.so
...

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

# restorecon /usr/lib/php/modules/apc.so
]# ls -Z /usr/lib/php/modules
-rwxr-xr-x root root system_u:object_r:textrel_shlib_t apc.so
-rwxr-xr-x root root system_u:object_r:textrel_shlib_t dbase.so
-rwxr-xr-x root root system_u:object_r:textrel_shlib_t gd.so
...

Now let's try again:

# service httpd restart

Yay!

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

[ Submitted by John on Tue, 2008-08-12 16:13. | | ]

IIS6.0, FastCGI Go Live, Windows Server 2003

With all the hoopla about FastCGI on IIS I thought I'd give it a whirl. Here's what I did.

Installed Windows Server 2003 R2 Standard Edition.

Selected Application Server role. This installs IIS 6.

Setup autologin since this is a disposable virtual machine.

Fought IE7's draconian security popups to download Firefox.

Downloaded mysql-essential-5.0.45-win32.msi.

Downloaded php-5.2.4-nts-Win32.zip. (This non-thread-safe version is recommended to use FastCGI).

Extracted the contents to C:\php.

Went to My Computer - Properties - Advanced - Environmental Variables and added ,C:\php to the PATH variable.

Renamed php.ini-dist to php.ini. I used php.ini-dist since this is just a development box.

In php.ini:

- uncommented fastcgi.impersonate = 1 since I plan to run it with IIS.
- set doc_root = "C:\Inetpub"
- set session.save_path = "C:\php\sessiondata"

Opened port 80 in the firewall. I can now send a request to IIS and get back a response in my web browser. The response is an Under Construction page since I haven't set a default page in IIS yet. Made a index.htm file and said Hello World.

Downloaded FastCGI Extension for IIS6.0.

The End-User License Agreement includes this: "You may not disclose the results of any benchmark tests of the software to any third party without Microsoft's prior written approval". Thus you will not see any benchmarks from me.

And this: "If you give feedback about the software to Microsoft, you give to Microsoft, without charge, the right to use, share and commercialize your feedback in any way and for any purpose." Thus you will not see any feedback about the Microsoft FastCGI Extension for IIS 5.1 and 6.0 Go Live software from me.

Configured FastCGI according to these instructions.

My C:\WINDOWS\system32\inetsrv\fcgiext.ini file contains the minimum:

[Types]
php=PHP
[PHP]
ExePath=C:\php\php-cgi.exe

I created a basic hello.php file containing

<?php
 
echo "Hello world from PHP."
?>
.

I can now do \php\php.exe \Inetpub\wwwroot\hello.php at the command line and it works.

But hitting it through IIS results in

FastCGI Error

The FastCGI Handler was unable to process the request.


Error Details:

  • The FastCGI process exited unexpectedly
  • Error Number: -2147467259 (0x80004005).
  • Error Description: Unspecified error

HTTP Error 500 - Server Error.
Internet Information Services (IIS)

Using Rick James' Fake FastCGI Web Server to say

C:>fakefcgi.exe c:\Inetpub\wwwroot\hello.php c:\php\php-cgi.exe

I get

Fake FastCGI web server
FCGI_PARAMS sent
FCGI_STDIN sent
Launching receive loop
FCGI_STDOUT: Status: 404
X-Powered-By: PHP/5.2.4
Content-type: text/html
No input file specified.
FCGI_END_REQUEST received
killing app
FastCGI process exited with 0

I installed procmon and discovered that the IIS user (NETWORK SERVICE) did not have Execute access to C:\php\php5.dll. Once that was granted, my hello.php ran.

The next problem was that I wanted to set up Drupal, so clearly I need to run MySQL. But PHP would not load the C:\php\ext\php_mysqli.dll file. Again, a permissions issue solved by giving NETWORK SERVICE access. Clearly I must have missed the permissions section of the PHP installation docs.

Thanks to Drew Robbins of Microsoft for debugging the extension permissions issues.

[ Submitted by John on Tue, 2007-10-23 14:42. | | ]