Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Configuring Virtual Host |
|
Author |
|
SusieStyle
Joined: 08 Oct 2006 Posts: 1
|
Posted: Sun 08 Oct '06 1:53 Post subject: Configuring Virtual Host |
|
|
Hey how is everyone?
I've got a question concerning how to configure virtual hosts by name.
The problem I'm having is it always goes to the default no matter which url I type.
I'm running Apache 2 which is very different. (No such thing has httpd.conf)
I followed the instructions i found here: http://www.linux.com/article.pl?sid=05/09/01/186204
here is the relevant part:
Quote: | recommend following this convention. It makes it much easier to manage when there are a large number of virtual hosts on a server. In the example above, you would create two files, /etc/apache2/sites-available/default and etc/apache2/sites-available/example.com. The /etc/apache2/sites-available/default file would look like this:
NameVirtualHost *
<VirtualHost *>
ServerName incorrect.com
DocumentRoot /var/www/html/default
</VirtualHost>
And the /etc/apache2/sites-available/example.com would look like this:
<VirtualHost *>
ServerName www.example.com
ServerAlias example.com
DocumentRoot /var/www/html/example.com/html
CustomLog logs/www.example.com-access_log common
</VirtualHost>
Then, create symlinks to the files in the /etc/apache2/sites-enabled directory with the ln -s command: ln -s /etc/apache2/sites-available/example.com /etc/apache2/sites-enabled/example.com.
Now that you have the virtual hosts configured, it's time to test. To start Apache 2, type /etc/init.d/apache2 start. Fire up a browser and head to www.example.com:8080. Obviously, this will only work assuming you have a correct virtual host entry for a hostname which has DNS pointing to your server rather than www.example.com. Alternatively, you can add an entry in the /etc/hosts file on the machine that you're browsing from to fool it into thinking it should be going to the IP address of your server.
If Apache 2 didn't start correctly, you may see errors when running /etc/init.d/apache2 start, and you will need to resolve some issues before you can proceed. Check the /var/log/apache2/error.log for details on any problems.
|
|
|
Back to top |
|
sb.net
Joined: 22 Sep 2006 Posts: 120 Location: USA
|
|
Back to top |
|
|
|
|
|
|