Page 1 of 1

problem configuring virtual host

PostPosted: 21. January 2011 15:44
by argie01
Hello,

I need a little help configuring a site on Apache.
I'm moving a web from an apache server (not xampp) to an lampp-apache server, on linux.

The old apache server has a virtual host configuration. So, when someone point to www.mysite.com, he was redirected to /var/www/mysite/
But on my lampp-server I don't need to write a dns entry like that. All I just need is to change the document root only for this site. But I'd like to request this site writing something like http://ip-server/mysite/

So, in the new server with lampp I enabled http-vhost.conf on httpd.conf, and then I added the following lines inside http-vhost.conf

<VirtualHost *:9090>
DocumentRoot /opt/lampp/htdocs/mysite/
</VirtualHost>

That's because all I need is that when someone point to http://ip-server:9090 Apache redirects it to the site /opt/lampp/htdocs/mysite/
So, the results of this request would be something like http://ip-server:9090/mysite/index.php
But it doesn't works.
Besides it, I have other site configured in lampp-apache, and it doesn't works after I enabled http-vhost.conf on httpd.conf.
I've checked this config by doing telnet to the port 9090, and it doesn't respond.

Thank you for your help.

Re: problem configuring virtual host

PostPosted: 22. January 2011 02:54
by greno
Firewall.

Re: problem configuring virtual host

PostPosted: 22. January 2011 14:44
by argie01
I don't think so. Because the OS is an Ubuntu server 10.04 + gnome, and the firewall is not installed by default (and I didn't installed it).

Re: problem configuring virtual host

PostPosted: 22. January 2011 22:29
by greno
You must have Apache listening on 9090 and the firewall open on this port.

Re: problem configuring virtual host

PostPosted: 25. January 2011 12:50
by argie01
But how can I configure Apache to listen at the port 9090 (and also at the port 80)?
Because I suppose that the virtual host would configure Apache for this port....

Thank you.

Re: problem configuring virtual host

PostPosted: 25. January 2011 13:21
by Sharley
You may need to read the documentation to see what syntax a VirtualHost container requires to be effective:
http://httpd.apache.org/docs/2.2/vhosts/

Some good examples here:
http://httpd.apache.org/docs/2.2/vhosts/examples.html

Three essential components are, one to define whether you want to use an IP-Based vhost or a Name-Based vhost and two, to define a ServerName for your vhost so Apache can listen on port 80 using the defaults in the httpd.conf file and to be able to listen on port 9090 for a particular server name and three, to define the DocumentRoot for Apache to look in for the files to serve when requested.

The docs will help greatly in understanding what is required in your http-vhost.conf file.

Here is a very basic example, based on the info you have provided here, to enter into your httpd-vhosts.conf file:
Code: Select all
NameVirtualHost *:9090

<VirtualHost *:9090>
ServerName ip-server
DocumentRoot /opt/lampp/htdocs/mysite/
</VirtualHost>
http://ip-server:9090/ should then serve the index file it finds in the mysite directory.

Good luck and best wishes.

Re: problem configuring virtual host

PostPosted: 25. January 2011 18:18
by argie01
Thank you!

I fixed the problem just adding the line "Listen 9090" inside httpd.conf.