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

[ Submitted by John on Tue, 2008-08-12 15: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 13:42. | | ]