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
</Directory>
DocumentRoot "/var/www/html"
<Directory "/var/www">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
<Files ".ht*">
Require all denied
</Files>
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>
<IfModule alias_module>
 ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>
<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
<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
</IfModule>
AddDefaultCharset UTF-8
<IfModule mime_magic_module>
MIMEMagicFile conf/magic
</IfModule>
EnableSendfile on
IncludeOptional conf.d/*.conf
I added index.html to /var/www/html with such content:
<html>
<title> The library </title>
<body>
<h2> Welcome to our library </h2>
<br /> <hr> <br />
<img width = "600" height = "400" src = "images/library.jpg">
<body/>
</html>
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
</Directory>
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
</VirtualHost>
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?


