Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between httpd.conf, virtual host in apache2, why none in ubuntu using sudo-apt-get install

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

like image 851
user798719 Avatar asked Mar 17 '13 22:03

user798719


People also ask

Is apache2 Conf the same as httpd conf?

Apache is configured by placing configuration directives, such as Listen and ServerName , into a configuration file, which will be read by the Apache executable during the startup. The default configuration file is called " httpd. conf " (or " apache2. conf ") in the directory " <APACHE_HOME>\conf ".

Where is httpd conf in Ubuntu apache2?

and for Debian/Ubuntu is: /etc/apache2/apache2. conf . as you are using ubuntu os so you should edit /etc/apache2/apache2. conf .

What is Apache virtual hosts?

The Apache HTTP server supports virtual hosts, meaning that it can respond to requests that are directed to multiple IP addresses or host names that correspond to the same host machine. You can configure each virtual host to provide different content and to behave differently.


1 Answers

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).

like image 158
rra Avatar answered Oct 05 '22 23:10

rra