web stats OS X Client Server » Blog Archive » Enable PHP Includes on OS X



Enable PHP Includes on OS X


PHP

Im in the process of switching to a new server. Tonight I noticed in my error log:

/var/log/httpd/error_log

This error:

[Mon Apr 23 02:27:30 2007] [error] PHP Warning: include(/script.php) [function.include]: failed to open stream: no suitable wrapper could be found in /script.php on line 26

I search around a bit and found the problem. The default instalation turns Has includes set to off for sucrity reasons. If you want to enable includes open:

/usr/local/php5/lib/php.ini
or
/usr/local/php/lib/php.ini

On Snow Leopard it is in:
/etc/php.ini

and search for:

Whether to allow include/require to open URLs (like http:// or ftp://) as files.
allow_url_include = Off

Switch to:

allow_url_include = On

Save and restart apache.

You can also turn on fopen from the same file, its right above the includes lines.

My text editor was unable to open the php.ini file because it did not have safficiant privileges. I used the editor in Webmin, if you have not installed Webmin yet you can edit it using pico