LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 01-13-2011, 02:34 PM   #1
wnkltd
LQ Newbie
 
Registered: Mar 2006
Posts: 4

Rep: Reputation: Disabled
Angry 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?
 
Old 01-13-2011, 08:41 PM   #2
Azmeen
Senior Member
 
Registered: May 2003
Location: Malaysia
Distribution: Slackware, LFS, CentOS
Posts: 1,307

Rep: Reputation: 46
Have you checked the ownership and permissions on the png file?
 
Old 01-13-2011, 09:37 PM   #3
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942
Quote:
Originally Posted by wnkltd View Post
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.
Check the output of command ls -laFZd ~user/ ~user/images/.
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.
Nominal Animal

Last edited by Nominal Animal; 03-21-2011 at 03:17 AM.
 
Old 01-14-2011, 07:17 PM   #4
wnkltd
LQ Newbie
 
Registered: Mar 2006
Posts: 4

Original Poster
Rep: Reputation: Disabled
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_ubject_r:user_home_dir_t:s0 /home/user/
drwxr-xr-x. user faculty unconfined_ubject_r:user_home_t:s0 /home/user/public_html/images/
drwxr-xr-x. user faculty unconfined_ubject_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
138.192.24.49 - - [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)
24.9.100.48 - - [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.

Last edited by wnkltd; 01-14-2011 at 07:30 PM. Reason: Added extra info
 
Old 01-14-2011, 08:22 PM   #5
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942
Quote:
Originally Posted by wnkltd View Post
The ownership and permissions on the file are set correctly.
Yes, I fully agree. It's also confirmed by the access log.

Quote:
Originally Posted by wnkltd View Post
Here is the output of the wget command from access_log
138.192.24.49 - - [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)
24.9.100.48 - - [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"
That indicates there was no error, and that the browser should have received the image properly.

I do believe your Apache is correctly configured, and that there is no problem at the server end.

Quote:
Originally Posted by wnkltd View Post
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.
Opera is notorious for its sticky cache; it does not seem to have a force-reload thingy either. Other browsers go thorough all caches to the originating server if you press Ctrl or Shift or Command key (depending on OS and browser) while reloading -- a "forced" reload. In Opera, sometimes you can click reload as much as you want, but it still will just show the cached version. (I believe this happens in Opera if the timestamp on the files has not changed.)

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,
Nominal Animal

Last edited by Nominal Animal; 03-21-2011 at 03:13 AM.
 
  


Reply

Tags
apache, png, server


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot see png images in firefox BCarey Slackware 11 04-26-2009 08:29 PM
Apache 2.2 issues with NFS mounts and displaying images etc. Linuxfrog Linux - Server 3 04-11-2008 01:48 AM
firefox and .png images. slackbat Slackware 9 12-02-2005 09:22 AM
apache not displaying images tlgates Linux - Networking 0 01-24-2005 03:06 PM
png images not served by apache ..??? gene_gEnie Linux - Software 2 05-10-2002 08:11 AM


All times are GMT -5. The time now is 03:34 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration