[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

Where are the virtual hosts setup? not where I exspected

I've been tasked with adding a new domain to a server. I've done this before, usually I go to httpd.conf and add a new virtual host. My problem is that I can't figure out where the existing virtual hosts are configured. They aren't in /etc/apache/httpd.conf like I expected. I can't figure out where else the virtual host configuration would be. Any suggestions?

0
fworld
Asked:
fworld
1 Solution
 
mhequipitCommented:
Are you running apache on Windows or Linux?  If linux which version?
0
 
fworldAuthor Commented:
it is linux, Debian 2.6.8-2-686

httpd -v isn't working to get the version of apache though...
0
 
fworldAuthor Commented:
I didn't make this clear but there IS a /etc/apache/httpd.conf file. The existing sites on the server aren't configured in there though.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
mhequipitCommented:
This should take you all the way:

http://www.debian-administration.org/articles/18

Here is the text from that:

Hosting multiple sites with Apache

Posted by Steve on Thu 30 Sep 2004 at 18:50
Tags: apache, virtual domains

Apache is probably the most popular webserver for the Linux platform, and despite being very powerful and extensible it is very well documented. In spite of this documentation many people seem to struggle with hosting multiple sites with Apache.

There are two ways to host multiple sites with one Apache instance, and both are very simple to setup. You have the choice of using Name based virtual hosts, or IP based virtual hosts.

In most common situations you will use Name based virtual hosts, this only requires that all the sites you wish to host point to the IP address of your Apache server.

To start with you'll need to install the apache server itself. On a Debian system you will install software via the apt-get system, so as root you need to run the following commands apt-get update and apt-get install apache.

Once this has been done you will find you have Apache installed, and it's default configuration is included inside the directory /etc/apache, by default this will be setup to serve the files that are contained in the directory /var/www.

To enable multiple host support you must add, or uncomment, the following line:


NameVirtualHost *

This sets up Apache to accept the hosts.

Once this is done you need to create the directories to contain your sites, personally I use /home/www/name.of.site.org.

Assuming that you wish to host two sites you should create two directories:


root@skx:# mkdir -p /home/www/www.foo.com
root@skx:# mkdir -p /home/www/www.foo.com/htdocs
root@skx:# mkdir -p /home/www/www.foo.com/logs
root@skx:# mkdir -p /home/www/www.foo.com/cgi-bin
root@skx:# mkdir -p /home/www/www.bar.com/
root@skx:# mkdir -p /home/www/www.bar.com/htdocs
root@skx:# mkdir -p /home/www/www.bar.com/logs
root@skx:# mkdir -p /home/www/www.bar.com/cgi-bin

This gives you the directories to place your content inside htdocs, a directory for the CGI scripts, if you need them, and a directory to contain the logfiles for that host.

The next step is to add the configuration for each site, this can be done by adding the following settings to the default configuration file, /etc/apache/httpd.conf:


<VirtualHost *>
        # Basic setup
        ServerAdmin webmaster@foo.com
        ServerName www.foo.com
        DocumentRoot /home/www/www.foo.com/htdocs/


      # HTML documents, with indexing.
        <Directory />
        Options +Includes
        </Directory>

        # CGI Handling
        ScriptAlias /cgi-bin/ /home/www/www.foo.com/cgi-bin/
        <Location /cgi-bin>
                Options +ExecCGI
        </Location>

        # Logfiles
        ErrorLog  /home/www/www.foo.com/logs/error.log
        CustomLog /home/www/www.foo.com/logs/access.log combined
</VirtualHost>

<VirtualHost *>
        # Basic setup
        ServerAdmin webmaster@bar.com
        ServerName www.bar.com

        DocumentRoot /home/www/www.bar.com/htdocs/

      # HTML documents, with indexing.
        <Directory />
        Options +Includes
        </Directory>

        # CGI Handling
        ScriptAlias /cgi-bin/ /home/www/www.bar.com/cgi-bin/
        <Location /cgi-bin>
                Options +ExecCGI
        </Location>

        # Logfiles
        ErrorLog  /home/www/www.bar.com/logs/error.log
        CustomLog /home/www/www.bar.com/logs/access.log combined
</VirtualHost>

This sets up two sites, which have their docements and logfiles contained beneath /home/www/www.nameofsite.com. You can adjust the paths if you wish to keep the files elsewhere.

Before attempting to restart the server you should run a quick test to make sure that the configuration file /etc/apache/httpd.conf doesn't contain any errors. To do that you can run:


root@skx:/etc/apache# apachectl  configtest
Syntax OK
root@skx:/etc/apache#

Any errors should be highlighted, but in this case we see that our syntax is OK, so we can restart apache with:


root@skx:/etc/apache# /etc/init.d/apache reload
Reloading apache configuration.
root@skx:/etc/apache#

0
 
svsCommented:
> They aren't in /etc/apache/httpd.conf like I expected.

There must be more configuration files then -- look for an 'include' statement in httpd.conf.
0
 
karlwilburCommented:
Debian right?

check:
 /etc/httpd/sites-enabled/*
or
 /etc/apache/sites-enabled/*
or
 /etc/apache2/sites-enabled/*
0
 
theevilwormCommented:
run 'apache2 -S'. You don't have to be root to do so. It will give you all configured virtual hosts and the config files they are configured in. Also tests your configuration.
0
 
alextesiCommented:
I think that you are looking for configuration file of hosts.

if so, you can find the configuration file on apache2 under
/etc/apache2/sites-available
/etc/apache2/sites-enabled
in this two folder you can find rispectly the available configuration file of hosts and the Enabled configuration file of hosts.

The folder is populated with 1 file for each host that you configure in your apache.

Apache2 import any file that can be found in /etc/apache2/sites-enabled directory.

If you need to disable an host you can move the configuration file from sites-enabled folder to site-available folder, and viceversa for enable an host, making so you doesn't loose you configuration.

Make me know if the information is correct for you, and if you need other information.
Alessandro

0
 
mhequipitCommented:
Is this working now?
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Tackle projects and never again get stuck behind a technical roadblock.
Join Now