LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Images not served by apache over a symbolic link folder (https://www.linuxquestions.org/questions/linux-server-73/images-not-served-by-apache-over-a-symbolic-link-folder-699659/)

fakeer 01-24-2009 05:15 PM

Images not served by apache over a symbolic link folder
 
a variation of the problem i'm facing has be mentioned before here (however without resolution):

http://www.linuxquestions.org/questi...ic+link+images

my setup involves a Centos 5 server and a Windows XP box with images

1. i mount the windows images directory e:\Pics on under /mnt/pics

2. on centos a vhost (www.mysite.org) is setup with the root as /var/www/web3/web

3. i created a symbolic link as
Code:

ln -s /mnt/pics /var/www/web3/web/Pics
4. in the vhost configuration the apache directives are setup to follow symbolic links
Code:

<Directory /var/www/web3/web>
    Options Indexes FollowSymLinks
 </Directory>

at this point if i go to
Code:

http://www.mysite.org/Pics
i can see the listing just fine and can see the directory of JPG and GIF files. however when i click on one i just get a broken image. the http response also seems fine and is 200.

there are no permission issues because on the windows share i can access html and txt files just fine. for e.g.
Code:

http://www.mysite.org/Pics/letter.txt
the problem is with serving the images like
Code:

http://www.mysite.org/Pics/foo.gif
. it might also be a problem with other times of media files but i haven't tried.

does this look like a mime issue to anyone? or is it just the way the mount was done. the question is why would it serve up non-images fine but fail while returning images..

fakeer 01-25-2009 01:16 AM

The Solution
 
with a bit more creative use of keywords i was able to reach this post (surprise, it was again back on linuxquestions.org)

https://www.linuxquestions.org/quest...mlinks-443537/

the problem is with serving all binary files of which i had gotten just a taste with the images not working. the fix therefore was to turn off apache's memory-mapping of files. in the systems that supports this it could form a rather efficient cache by itself. my system won't be serving massive amounts of content but any large scale system should investigate this setting more closely.

in /etc/httpd/conf/httpd.conf find the relevant sections as below and uncomment the lines:
Code:

#
# EnableMMAP: Control whether memory-mapping is used to deliver
# files (assuming that the underlying OS supports it).
# The default is on; turn this off if you serve from NFS-mounted
# filesystems.  On some systems, turning it off (regardless of
# filesystem) can improve performance; for details, please see
# http://httpd.apache.org/docs/2.2/mod/core.html#enablemmap
#
EnableMMAP off

#
# EnableSendfile: Control whether the sendfile kernel support is
# used to deliver files (assuming that the OS supports it).
# The default is on; turn this off if you serve from NFS-mounted
# filesystems.  Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#enablesendfile
#
EnableSendfile off

then a bounce
Code:

service httpd restart

to know more about why it does what it does you can look at the docs for these obscure attributes at http://httpd.apache.org/docs/2.2/mod...tml#enablemmap

Quote:

This directive controls whether the httpd may use memory-mapping if it needs to read the contents of a file during delivery. By default, when the handling of a request requires access to the data within a file -- for example, when delivering a server-parsed file using mod_include -- Apache memory-maps the file if the OS supports it.

This memory-mapping sometimes yields a performance improvement. But in some environments, it is better to disable the memory-mapping to prevent operational problems:

* On some multiprocessor systems, memory-mapping can reduce the performance of the httpd.
* With an NFS-mounted DocumentRoot, the httpd may crash due to a segmentation fault if a file is deleted or truncated while the httpd has it memory-mapped.

and there went my entire day . . .


All times are GMT -5. The time now is 02:17 AM.