php.ini: Using a Relative Doc_Root (for Portability)

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
tgftw
Forum Newbie
Posts: 1
Joined: Sun Mar 15, 2009 11:41 pm

php.ini: Using a Relative Doc_Root (for Portability)

Post by tgftw »

I'm running Mongoose web server on my USB flash drive.

I've got PHP installed on the flash drive as well, and it works fine, as long as I have:

doc_root = I:/server/www

For record, the PHP files are in /server rather than a /php folder... I didn't see the reason to have it in a seperate folder from the server, when they're supposed to be run together... it just makes it easier to navigate :)

Now, my problem is, if I plug my USB drive in on a computer where it's not the I: drive, PHP won't work. (my PC has a lot of ports for SmartCards and such, my laptop doesn't... laptop shows my USB as the E: drive)

I've tried the following configurations to no avail: (keep in mind, the path to php.ini is I:/server/php.ini)

doc_root = ./www
doc_root = .\www
doc_root = /www
doc_root = \www

None of them seem to work. I've seen a lot of portable WAMP servers though, so I know there's got to be a way to set the path correctly. I have to run PHP in CGI mode because of the limitations of Mongoose.

Can anyone help? Thanks a lot! :)

Please refrain from telling me to use Apache, btw. The idea is to conserve disk space and Mongoose is very small. If you're going to suggest another web server, please keep in mind FILE SIZE and PORTABILITY. (in terms of physical portability, not operating systems - it will be running on Windows)

UPDATE! I've achieved an equivilent functionality work-around using the "subst" command in a batch file. For anyone that's attempting this, make a Windows Batch file (*.bat) with the following command:

subst Z: .

where Z: is the drive letter you'd like to use and C:\filepath is the path to the stuff you'd like to always have on that drive. (note the period at the end)

to "unmount", use:

subst Z: /D

There's a glaring flaw in this method however... if, for example, your host PC has a network folder mapped to the Z: drive, I can predict that the concept will fail similarly to my original php.ini.

I'm still extremely interested in finding out the way to make a relative Doc_Root, as this is more elegant and simple, and not succeptible (sp?) to the flaw mentioned above.
Post Reply