0

0 down vote favorite I have an EFS file system mounted to multiple EC2 instances. I am trying to change apache config file. I don't want my index.html to be on the EC2 instance hard drive. Instead I want to move it to a directory in my EFS so I tried to modify the httpd.conf as the following :

#<Directory "/var/www"> This is the original location on EC2 instance
<Directory "/home/ec2-user/efs"> my new location on EFS
AllowOverride None
# Allow open access:
Require all granted
</Directory>
#<Directory "/var/www/html"> This is the original location on EC2 instance 
<Directory "/home/ec2-user/efs/files"> my new location on EFS
 #
  Possible values for the Options directive are "None", "All",
 # or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
AllowOverride None

#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
   DirectoryIndex index.php   modified file
</IfModule>

The only modifications I did are in the <<"Directory">> element where I changed the path to the EFS file system. After that I restart my apache server, but I receive the following error when loading my webpage "You don't have permission to access / on this server". Any help would be appreciated

Ahmed
  • 103
  • 4
  • 2
    Please don't [cross-post the same question](https://stackoverflow.com/questions/49766764/modifying-httpd-conf-file-apache-aws-ec2) over multiple sites. If you posted a question and decide that it was on the wrong SE site, either flag it for migration or delete it outright before posting it elsewhere. – HBruijn Apr 11 '18 at 09:43
  • @HBruijn i deleted it from stalkoverflow – Ahmed Apr 11 '18 at 09:46
  • If you want to change where content is served from you usually need to change the `DocumentRoot` – HBruijn Apr 11 '18 at 09:46
  • @HBruijn sorry I change the DocumentRoot but I still get 403 error. – Ahmed Apr 11 '18 at 09:50
  • As a server admin you have more tools at your disposal than normal visitors of your site and and after seeing an error in your webbrowser (which is typically not very informative by design) you should look at the (error) logs of your server, which usually will contain more useful and descriptive diagnostic errors. – HBruijn Apr 11 '18 at 09:52
  • When pointing `DocumentRoot` to an unusual place, be sure you have SELinux sorted out. – Ondřej Xicht Světlík Apr 12 '18 at 05:34
  • @OndřejXichtSvětlík sorry can you explain more what do you mean by SELinux sorted out. Can you elaborate more – Ahmed Apr 12 '18 at 05:35
  • @OndřejXichtSvětlík I checked my error_logs and here what I get search permissions are missing on a component of the path. Do you know How can I enable search permission for current path – Ahmed Apr 12 '18 at 05:51
  • There are just too many possibilities. Even missing search permissions may be caused by SELinux, try disbling it `setenforce 0`, if it doesn't work, try to check that the user under which your httpd is running, can enter the directory specified in `DirectoryRoot`. That's the search permission, if you don't have it, you cannot enter the directory. It's the `x` part of the permissions. And to whom you give the permission depends on who owns the directory. See https://askubuntu.com/questions/451922/apache-access-denied-because-search-permissions-are-missing – Ondřej Xicht Světlík Apr 13 '18 at 10:55

0 Answers0