Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Global Test Directory 1

Status
Not open for further replies.

newpoet

Programmer
Jan 12, 2008
6
Hi,

I'm not sure how to word this, but I have a USB drive with Uniserver, XAMP, and WOS portable webservers installed.

The problem is that I would like to have a "test" directory that is independent of these three servers, but still accessible by typing something like "localhost/test" into the browser, regardless of which package I'm running.

Each server package has its own neat little pros and cons and I'd like to be able to play around with all of them and still have the same common access to the same test directory.

Does anybody know if it's possible and how I can do that?
 

those are all apache based right?

all you need is mod_alias (if not installed)
and and an Alias directive on each like

Alias /test "path_to_your_test_stuff"

and a Directory directive to allow access

<Directory "path_to_your_test_stuff">
Allowoveride None
Order allow,deny
Allow from all
</Directory>
 
I appreciate your help. I don't know what I'm doing wrong.

When I do this, it causes an error that keeps the server from starting:

##########VIRTUAL HOST SETUP##########
# TEST
<VirtualHost *>
DocumentRoot "X:\testserver"
ServerName tst
</VirtualHost>

<Directory "tst">
Allowoveride None
Order allow,deny
Allow from all
</Directory>
 
So each Document root has a directory called tst?

I thought you wanted to share a directory like this (Pardon my ignorance, I don't Apache under windows):

Alias /tst "C:\testdir" (this is global)

<Directory "C:\testdir"> (I think this can be global too)
Allowoveride None
Order allow,deny
Allow from all
</Directory>

So if you had a test.php file in C:\testdir, all you would have to do on any of your virtual webservers:

 
Thanks again for your help and patience.

Basically, I have about four different projects going on and each one has a lot of files involved.

You know how you type in "localhost" in the broswer and that takes you to the server's default directory?

I wanted to have three more directories on another disk drive named tst (X:\test) jom (Y:\jombla) osc (Z:\osCommerce).

So when I typed "tst" in the browser it would take me to that directory with all of those files, etc.

I thought for sure I was able to do this in the past with Apache, but I forgot how and can't get it to work now.

I know I could put them all in subdirectories under the "www" server directory, but they are different projects and I was looking for an easy way to keep them all seperate.
 
It sounds like you want to setup 3 named based virtual host.

Please phrase it like this:

When I type in X I want it do Y.

For instance, I assume this is what you want:

When I type in I want it to start serving pages from X:\test
When I type in I want it to start serving pages from Y:\jombla
When I type in I want it to start serving pages from Z:\osCommerce

If this is what you want, first you have to get DNS to think the server test, jombla and oscommerce are on your box, or some other names that you choose. Locally, you can do this by editting the hosts file.

Then it is matter of configuring 3 named based virtual hosts on your box with the different ServerNames and DirectoryRoots.

eugene
 
Yes, that's exactly what I want it to do.

The folders are out there with temporary index.htm files.

I put this in the config file:

##########VIRTUAL HOST SETUP##########
# TEST
<VirtualHost *>
DocumentRoot "X:\testserver"
ServerName tst
</VirtualHost>

But when I type in the browswer starts searching for websites named "tst" on the internet.
 
You need to map these "fake" names to the IP of the box, either 127.0.0.1 or the real one.

I would add
127.0.0.1 tst jombla oscommerce
or the real ip
A.B.C.D tst jombla oscommerce

remember that this changes what the boxes IP mapping for these names (if unqualified). So if it uses jombla or oscommerce, I would make the name more unique, like jombla-test and oscommerce-tst.


How to edit hosts on vista:


another link:


And remember that you did this! Nothing is more embarassing than "Hey, I get different results from my box and realizing that the hosts file is the culprit."

If you want this accessible from other boxes, just map the names to IP in DNS as CNAMES.
eugene
 
Don't get me started about embarassment; I'm like a diabetic kid in a candy store when it comes to this stuff.

"You need to map these "fake" names to the IP of the box, either 127.0.0.1 or the real one.

I would add
127.0.0.1 tst"

Is this what you mean?

##########VIRTUAL HOST SETUP##########
# TEST
<VirtualHost 127.0.0.1 tst>
DocumentRoot "X:\testserver"
ServerName tst
</VirtualHost>

######################################

I don't want this accessible from any other computer than the one I'm running it on. I'm using Universal Server for testing, and it's just me doing it for now.
 
You don't need 127.0.0.1 or tst in the VirtualHost line:

<VirtualHost *>

That only defines what IP and port the VirtualHost is bound.
The server takes what is in ServerName and matches with the called URL (what you type in the browser)

What you are missing is to add
127.0.0.1 tst
to the hosts file to fake out nameservice. Without this, your browser will always try and resolve the name using DNS or WINS or whatever and never get the packets to IP address 127.0.0.1 port 80 (your box running your web server).

After you make the host change, you should be able to run/command and "ping tst" which will return a reply from 127.0.0.1. If it doesn't something is wrong.

eugene
 
What you are missing is to add
127.0.0.1 tst
to the hosts file to fake out nameservice."

#####

I'm sorry, but you lost me here.

Do you mean like this?

##########VIRTUAL HOST SETUP##########
# TST
<VirtualHost *>
ServerName 127.0.0.1 tst
DocumentRoot "X:\testserver"
</VirtualHost>
 
It isn't in the Apache configs. You are running some flavor of windows ?, and that supports a text file (but it does not have the .txt extension) called "hosts" It usually is in C:\windows\system32\drivers\etc\hosts.

Do a google search about editting host file for windows.
You simply add:
127.0.0.1 tst
to the file (save as type text without the .txt extension)

It should already have
127.0.0.1 localhost
in there.

So that file should look like:

127.0.0.1 localhost
127.0.0.1 tst

Now test by "ping tst". You don't need to reboot or restart anything and it should work.

This is what I would have for Virtual host:
##########VIRTUAL HOST SETUP##########
# TST
<VirtualHost *>
ServerName tst
DocumentRoot "X:\testserver"
</VirtualHost>

Changing the apache configs is not going to work, it does not affect nameservice mapping.

eugene
 
I really appreciate your help, hombre.

I'm jumping around from Vista32 to XP and back.

I'm running 'Universal Server' off of a USB key or from a select drive (usually X:\).

I did this once already from the config file, and it worked, but then it stopped working.

I'll try what you said.

Thanks much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top