amarincolas
amarincolas

Reputation: 141

Load images outside apache directory

Well, I have a website in apache directory: /var/www/html. Previously I had all my web images in /var/www/html/media, so I used to put /media/imgX.jpgfor loading them. but now I need to put them in /mnt/imgs. For some reason, using this path does not work the same way as before.

I think it has something to do with permissions using files from outside apache directory but I am not sure about it. Any idea?

Upvotes: 1

Views: 1757

Answers (1)

Stefan
Stefan

Reputation: 12453

The easiest way to add directories to Apache httpd is to use the "alias" module:

Alias /images "/mnt/imgs"
<Directory "/mnt/imgs>
    Options Indexes
    AllowOverride All
    Require all granted
</Directory>

Once you have set up this, test it with: "yourdomain.com/images".

Of course:

  • The directory "/mnt/imgs" need the appropriate rights, so Apache Httpd can access it. Therefore you need to find out the group it runs with.
  • These files will be available to the public, if you dont secure them.
  • Once this is functional, remove the "indexes" line from the snippet above.

Upvotes: 1

Related Questions