btongeorge
btongeorge

Reputation: 453

PHP unable to open include file

I have a problem with a PHP script. The following error is being logged whenever the site is accessed:

[Fri Sep 26 11:57:56 2014] [error] [client 31.22.44.2] 
PHP Fatal error:  require_once(): Failed opening required
 './sites/default/modules/views/handlers/views_handler_field_markup.inc' 
(include_path='.:/usr/share/php:/usr/share/pear') in 
/var/www/www.xoomtalk.com/htdocs/sites/default/modules/views/includes/handlers.inc
 on line 76

I have confirmed that the file referenced is present, and that www-data can access it. Permissions look fine and have not been changed as far as I am aware

What am I missing?

Upvotes: 0

Views: 332

Answers (3)

btongeorge
btongeorge

Reputation: 453

I managed to solve this problem, ended up being nothing to do with permissions or paths, although there was no indication of this in the Apache logs.

The problem was that the server was also running AppArmor which for some reason was blocking the Apache process from accessing the files.

AppArmor was set to complain rather than enforce mode for testing (command is aa-complain apache2) this made everything start working.

Thanks to all contributors for their suggestions.

Upvotes: 0

Gipsz Jakab
Gipsz Jakab

Reputation: 433

in the following file: /var/www/www.xoomtalk.com/htdocs/sites/default/modules/views/includes/handlers.inc on line 76

Change This:

'./sites/default/modules/views/handlers/views_handler_field_markup.inc'

to THIS: '/var/www/www.xoomtalk.com/htdocs/sites/default/modules/views/handlers/views_handler_field_markup.inc'

This should do the trick. The problem is, you're using scripts from various directories, but the "root" of the request is the cwd (current working directory) which you can check with: getcwd() (and you're requesting the include relative to the cwd.

Upvotes: 1

TopCaver
TopCaver

Reputation: 369

[Fri Sep 26 11:57:56 2014] [error] [client 31.22.44.2] PHP Fatal error: require_once(): Failed opening required
'./sites/default/modules/views/handlers/views_handler_field_markup.inc' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/www.xoomtalk.com/htdocs/sites/default/modules/views/includes/handlers.inc on line 76

Add path /var/www/www.xoomtalk.com/htdocs into your include_path

More explains:

your include_path=.:/usr/share/php:/usr/share/pear , means php script will find include file in: current_path, /usr/share/php or /usr/share/pear

when you want to require this file ./sites/default/modules/views/handlers/views_handler_field_markup.inc

all allowed path are: (current path) /var/www/www.xoomtalk.com/htdocs/sites/default/modules/views/includes/./sites/default/modules/views/handlers/views_handler_field_markup.inc

(/usr/share/php) /usr/share/php/./sites/default/modules/views/handlers/views_handler_field_markup.inc

(/usr/share/pear) /usr/share/pear/sites/default/modules/views/handlers/views_handler_field_markup.inc

In these path ,php can't find the file.

Upvotes: 1

Related Questions