Computers And Industry

Apache Virtual Host Configuration File Example


The following shows an example virtual hosts configuration file. This file defines a website under apache that listens on port 80. It is a bare minimum configuration and should be used for development purposes only.

Under CentOS 7, this file is should be placed in the /etc/httpd/conf.d folder. Note too that the main apache server configuration file (httpd.conf) needs to be modified to include this folder.

The sample virtual host configuration file is shown below.


  ServerName  www.sirpenski.local
  DocumentRoot  "/var/www/sirpenski.local/public_html"
  ServerAlias sirpenski.local
  ErrorLog  "/var/www/sirpenski.local/_logs/error.log"
  CustomLog "/var/www/sirpenski.local/_logs/access.log" combined

  
      DirectoryIndex  index.php index.html
      Options   Indexes FollowSymLinks
      AllowOverride All
      Require all granted
  



Note 1. Within the Directory Tag, next to the Options key the keyword Indexes means that if no file names is specified, and there is no default file, then the contents of the folder will display. Normally, this is set to -Indexes to stop full directory listings.

Note 2. Within the Directory TAg, next to the AllowOverride key, the value is set to ALL. This allows .htaccess files to control access to the folder. If this is set to none, then the .htaccess file will have no effect on the folder. This is important!!

Open Source

Paul F. Sirpenski
Personal Open Source Directory Of Paul F. Sirpenski

ASP.NET Core
Open Source directory Of the Microsoft Asp.Net Core project.

Developed By Paul F. Sirpenski. Copyright 2021.