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/httpdListen 80Include conf.modules.d/*.confUser apacheGroup apacheServerAdmin root@localhostServerName localhost<Directory />AllowOverride noneRequire 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 FollowSymLinksAllowOverride NoneRequire all granted</Directory><IfModule dir_module>DirectoryIndex index.html</IfModule><Files .ht*>Require all denied</Files>ErrorLog logs/error_logLogLevel 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\     combinedLogFormat %h %l %u %t \%r\ %>s %b common<IfModule logio_module># You need to enable mod_logio.c to use %I and %OLogFormat %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 NoneOptions NoneRequire all granted</Directory><IfModule mime_module>TypesConfig /etc/mime.typesAddType application/x-compress .ZAddType application/x-gzip .gz .tgzAddType text/html .shtmlAddOutputFilter INCLUDES .shtml</IfModule>AddDefaultCharset UTF-8<IfModule mime_magic_module>MIMEMagicFile conf/magic</IfModule>EnableSendfile onIncludeOptional conf.d/*.confI 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.htmlln -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.comServerAlias *.my_host.comDocumentRoot /var/www/my_host<Directory /var/www/my_host>Options FollowSymLinks IndexesAllowOverride All</Directory>ErrorLog /var/www/my_host/error_logLogFormat %a %v %p %U %m %T common_new_formatCustomLog /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 httpdEverything 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 directiveI 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?
apache Virtual Host Configuration CentOS7
centos;symlink;apache httpd
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!)