My host machine is Windows 7 and guest machine is CentOS 7. I am a new to Apache and I am trying to create VirtualHost on CentOS7. I have read a lot of documentation and a lot of answers over StackCommunity (apache symlinks)virual host CentOS7 and on. Here is what I did. My /etc/httpd/conf/httpd.conf file configuration without adding any changes to it:

ServerRoot "/etc/httpd"
Listen 80
Include conf.modules.d/*.conf

User apache
Group apache

ServerAdmin root@localhost

ServerName localhost
<Directory />
AllowOverride none
Require all denied

DocumentRoot "/var/www/html"

<Directory "/var/www">
AllowOverride None
# Allow open access:
Require all granted

<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted

<IfModule dir_module>
DirectoryIndex index.html

<Files ".ht*">
Require all denied

ErrorLog "logs/error_log"

LogLevel warn

<IfModule log_config_module>
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""     combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common

<IfModule logio_module>
# You need to enable mod_logio.c to use %I and %O
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio

</IfModule>CustomLog "logs/access_log" combined

<IfModule alias_module>
 ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Require all granted

<IfModule mime_module>
TypesConfig /etc/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

AddDefaultCharset UTF-8

<IfModule mime_magic_module>
MIMEMagicFile conf/magic

EnableSendfile on
IncludeOptional conf.d/*.conf

I added index.html to /var/www/html with such content:

<title> The library </title>
<h2> Welcome to our library </h2>
<br /> <hr> <br />
<img width = "600" height = "400" src = "images/library.jpg">

Then I created symbol link for /var/www/html/index.html in /var/www/my_host/my_host.html

ln -s /var/www/html/index.html /var/www/html/my_host.html

Next step: I created my_host.conf in /etc/httpd/conf.d/ and allow Symlink:

vim /etc/httpd/conf.d/my_host.conf

<VirtualHost *:80>
ServerName www.my_host.com
ServerAlias *.my_host.com
DocumentRoot /var/www/my_host
<Directory "/var/www/my_host">
Options FollowSymLinks Indexes
AllowOverride All
ErrorLog /var/www/my_host/error_log
LogFormat "%a %v %p %U %m %T" common_new_format
CustomLog /var/www/my_host/custom_log common_new_format

Then I checked apache with this command: apachectl configtest and got output => Syntax OK. After all this steps I started httpd:

systemctl start httpd

Everything started perfectly.

But there was one problem I got in error_log of my virtual host:

AH01276: Cannot serve directory /var/www/my_host/: No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive

I understand that I can add DirectoryIndex my_host.html to my my_host.conf file but why my symlink my_host.html -> ../html/index.html did not work as I expected it to be? I thought it would be enough to allow FollowSymLinks in my /var/www/my_host/ directory and I did not need to point another DirectoryIndex ? My question is: Why does FollowSymLinks is not enough to point DirectoryIndex if I have already add symbol link to index.html?

1 Answer 1


I think you're reading too much into the symlink. httpd will not look if you have files that are symlinks to files that are called index.html in either case. It looks for a file named index.html in your DocumentRoot.

The FollowSymLinks is needed when such a file exists and is a symlink. (Imagine if, by accident or malice, a symlink to say, /etc/passwd or your private SSH key ended up in your DocumentRoot!)

  • But if I want to add symlink in my /var/www/ directory for another directory that is located in my home directory for example - can I use FollowSymLinks in this way?
    – fuser
    Jan 30, 2016 at 13:26
  • Yes, but the "relevant name" that will be part of the URL is the name of the symlink, not the name of its target. Jan 30, 2016 at 15:45
  • Oh!Now I understand!
    – fuser
    Jan 30, 2016 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.