changing root

Problems with the Windows version of XAMPP, questions, comments, and anything related.

changing root

Postby TheTitans » 04. February 2008 04:59

I have this problem with one of my PHP scripts.

Code: Select all
Warning: require(/admin/top.php) [function.require]: failed to open stream: No such file or directory in C:\xampp\htdocs\admin\scripts\authentication.php on line 2

Fatal error: require() [function.require]: Failed opening required '/admin/top.php' (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\admin\scripts\authentication.php on line 2


It's suppose to open top.php in the admin directory, but it's failing.

In my PHP code I have this:

Code: Select all
require("/admin/top.php");


I figured that the htdocs folder would be the root. When I view my website with http://localhost/, my website in the htdocs folder does appear. However, with the error above, the system is thinking that the C:\ drive is the root (or so I think). So why won't it let me open top.php?

BTW, I did change my httpd.conf file and it's still not working.

DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
TheTitans
 
Posts: 5
Joined: 04. February 2008 04:53

Postby Izzy » 04. February 2008 06:31

This is what you should see in your httpd.conf file not what you did as that was very wrong.

Code: Select all
DocumentRoot "C:/xampp/htdocs"

#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features. 
#
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "C:/xampp/htdocs">
...and look how the rest of this <Directory "C:/xampp/htdocs"> directive is constructed by reading on from here until you see the end of the directive </Directory>.

You will see that the DocumentRoot has it's configuration changed to allow access from all among other directives that it needs to function.

TheTitans wrote:DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>

You have just changed this in error and now Deny from all means exactly that - no access for anybody to the htdocs directory, your server's DocumentRoot - so correct this by reverting to what it should be, as pointed out above, and read the comment # lines in the httpd.conf file as they will help you in future.

You should not change anything in the httpd.conf file until you know what you are doing or you will always have issues.

Your error message has nothing to do with the httpd.conf file at all and is the result of your not quite knowing how to configure your scripts.

The error message is telling you that the path to /admin/top.php is not correct as /admin is C:\xampp\htdocs\admin and I suspect this is not the case - the server is looking for the directory admin in the htdocs directory and can't find it, according to the error message.

TheTitans wrote:with the error above, the system is thinking that the C:\ drive is the root
That is not what I see and I just explained that above.

Try changing the link in your php script to a full path "C:/xampp/htdocs/admin/top.php" if your website is in htdocs (or is it in a sub directory of htdocs like htdocs\mysite\admin?) or simply change it to a relative path to C:\xampp\htdocs\admin\scripts\authentication.php - you will need to experiment with this for example .\admin\top.php

Paths are all important and need special attention and double checking to make sure they are indeed correct.

Don't forget to restart Apache after making changes to the httpd.conf file and always make a back up conf and ini files before editing, this way you always have a clean default starting point to try again if things go belly up.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 60 guests