From charlesreid1

When you install or use the default-installed apache on ubuntu, things can be a bit all-over-the-place. This page is intended to collect my notes on where everything is when you go this route.

Overview

htdocs

The main Apache site is located in /www/htdocs

I put things in /www/ if they need to be accessed by Apache (MediaWiki, Wordpress, Drupal, etc.)

Configuration Files

Normally, Apache is configured through the httpd.conf file. However, on Ubuntu, configuration files are more fragmented.

The main configuration file is located in /etc/apache2/apache2.conf. This contains the system's Apache configuration, and should probably not be modified directly.

The main configuration file pulls in other configuration files, such as /etc/apache2/ports.conf, which contains configuration directives related to which ports Apache uses.

There are also site-specific configuration files, detailed below.

Sites

Site settings contained in: /etc/apache2/sites-available/default

Site settings for sites currently running contained in: /etc/apache2/sites-enabled/*

The contents of the server's main website are contained in: /www/htdocs/

To add a new site, you'll need to add a new virtual host, by creating a new file in /etc/apache2/sites-available/newsite. It will contain a <VirtualHost> block that will indicate how to reach the new site and the directory containing the contents of the new site.

To enable the new virtual host, run:

sudo a2ensite newsite

To disable it, run:

sudo a2dissite newsite

Modules

Available modules contained in: /etc/apache2/modules-available

Modules can be enabled by running (e.g.): sudo a2enmod rewrite (which will enable the "rewrite" module.)

sudo a2enmod proxy_http

Starting Apache at Startup

Starting Apache at startup requires using the Ubuntu startup manager, upstart. This involves writing a configuration file that tells upstart how to start Apache.

The configuration file goes in /etc/init/apache.conf

The contents of this file are given below:

# see http://serverfault.com/questions/202787/how-to-start-apache-server-automatically
start on runlevel [2345]
stop on runlevel [!2345]
expect daemon
exec /usr/sbin/apache2ctl start
pre-stop exec /usr/sbin/apache2ctl stop