scriptygoddess

05 Mar, 2004

What does "Full server path" mean?

Posted by: Jennifer In: Lessons learned

Often times when a script is posted here, the term "full server path" is used. This is a confusing term for many people. In the midst of a script tutorial or instructions, the focus is usually kept to the script at hand, so this term isn't described at depth, but ends up being the cause for many a script-installation to fail. Here, I'll try to describe what it means (and hopefully remember to link back to this post in the future whenever I use that term)

In as simple terms as possible, "full server path" refers to where your file is in relation to the server your file is sitting on. This will almost always include directories that are NOT web accessible. It basically STARTS with the very root of your server and works down the folder/hierarchy chain from there.

You may wonder why I just don't hand over your particular server path and tell you to swap out the folder names. The problem is that many servers are set up differently. Depending on who you host with, what type of server it is, how it's organized – there can be huge variations.

There's a few things you can do to try and figure out what your server path is.

Option 1) Build first, read directions later.
Obviously, this is not completely recommended. LOL! But if you do happen to have a script running, and it's spitting an error out, pay close attention to the error messages. If the problem is with the path you've provided, the error will probably look like:

Warning: you did something wrong blah blah blah in /home/jsmith/public_html/myfile.php on line 10

Just a little side track about using error messages to help debug your scripts – it may be too simple to mention, but when you get errors like this, GO LOOK AT LINE 10! (or whatever line is mentioned in the first error) Examine it VERY carefully. If it looks okay to you, GO LOOK AT LINE 9! Then, GO LOOK AT LINE 11! If the line mentioned in the error isn't actually causing the problem, sometimes the *real* problem is occuring on the line before or after the line mentioned.

Okay, getting back on track. You see that path in bold. THAT, my friends, is your full server path to your file. If ANOTHER path is mentioned in the blah blah blah part – and it's missing some parts or directories that you see in bold – you've entered in the wrong path in your script. (and this could very well be the cause for the error in the first place!)

This is huge. I can't tell you the number of times people miss that very easy clue. PHP knows your server path! It's handing it to you on a platter. Listen to it. :)

Option 2) I repeat, PHP knows your server path! Listen to it. 😉
There is a great little function in PHP: phpinfo(). And actually, another sidetrack. If you're not sure if your server is running php or not, using this simple little function will tell you. Just create a file that has the following and nothing else in it, and upload it to your server:

<?php
phpinfo();
?>

Pull that page up in a browser, and you should get a TON of information about php, your server. It's pretty cool actually. And… this page will also tell you what your server path looks like! 😀

Once you have that page loaded up in your browser, find the variable "PATH_TRANSLATED" or "_SERVER["PATH_TRANSLATED"]" (I'm relatively sure that should show up on the majority of configurations – if there's a better variable you suggest, please feel free to correct me in the comments). The value of this variable will be the full server path to the file you're looking at. It will probably look like:
/home/jsmith/public_html/testphpinfo.php
or maybe even:
C:\wwwroot\myfiles\testphpinfo.php

Option 3) Hold my hand please
If you have a really nice host, that doesn't mind being bugged – you can also try directly asking them. If they don't get what you're asking for, you can explain you're trying to run a php script, and the instructions required your using the server path to the file – maybe even point them to this post. They'll probably hate me forever. LOL! (If you're one of these host providers, and there's more information I can provide that will help people – feel free to post it in the comments. If it's value is wide enough, I can modify this post and include it here)

12 Responses to "What does "Full server path" mean?"

1 | Erica

March 5th, 2004 at 12:48 pm

Avatar

Another useful way to find the full web path, if you have telnet or ssh access (and you're using it), is to issue the "pwd" command. It will tell you exactly what the path is to the folder that you're in. :)

2 | Jennifer

March 5th, 2004 at 1:55 pm

Avatar

Erica – is that any different than being connected via FTP and issuing a raw ftp command? *If it isn't* – that may not give the full server path. For example – if I'm connected via FTP to my site, and I issue the raw command "pwd" – I get back simply "/" or "/public_html" (if I'm in public_html)… however, my server path looks more like:
/home/myaccount/public_html/etc…

3 | Jennifer

March 5th, 2004 at 2:03 pm

Avatar

😀 I'll answer my own question. LOL! It IS different. Just tried connecting via ssh – and it gave me the correct server path. :)

4 | Blinger

March 5th, 2004 at 5:52 pm

Avatar

I would think that any host worth their salt would provide you with the server path on demand preferably including it either on thier help pages or somewhere in your control panel

5 | Natalie

March 5th, 2004 at 10:32 pm

Avatar

I would also mention about the debugging part, sometimes where it says the error is (line 99) is caused by something way back earlier. In Java I get a lot of that caused by uninitialized variables, though of course PHP doesn't have that problem. But it's still something to remember… if you've looked for hours and can't find it, trace it back.

6 | Adnan

March 7th, 2004 at 5:08 am

Avatar

i want users to upload images.so i have copied images which users upload to permanent location on my server.i also got current working directory by using funciton getcwd();….
i want to upload images so that when i host my site on any commercial webserver, it can get path of that server dynamically. and upload pictures in specified location………..

7 | Imabug

March 8th, 2004 at 9:20 am

Avatar

A 'pwd' command issued from a telnet/ssh session will definitely (or had better) give you a different path than the same command issued from an FTP session. A properly configured FTP server will be CHROOTed so that / points to the root of the FTP space, rather than the root of the file system. This prevents people from sneakily trying to FTP files to /../../../etc/passwd or other evilness.

8 | Christine

March 15th, 2004 at 11:28 pm

Avatar

I made a point of adding the full server path information needed to my new hosting client e-mails. In the past year, I think maybe 1 client has come back and asked for that information. It's so much easier to give it to people up front!

(On a separate note – the tab order for the comment page is out of order – it jumps from the RSS line to the "please email me" line, skipping the code line. I'm tab happy on this keyboard.)

9 | Theo

May 26th, 2004 at 4:12 am

Avatar

Tank you for this, it was VERY helpful to me!!!

10 | anthony

May 27th, 2004 at 11:31 pm

Avatar

wow!
i've had lots trouble finding coherent php information online, but you solved my problem right away.

you guys rock, thank you.

11 | [supafine] geek blog

March 7th, 2004 at 5:15 pm

Avatar

Hmm. Server path, eh?
Scriptygoddess has an article — "Lessons learned: What does 'full server path' mean?" — that I need to read again. I think it may help with the PHP styleswitcher I've still got on the back burner….

12 | Coachamatic.com

April 10th, 2004 at 1:43 pm

Avatar

What's a Full Server Path?
The first hurdle in script installation.

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements