19

I am trying to follow some guides about starting up apache2.2

I'm ubuntu 12.10

What is the httpd.conf file, and is it the same as a vhost file? Where is it located? I did a 'find' using the command line and it is not found. Does this mean that I have to create it? Or has this been deprecated in apache 2.2? I do not have Apache 2.4. The links that I've seen all seem to refer to this file.

http://httpd.apache.org/docs/2.2/invoking.html

Shows that apache is located at usr/local/apache2, but when I installed using the apt-get tool, it is not installed there. It's in /etc/apache2, and that kind of is throwing me off. Do I have the right directory?

I also have no httpd.conf, nor do I have a conf directory, but I do have a conf.d, but I'm just having a hard time orienting myself. I also keep seeing something like "make a new site" in tutorials, but I would request more background since I have no idea how to do that. Is it with a vhost? I can not find my vhost configuration.

Thank you!

well, as an update ,I have found a good source of information: https://help.ubuntu.com/12.10/serverguide/httpd.html

I would delete my question, but for anyone else:

Your virtual host file, on ubuntu 12.10, if you installed using sudo apt-get install apache2 is /etc/apache2/sites-available/default

It's not called virtual host, nor does it have a file extension.

Guys, this is very confusing for newbies. So much documentation asks you to find an httpd.conf file, yet doing a simple find / *.conf from the command line will give you nothing if you used sudo-apt-get install to install apache2. But if you had downloaded the .zip file from the Apache site, all of a sudden you get everything most tutorials talk about. This needs to be explained, clearly. Is there an equivalent httpd.conf file that's listed in /etc/apache2? I think it is actually called "default"?

Here are some very helpful links; I would recommend them over the official documentation for newbies. It may help orient you (like it did me), and then the docs may make more sense.

http://articles.slicehost.com/2010/5/19/installing-apache-on-ubuntu

http://articles.slicehost.com/2010/5/19/apache-configuration-files-on-ubuntu

6
  • It should be located in the bin/conf/extra folder
    – apomene
    Mar 17, 2013 at 22:12
  • I do not have a directory in the path /bin/conf/ nor do I have a directory in /etc/apache2/bin/
    – user798719
    Mar 17, 2013 at 22:25
  • Oh maybe you are thinking of windows? I am on ubuntu 12.10. Thanks though.
    – user798719
    Mar 17, 2013 at 22:31
  • Oh interesting. If I install the pre-compiled binaries I see the directories you are talking about. wow this is confusing to a newbie b/c if you use sudo apt-get install you're getting totally different directory structures. Why do they do this?
    – user798719
    Mar 17, 2013 at 22:39
  • An easy way to find files using terminal is to use the locate command, i.e locate httpd.conf, might be useful in future.
    – Aesir
    Aug 16, 2013 at 14:58

1 Answer 1

39

Here's some additional background, in case it's helpful. (This is covered by the document you link to, but it mixes description, rationale, and a bunch of other information about the default configuration.)

The Apache configuration system in both Debian and Ubuntu tries to set things up so that you don't have to edit the base httpd.conf. It sets a bunch of defaults that you hopefully don't have to touch. Instead, the extra configuration is broken into several directories of files, all of which are included from httpd.conf.

A lot (possibly most) Apache configurations have virtual hosts, often more than one. It's useful to have all the configuration for a specific virtual host (everything within a particular <VirtualHost> configuration block) in a separate file just for that virtual host. The Debian/Ubuntu configuration stores those files in the /etc/apache2/sites-available directory. The reason for the "available" part is that there is a system to easily enable and disable virtual hosts using the a2ensite and a2dissite commands, which create and remove symlinks in a parallel /etc/apache2/sites-enabled directory that the Apache configuration actually includes. You should never touch files in the sites-enabled directory normally; instead, edit or create them in sites-available and then use a2ensite and a2dissite to enable and disable specific virtual hosts.

To keep your configuration clean and maintainable, generally each configuration file in /etc/apache2/sites-enabled should contain only one <VirtualHost> block (or two if there is a port 80 and a port 443 configuration for the same host). Any global settings that are outside of any specific virtual host should not go into that directory, and should instead go into separate files in /etc/apache2/conf.d.

It's okay to start by editing the default virtual host, but as you get farther down the path of building your Apache configuration, I would recommend creating a new file in sites-available named for the actual virtual host you're configuring and just use default as a model (and then disable the default virtual host with a2dissite default).

1
  • 1
    #rra I would have voted up many times for this response. I am running Apache/2.4.7. And your "good practices" really helped me a lot to understand. Now my 2 cents. Apart from the a2ensite/a2dissite, a2enmod/a2dismod Apache incorporated a2enconf/a2disconf to enable/disable the configurations located at the folder suggested by you:/etc/apache2/conf.d Good move Apache! #rra, once more, THANKS!!! Mar 7, 2014 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.