configure multiple public_html directories with a single IP

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
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

configure multiple public_html directories with a single IP

Post by neophyte »

I've got a fresh installation of xampp. (http://apachefriends.org/en/) Anyway I'd like to configure it to run over a network with more than one web directory(public_html). I only have one ip address. It's been suggested that I run them to different ports. Can someone give me apache directives example for this? Or just how do I go about doing it?

Thanks
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

at the bottom of httpd.conf, there should be something like this:

Code: Select all

<VirtualHost *:80>
    ServerName example.com
    DocumentRoot /path/to/public_html
</VirtualHost>
Just add another as so (change the 8080 to whatever you want):

Code: Select all

<VirtualHost *:8080>
    ServerName example.com
    DocumentRoot /path/to/public_html2
</VirtualHost>
To get to that addy, though, the user would have to type in the address bar:
example.com:8080

You should do subdomains instead:

Code: Select all

<VirtualHost *:80>
    ServerName subdomain.example.com
    DocumentRoot /path/to/subdomain_html
</VirtualHost>
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

The problem is I don't have a dns or .com address. It's localhost with a single IP over a n intranet.

I've gotten it to work so far with this:

Code: Select all

#First tell apache to listen to a port
Listen 8080
...
#Tell it what port to get
<VirtualHost 192.168.0.100:8080>
  ServerName 192.168.0.100:8080
   DocumentRoot c:/webserver/xampp/htdocs/xampp/rwu/www
 </VirtualHost>
My only problem is that when I hit http://192.168.0.100:8080/ it doesn't load index.php. It tries to load xampp/splash.php -- Any clues where to look to get rid of this annoying option? What directive would make this happen. I don't think the above works with localhost in place of the ip address.
Last edited by neophyte on Tue Jun 14, 2005 4:35 pm, edited 1 time in total.
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

ah. you can get a domain as cheap as 4 USD per year.

Using an IP shouldn't change it, though.

Code: Select all

<VirtualHost 192.168.0.100:8080>
  ServerName 192.168.0.100
  DocumentRoot c:/webserver/xampp/htdocs/xampp/rwu/www
</VirtualHost>
You don't need the port again on ServerName.

Just so you know (I'm sure you do), this is only accessible via your local network. 192.* is a local IP. ;)
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

Yup, I'm just interested in setting this up for a test environment.
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

Any ideas of what directive to look at to make index.php the default instead of xampp/splash.php?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

I suggest you get an account with no-ip.org (it's free) and then set up virtual hosts by name.

That's easy too (you can have them all on port 80 like they should be).

Code: Select all

NameVirtualHost *:80

<VirtualHost *:80>

ServerName daliup.no-ip.org
DocumentRoot /home/daliup/public_html/

</VirtualHost>

<VirtualHost *:80>

ServerName corbyn.no-ip.org
DocumentRoot /srv/www/htdocs/

</VirtualHost>

<VirtualHost *:80>

ServerName w3style.co.uk
ServerAlias www.w3style.co.uk
DocumentRoot /home/d11wtq/public_html/.w3style_files/

</VirtualHost>
Last edited by Chris Corbyn on Tue Jun 14, 2005 5:18 pm, edited 1 time in total.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

neophyte wrote:Any ideas of what directive to look at to make index.php the default instead of xampp/splash.php?

Code: Select all

# List of resources to look for when the client requests a directory
DirectoryIndex index.php index.php3 index.html index.htm index.pl
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

Thanks for the tips all!
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Btw, you don't need to buy domain name(s).

Simply edit your /etc/hosts or c:/windows/system32/drivers/etc/hosts

Code: Select all

127.0.0.1       localhost test

Now i can surf to localhost and to test ;)

Code: Select all

NameVirtualhost *:80

<VirtualHost *:80>
  ServerName localhost
  DocumentRoot &quote;F:/websites/localhost&quote;
  <Directory &quote;F:/websites/localhost&quote;>
    AllowOverride All
    Options All
  </Directory>
</Virtualhost>

<VirtualHost *:80>
  ServerName test
  DocumentRoot &quote;F:/websites/test&quote;
  <Directory &quote;F:/websites/test&quote;>
    AllowOverride All
    Options All
  </Directory>
</Virtualhost>
Post Reply