PNG images not displaying from certain directories in Apache server
Just before anybody tells me to search the postings, I have and have not seen anything answering my problem.
I have a png file which I put into a user's directory: /~user/file.png
This displays OK. When placed in the user's images directory: /~user/images/file.png
the file does not display. If I put the file in the global images directory: /images/file.png
the file displays OK. Finally if I change the format of the file to a jpg and save it in the user's images directory: /~user/images/file.jpg
the file displays OK.
When I look at the Apache access_log and error_log files, there is not even an entry if the png image file is accessed from the user's images directory.
Has anyone seen this? Can anyone suggest where to look? Is this a problem with the png file or with the location?
Have you checked the ownership and permissions on the png file?
The mode should be drwx____-x for both. The security context (in the fifth column) should be the same for both directories; just ? if you don't use SELinux. I believe you have these correct, but please make sure.
Then check the output of command ls -laFZd ~user/file.png ~user/images/file.png .
The modes should be -rwx___r--. The security context should be the same for both files.
Could you please show the output?
It's possible your Apache is configured to do alias matching or URL rewriting in a way causing this problem. But let's check the permissions and the security context first. If you want to be really helpful, you could output the line in access_log or error_log that the load attempt produces -- there will be one, or else your browser is caching the result. If you use wget URL to load the image (append -O /dev/null if you don't want to save the image in current directory), it's easy to see in the logs (since the wget User-Agent is different). You can usually see the transformed file path in error_log, and that makes it easier to see what kind of transformation was done.
Thank you for responding and a possible resolution
First, thank you for responding to my post. Here are replies to the specific questions.
The ownership and permissions on the file are set correctly. They are the same as for the other files in the images directory
Nominal Animal: Thanks for the specific instructions to check permissions. Here is the output for ls -alFZd ~user ~user/public_html/images ~user/public_html/images/.
drwxr-xr-x. user faculty unconfined_u:object_r:user_home_dir_t:s0 /home/user/
drwxr-xr-x. user faculty unconfined_u:object_r:user_home_t:s0 /home/user/public_html/images/
drwxr-xr-x. user faculty unconfined_u:object_r:user_home_t:s0 /home/user/public_html/images/./
Also here is the ouptut for ls -alFZd ~user/public_html/file.png ~user/public_html/images/file.png ~user/public_html/images/file.jpg
-rw-r--r-- user faculty ? /home/user/public_html/images/file.jpg
-rw-r--r-- user faculty ? /home/user/public_html/images/file.png
-rw-r--r-- user faculty ? /home/user/public_html/file.png
I used to run SELINUX but have had it turned off for more than a year (SELINUX=disabled in /etc/selinux/config) which is probably why I get the security info for the directories.
Here is the output of the wget command from access_log
220.127.116.11 - - [14/Jan/2011:19:01:17 -0600] "GET /~user/images/file.png HTTP/1.0" 200 5510 "-" "Wget/1.11.4 Red Hat modified"
and from attempting to read it in a browser (where it does not get displayed)
18.104.22.168 - - [14/Jan/2011:19:02:30 -0600] "GET /~user/images/file.png HTTP/1.1" 200 5510 "-" "Opera/9.80 (Windows NT 6.1; U; en) Presto/2.7.62 Version/11.00"
There is no entry in error_log.
I hope all this information helps you help me resolve the issue.
BTW: changing the mode of file.png to be executable does not help.
Next: A possible resolution (with head hung in shame)
I probably should have checked this before the post. Though the file displays correctly in Paint Shop Pro (the utility I used to create it) it would not display after uploading to Linux server on which I am running Apache. I regenerated the file by saving the jpg file as a png and uploaded it. This time the file display correctly in a browser. It could be that the file was corrupted and so was not displaying. However, it still does not explain correct display when loaded from one directory but not from another.
I do believe your Apache is correctly configured, and that there is no problem at the server end.
If you loaded a badly corrupted version from one directory but not the other, it'd explain the behaviour with Opera.
This problem is not one to be ashamed of. Unless you know of it beforehand, it will catch you.
For example, I've created some SVG graphics to be used in web pages. They're embedded OBJECTs, with a PNG alternate image (for soft antialiasing), and a CSS workaround to make IE support the antialiased PNG correctly. It's as sticky as hot tar.
Fortunately, first force-reloading the web page, then opening the SVG directly in another window, force-reloading, and then going back and force-reloading the web page, "unsticks" and actually reloads everything it in all browsers -- except maybe Opera.
This procedure quickly becomes a reflex routine if you do web media development.
Hope this helps,
|All times are GMT -5. The time now is 11:04 PM.|