Vhosts and URL

Problems with the Linux version of XAMPP, questions, comments, and anything related.

Vhosts and URL

Postby whyzerman » 10. December 2009 11:33

I am using XAMPP for linux on CentOS and primarily use it as home web server. I have a domain at freedns e.g. "http://something.moo.com" and it worked perfectly. If I wanted to put something online to quickly publish I just put a folder with homepage (e.g.joomla) in htdocs:" http://something.moo.com/joomla/" and the browser showed the page in that folder. Yesterday I activated vhosts (I wanted to have more domains on one IP) and it works beautifully. But I realized that the old trick doesn't work anymore. If I put " http://something.moo.com/joomla/" in the browser it doesn't find it. Since I don't want to put more new subdomains in freedns (e.g. http://joomla.moo.com/) I wonder if there's any trick or a workaround to keep the old way and the vhosts working together.

And another question. Where can I set that entering an IP number in the browser wouldn't show the page. In other words I want my pages to be accessed only via domain name and not through IP. Is that a router setting or apache setting?

Any help would be greatly appreciated

Thanks, Mitja
whyzerman
 
Posts: 5
Joined: 10. December 2009 11:06

Re: Vhosts and URL

Postby Wiedmann » 10. December 2009 11:40

If I put " http://something.moo.com/joomla/" in the browser it doesn't find it.

You are having a VHost with ServerName "something.moo.com" and the htdocs dir as DocumentRoot?
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: Vhosts and URL

Postby whyzerman » 10. December 2009 12:15

Thanks for the quick reply. These are my active vhosts. For the last two I had to make a new subdomain. /phpbb3/ and /league/ after the domain name would be enough for me. Instead of making another subdomain.


#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.

<VirtualHost *:80>
DocumentRoot /opt/lampp/htdocs/site1
ServerName http://www.example.com
ServerAlias http://www.example.com
ErrorLog /opt/lampp/logs/www.example.com-error_log
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /opt/lampp/htdocs/site2
ServerName something.moo.com
ServerAlias something.moo.com
ErrorLog /opt/lampp/logs/something.moo.com-error_log
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /opt/lampp/htdocs/phpBB3
ServerName forum.moo.com
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /opt/lampp/htdocs/league
ServerName league.moo.com
</VirtualHost>
whyzerman
 
Posts: 5
Joined: 10. December 2009 11:06

Re: Vhosts and URL

Postby Wiedmann » 10. December 2009 12:26

Code: Select all
<VirtualHost *:80>
DocumentRoot /opt/lampp/htdocs/site2
ServerName something.moo.com
ServerAlias something.moo.com
ErrorLog /opt/lampp/logs/something.moo.com-error_log
</VirtualHost>

If I put " http://something.moo.com/joomla/" in the browser it doesn't find it.

You have a directory "/opt/lampp/htdocs/site2/joomla"?
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: Vhosts and URL

Postby whyzerman » 11. December 2009 00:27

Wiedmann wrote:
Code: Select all
<VirtualHost *:80>
DocumentRoot /opt/lampp/htdocs/site2
ServerName something.moo.com
ServerAlias something.moo.com
ErrorLog /opt/lampp/logs/something.moo.com-error_log
</VirtualHost>

If I put " http://something.moo.com/joomla/" in the browser it doesn't find it.

You have a directory "/opt/lampp/htdocs/site2/joomla"?


Sorry for the confusion here. I made joomla just as an example name of the folder in my first post, it could be named anything. (It doesn't actually exist in my vhosts)

When I posted my vhosts configuration, I changed joomla example name to site1 or site 2. Because like I said, when I had vhosts off, I had just put it this way in the browser (examples):

http://something.moo.com/site1/ .... and the homepage from /opt/lampp/site1/ folder opened
http://something.moo.com/site2/ .... and the homepage from /opt/lampp/site2/ folder opened

In this cases, htdocs folder contain two folders: site1 and site2 with different homepages.

In the current situation (vhosts on):
If I want to access site1, I have to define a proper path in virtual host (DocumentRoot) and own subdomain:
Code: Select all
DocumentRoot /opt/lampp/htdocs/site1
ServerName something.moo.com

If I want to access site2, I have to define a proper path in virtual host (DocumentRoot) and own subdomain:
Code: Select all
DocumentRoot /opt/lampp/htdocs/site2
ServerName somethingelse.moo.com


If I put a third folder named site3 in htdocs (e.g. for quick posting online and I don't want to bother with creating a new (sub)domain, but instead use one of the existing ones ) and put in browser like I used to: http://something.moo.com/site3/ that site cannot be found (I assume because it has no virtual host defined)

Is there a way to use the same subdomain (in our case http://something.moo.com) and set another virtual host that it would actually accept additional subfolder?

That below code obviously wouldn't work?

Code: Select all
<VirtualHost *:80>
DocumentRoot /opt/lampp/htdocs/site2
ServerName something.moo.com/site3/
ServerAlias something.moo.com
ErrorLog /opt/lampp/logs/something.moo.com-error_log
</VirtualHost>


I hope I didn't get everything even more confused and thanks again for the effort.
whyzerman
 
Posts: 5
Joined: 10. December 2009 11:06

Re: Vhosts and URL

Postby Wiedmann » 11. December 2009 00:48

In this cases, htdocs folder contain two folders: site1 and site2 with different homepages.

You need a VHost, whose DocumentRoot is this htdocs folder.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: Vhosts and URL

Postby whyzerman » 11. December 2009 10:04

Thanks it works perfectly now. :D

Code: Select all
<VirtualHost *:80>
DocumentRoot /opt/lampp/htdocs
ServerName something.moo.com (or any domain with "A" record to your IP)
</VirtualHost>


Does a number of vhosts affect the web server performance if the pages have minimal number of visitors?
whyzerman
 
Posts: 5
Joined: 10. December 2009 11:06


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 6 guests