I have written at length about how administering a Linux server is a nightmare. It does not matter how smart, experienced, or nerdy you are. Everyone who uses Linux bangs their head against a wall from time to time.

That is why I have developed a very strict policy for using Linux: keep it simple. I refuse Linux projects where “no one has ever done this before.” I refuse projects where people say, “Ususally this code runs on version 4, but I think we can make it run on the new version 5.” No, thanks. Been there, done that. You can’t pay me all the money in the world to do those projects. I have nightmares about those projects.

Instead, I have a new zen. A new solution to the Linux nightmare: keep it simple. Don’t be a hero. Don’t be a revolutionary. Be boring. Linux will never be a breeze – but if you just keep things simple, and drive in the center lane with everyone else, your torment will be limited.

Such is the case with configuring Apache 2.

I keep my Apache 2 configuration very simple. It’s as standard and simple as can be. My Apache 2 is configured to run virtualhosts – which means I have 1 IP address and 1 server that runs multiple websites. If you are running multiple websites on Apache, you are likely using virtualhosts too.

Under my setup, each website has its own virtualhost configuration file. When I add a new website to my Apache, I add a new virtualhost configuration file. When I remove a website from my Apache, I delete its virutalhost configuration file. 1 virtualhost configuration file = 1 website. See what I mean about keeping it simple?

To accomplish this, I have a “default” Apache2 virtualhost file. It lives at /etc/apache2/sites-available/default. Every time I set up a new website, I copy this file and change a few lines. It’s the virtualhost “template” upon which all of my websites run. I pieced it together from dozens of Apache blog posts and Stack Overflow answers.

What’s cool is how surprisingly simple it is. It will let you run any vanilla HTML/CSS/JS site, and most PHP sites like Wordpress and Drupal.

Feel free to take it and use it on your own Apache 2 server:

<VirtualHost *:80>
  ServerName domain.com
  ServerAlias www.domain.com
  ServerAdmin youraddress@gmail.com
  DocumentRoot /var/www/domain.com/

  <Directory /var/www/domain.com/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride FileInfo
    Order allow,deny
    allow from all
  </Directory>

  # Possible values: debug, info, notice, warn, error, crit,
  # alert, emerg.
  LogLevel warn
  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

The default Apache 2 virtualhost configuration file is much longer. It is full of crap that you don’t need unless you’re living in 1996 (like CGI script support). Most likely, this is the configuration file you are running if you use Apache 2. If so, you should replace it immediately. The default virtualhost settings may open your system to attackers, since features you do not know about are active, unconfigured, and online. That’s a dangerous trifecta.

If you would like to learn how to set up an actual domain with Apache, read my guide: How to set up a new virtualhost domain in Apache 2.