Share this page:

Apache Basics

Install Apache

Apache can be installed from repositories of most Linux distributions.  On Debian based versions of Linux, use this command to install Apache:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install apache2

On Fedora:

sudo yum update
sudo yum install apache2

By default Apache uses the /var/www directory to store content.  Once you have installed Apache, a sample HTML file will be stored in /var/www/index.html.

Apache configuration files

Apache's configuration files are stored in /etc/apache2.  The main configuration is apache2.conf, which contains global timeout and keepalive settings.

Apache2.conf contains settings for the number of threads and processes that Apache uses to reply to incoming connections.  These options are useful for tuning Apache's performance.

Virtual hosts

A single installation of Apache can contain multiple virtual hosts.  Each virtual host is like a virtual instance of Apache with its own configuration and domain name.

Virtual hosts are stored in files in /etc/apache2/sites-available.  Each virtual host usually has its own file.  In order to enable a virtual host file, the a2ensite command must be used to create a link to the virtual host file in /etc/apache2/sites-enabled.


Apache modules can be enabled and disabled using the a2enmod and a2dismod commands. The a2enmod command creates a link from /etc/apache2/mods-available to /etc/apache2/mods-enabled.  Some modules have configuration files that can be found in /etc/apache2/mods-available.


Apache's log files are stored in /var/logs/apache2/.  Every request that Apache serves successfully is recorded in a file named access.log.  Information about errors is stored in /var/logs/apache2/error.log.

Apache's logs are a great source of information if you're debugging problems with your site.