I'm getting the strangest problem with my PHP extension. When I use it from the command line, like so:
php -r '$mc = new MyClass("foo"); echo $mc->getField();'
it prints out "foo" as expected.
However, if I try to do the same thing from within my index.php, I get a class not found error.
Fatal error: Class 'MyClass' not found in /var/www/html/index.php on line 12
How could this be happening? I've even set httpd to run as the same user as myself when running the php -r command.
My index.php looks like so:
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<p>
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
$mc = new MyClass("foo");
echo $mc->getField();
?>
</p>
</body>
</html>
The php portion of my httpd.conf looks like so:
# PHP Configuration for Apache
#
# Load the apache module
#
LoadModule php5_module modules/libphp5.so
#
# Cause the PHP interpreter handle files with a .php extension.
#
<Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
LimitRequestBody 9524288
</Files>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php
And obviously my php.ini is set up correctly, because my php -r command works. What could possibly be causing this issue?
It turns out that the issue was due to SELinux. If it is turned off like so:
echo 0 >/selinux/enforce
Everything magically works.