After a Debian 9 server (Debian GNU/Linux 9 (stretch)) was installed, a web server with virtual host capability was needed.  At the first step, creating a conf file for the virtual host and enabling it and  then restarting the apache2 service were successful. However, the next step was not straightforward.  After files were copied to the root folder of the virtual host, error messages were persistent whenever which pages were visited.

The error message like” You don’t have permission to access <page name> on this server”. It was wired because the same virtual host conf file was fine on Ubuntu servers with old Linux version.

After googling the internet, the problem was nailed down. the new version of Apache2 increases the security of virtual hosts. One more directive is needed to make it work. In the virtual host conf file, need add “Require all granted”. A working version of an virtual host conf file is the following.

<VirtualHost *:80>
ServerName 192.168.0.200

# Indexs + Directory Root.
DirectoryIndex index.html index.php
DocumentRoot {your virtual host root data folder}

<Directory />
  Options FollowSymLinks
  AllowOverride None
</Directory>

<Directory "{your virtual host root data folder}">
  Options Indexes FollowSymLinks MultiViews
  AllowOverride None
  Order allow,deny
  Allow from all
  # new directive needed in Apache 2.4.3 and beyond
  Require all granted
</Directory>

# Logfiles
ErrorLog {your virtual host root folder}/logs/error.log
CustomLog {your virtual host root folder}/logs/access.log combined

</VirtualHost>
Share

Tags: , , , ,