Jump to content

Recommended Posts

I have a puzzeling situation that I cannot solve. After having our OS reinstalled, all our old PHP scripts are no longer retrieving the include or required files in the scripts.

 

The OS is CentOS 5.2 and it seems when the sites subdomains listed under /var/www/vhosts/site.com/subdomains/domain.name/httpdocs/ cannot retrieve any files from outside that directory.

 

This was working before the reload, which was in response to a hardware issue. The OS'es are the same and nothing has been adjusted.

 

OS: CentOS 5

Web: Apache 2.2.3

PHP: PHP 5.2.6

MySQL: 5.0.58

PERL: 5.8.8

Link to comment
https://forums.phpfreaks.com/topic/124800-includerequire-not-pulling-file/
Share on other sites

I am not sure if I understand your concern, but if you are trying to access a remote file (that is not in folder "httpdocs") then:

 

1. edit php.ini and set allow_url_fopen setting to "on"

2. in your code use:

<?php
include 'http://www.example.com/file.php?foo=1&bar=2';
?>

 

More help here: http://us.php.net/manual/en/function.include.php

I get an error now, not sure why it wasn't reporting prior and have checked the php.ini for the allow_url_fopen, which is on but still being refused:

 

Warning: require() [function.require]: URL file-access is disabled in the server configuration in /var/www/vhosts/domain.tld/httpdocs/dev/events.php on line 86

 

Warning: require(http://www.domain.tld/dev/scripts/left_sidebar.php) [function.require]: failed to open stream: no suitable wrapper could be found in /var/www/vhosts/domain.tld/httpdocs/dev/events.php on line 86

 

Fatal error: require() [function.require]: Failed opening required 'http://www.domain.tld/dev/scripts/left_sidebar.php' (include_path='.:') in /var/www/vhosts/domain.tld/httpdocs/dev/events.php on line 86

 

I adjusted this to use require_once and include_once with the same results .. I am not sure what is going on since there are two php.ini files (on in /etc and one for Zend, both of which have the allow on).

Create a php page with the following code:

print phpinfo();

View the page and the location of the php.ini will be displayed near the top.

 

Remember you must restart the webserver after making changes to the ini file

yup .. i checked and it's reading the normal /etc/php.ini .. also both files have allow_url_fopen=on .. I have restarted both Apache and the server (for another reason_) with no luck.

 

Would this have anything to do with the chrooted environment on CentOS?

Is the URL that you are trying to include on your own webserver. allow_url_fopen is for incoming requests, not outgoing.

If it is on your own server then why do you not use the full server path i.e.

 

include("/var/www/html/domain.com/docs/sidebar.php");

Again, allow_url_fopen is on .. in both, however, when looking at the phpinfo, I see this:

 

allow_url_fopen On On

allow_url_include Off Off

 

I cannot locate the allow_url_include in any of the ini files at all .. was this removed or renamed in 5.2?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.