2

Probably a simple one, but this has me confused.

I'm running an EC2 instance which installs Apache 2.2 to the box once provisioned. I don't have access to a2enmod there but I need to change AllowOverride None to be AllowOverride FileInfo for the default /var/www/html directory where my app gets installed to.

This is configured in httpd.conf but I don't want to have to SSH into every new instance of my app and manually change that setting. I have a build script which copies the below file to /etc/httpd/conf.d/my-app.conf:

<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride FileInfo
    Order allow,deny
    Allow from all
</Directory>

This doesn't work though, I presume because the part in httpd.conf that loads files from conf.d/*.conf comes before the part where /var/www/html is defined (and AllowOverride is therefore set back to None).

How can I configure this so that setting is what I want (eg. FileInfo) without manually editing that file? I need this to be scriptable.

4
  • when you say it doesnt work, what is happening? what is the log output? would it be acceptable to you to edit httpd.conf via a script? Oct 19 '15 at 10:52
  • Sorry – just a standard 404 error in the browser when I hit a page that a .htaccess file should be rewriting (a Wordpress install where I'm removing index.php from the path). In the Apache logs I just get File does not exist: /var/www/html/category). I'd accept editing it via a script I guess but that feels a bit kludgy. Oct 19 '15 at 10:56
  • im assuming /etc/httpd/conf.d/my-app.conf where you putting your <Directory> container is a VHOST config? it it being loaded? - does the rewriting work if you temporarily change AllowOverride FileInfo to AllowOverride All ? Oct 19 '15 at 11:06
  • Ahh it looks like you're right – the contents of my-app.conf was literally the <Directory> part I posted in my question. When I wrapped this in a <VirtualHost *:80> tag it worked – my syntax was wrong. Thank you! Oct 19 '15 at 11:13
2

In order for your <Directory> container and the directives within it to take effect, it should be in a <VirtualHost> container that Apache matches when a request is made to your app.
Try re-checking your configuration and making sure that your config files are setup properly with the correct syntax

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.