views:

41

answers:

1

Hey,

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!!).

Many thanks in advance.

Regards,

Richard

+4  A: 

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');.

halfdan
I have tried that and it doesnt work either. Basically what I want is to be able to have "vars.php" in the root of the site, then have files at any level of the site which include "/vars.php". Also I have a pagesections.php to include which contains functions for the header, footer, **menu** and so on. The menu will contain links using relative URLs - but at the moment these wont work as I am currently using "a/path/to/navigate/to". I think these are classed as absolute paths. Obviously these may work on one level but not on any others (unless they have the same folder structure).
ClarkeyBoy
By the way I have used relative URLs starting with "/" in .net and PHP before now - I know how to use them just I have never set up a site like this before... I dont know what I need to change and where...
ClarkeyBoy
Well I managed to get it working - I used require_once $_SERVER["DOCUMENT_ROOT"]."/vars.inc"; instead. I also noticed that the relative URLs in the links were working after all - I didnt think they were... Is it better to use DocumentRoot or to allow url includes and use the server name and port?
ClarkeyBoy