require_once() [function.require]: Failed opening required '/vars.inc' (include_path='.;C:\php5\pear')

StackOverflow https://stackoverflow.com/questions/3868900

문제

I have several sites setup on my local machine - customerappglobal, customerapp and naturaleigh. I have just one - customerappglobal - working at the moment because thats the only one I need working. I have added the following code to my httpd.conf file:

<VirtualHost *:427>
 # The name to respond to
 ServerName customerappglobal
 # Folder where the files live
 DocumentRoot "C:/HeritageApps/CustomerApp_v2"
 # A few helpful settings...
 <Directory "C:/HeritageApps/CustomerApp_v2">
  allow from all
  order allow,deny
  # Enables .htaccess files for this site
  AllowOverride All
 </Directory>
 # Apache will look for these two files, in this order, if no file is specified in the URL
 DirectoryIndex index.html index.php
</VirtualHost>


<Directory "c:/HeritageApps">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride all

    #
    # Controls who can get stuff from this server.
    #

#   onlineoffline tag - don't remove
#Allow,Deny
    Order Deny,Allow
    Allow from all

</Directory>

This appears to be enough for it to work (oh and a line added in the HOSTS file..).

Anyway I am using wampserver (the latest one) with PHP 5, Apache and mySQL. The site loads fine unless I use a relative path for require_once in the file I am trying to load.

I get the following error:

Warning: require_once(/vars.inc) [function.require-once]: failed to open stream: No such file or directory in C:\HeritageApps\CustomerApp_v2\Customers\Customers.php on line 2

Fatal error: require_once() [function.require]: Failed opening required '/vars.inc' (include_path='.;C:\php5\pear') in C:\HeritageApps\CustomerApp_v2\Customers\Customers.php on line 2

As far as I know the include path (C:\php5\pear) does not exist and I cannot find any trace of that path in the php.ini file or the httpd.conf files. I have read that the non-existance of the path is why it is throwing the error, but I have not found any solutions. This has been happening for the past day or two and I tend to suffer from the curse of getting wound up and angry if something doesnt work for too long - so please could someone help me with this? I really dont know what is going wrong or where it is going wrong... I have searched everywhere that I can think of. I just need to be able to change the include path for all the applications individually (or changing it globally would be a brilliant start!!).

도움이 되었습니까?

해결책

The problem is your include: Warning: require_once(/vars.inc), where / relates to the file system root. What you really want is either require_once('./vars.inc'); or require_once('vars.inc');.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top