Absolute path?


#1

I’m trying to configure a php script and the tutorial I’m using says I need the absolute path where my files are at on the server. How do I find this out? Does this question even make sense?
Thanks!

Aaron


#2

Hi Aaron,

For example, if the script your using is looking for the path for ‘sendmail’ then you need to put the full path to where that is.

You can find out the path by typing ‘which sendmail’ at the UNIX command line.

Like so:

vic@mianetworks:~$ which sendmail
/usr/sbin/sendmail
vic@mianetworks:~$

The path will be:

/usr/sbin/sendmail

In unix you can issue the command ‘pwd’ that will tell you what dir. you are in.

hope this helps…

It also would be helpful if you posted part of the script that is giving you trouble.

Vic


#3

What I normally do is, use a php include code with some wrong paths and then when I visit the page, it will state my correct path :slight_smile:


#4

On Apache installations like the one at DreamHost, PHP gives you the absolute path (also known as relative from root) by means of a variable in the $_SERVER global array. You can access the variable like this:

$_SERVER['DOCUMENT_ROOT']Please note that the uppercase is required. It will return that path, which looks like this:

/home/username/domain/To make life easy, you can create a global variable that you can use within you scripts:

$path = $_SERVER['DOCUMENT_ROOT'];--------
Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]