The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

CSS images not loading

Discussion in 'General Discussion' started by Maximus1332, May 6, 2010.

  1. Maximus1332

    Maximus1332 Registered

    Joined:
    May 6, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Hello Everyone!

    I have done some searching on these forums to see if someone had the same issue I had. Here is what happened. I moved my websites from a shared hosting plan to a new dedicated server that came with Cpanel. I have used it in the past and have also know a few things about linux I decided to get the unmanaged server. After dealing with moving the site from its cpanel shared hosting account to its new home we noticed that the CSS images won't load. We can get to the image directly but we can't when its called in a css background image. I have set the url to the absolute path (/home/USERNAME/public_html/images/bg1.jpg) and even left it how we have it on the old server (/images/bg1.jpg). I don't think it is permission related because I can get to the file directly via the web browswer (http://serverip/~USERNAME/images/bg1.jpg). We are using just the server IP for now due to us not wanting to move the site until we are sure everything will move over fine.

    Am I missing something here? I have recompiled Apache and PHP using EA a few times. Checked the PHP info on both servers and they match pretty closely. We are using suexec for the PHP stuff but the page is an HTML page (index.html).

    Thanks for your time.
     
    #1 Maximus1332, May 6, 2010
    Last edited by a moderator: May 6, 2010
  2. cPanelJamyn

    cPanelJamyn Social Engineer
    Staff Member

    Joined:
    Jan 29, 2009
    Messages:
    105
    Likes Received:
    2
    Trophy Points:
    0
    I don't recommend using your 'real' username on your server for privacy reasons, so I'm editing it out of your original message and my quote here.

    Hi,

    Using the full filesystem path (ie: /home/USERNAME/public_html/images/bg1.jpg) won't work; the webserver uses the documentroot (typically /home/USERNAME/public_html) as a baseline, so you'd only include paths after that when working with file URLs. So for example, if the full path to the file is /home/USERNAME/public_html/bunnies/orange/blue.jpg, you'd use "/bunnies/orange/bpue.jpg" as your file link.

    Without seeing the relevant CSS, I can't tell you what's wrong with it, as one of the two scenarios you described should work.
     
  3. Maximus1332

    Maximus1332 Registered

    Joined:
    May 6, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Jamyn,

    Thanks for your response. That wasn't the real username and not even close to it actually. I did that part on purpose so it was something beside username hehe. :)

    Below is the CSS code we are using. As I said either way we can't get the image to display no matter what we do in the css code. Only way for us to see the image is to go to the direct URL in the browser http://serverip/~username/images/bg1.jpg).

    Would this maybe have to do with us needing to compile apache with the option checked for Mime?

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Our Website Title Here</title>
    <style type="text/css">
    <!--
    body,td,th {
            color: #FFF;
    }
    body {
            background-color: #000;
            background-image: url(/images/bg1.jpg);
            background-repeat: no-repeat;
            background-position: center;
            text-align: center;
    }
    -->
    </style></head>
    
    
     
    #3 Maximus1332, May 6, 2010
    Last edited: May 6, 2010
  4. cPanelJamyn

    cPanelJamyn Social Engineer
    Staff Member

    Joined:
    Jan 29, 2009
    Messages:
    105
    Likes Received:
    2
    Trophy Points:
    0
    I don't think it's related to mime. I took your example and modified the URL for the background image so it pointed to the right place in my situation; otherwise I left it alone. I was able to get it to load properly. Is there anything in the apache or domain error log that looks useful?
     
  5. Maximus1332

    Maximus1332 Registered

    Joined:
    May 6, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Nothing there at all. Its weird that its not working for us. Could it be because we are using the server ip instead of the domain name? Maybe this is causing a loading issue (IE: can't use the path in the URL because of the ~usernamehere). Maybe Apache can't find the URL or something because of it not being the right "domain".

    I can give you a link to the site but the problem with that is it gives the realusername.
     
  6. Maximus1332

    Maximus1332 Registered

    Joined:
    May 6, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Jamyn,

    I want to thank you for your help. It was great to see some help.

    I am one of those guys that likes to tinker with things. So I went ahead and was playing around. I know that using the IP address and then ~username does impact the bandwidth for the site because there is not a way to monitor that. (IE: It really deals with the way HTTP works because you are not using a domain that apache can track but does know the username.) So in that respect I was wondering if it could not locate the URL in the CSS command. So I placed a period infront of the / and the image popped right up. Thanks for your help on this matter. Maybe we could get this in a knowledgebase for future users.
     
  7. cPanelJamyn

    cPanelJamyn Social Engineer
    Staff Member

    Joined:
    Jan 29, 2009
    Messages:
    105
    Likes Received:
    2
    Trophy Points:
    0
    Sounds good! Thanks for the update, and I'm glad to see it's now working for you. :)
     
  8. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    7
    Trophy Points:
    0
    Take a look at your file permissions and particular your folder permissions.

    Running SuPHP, FCGI, or phpSuExec (old) --

    You would need to have all folders set to "755" permissions and cannot have any folders setup with "777" permissions anywhere using these.

    For the files themselves, I would go with these permissions:

    600 PHP Scripts (*.php, *.php4, *.php5)
    400 PHP Scripts that DON'T want to be writable (rare)
    644 Non-Script Files (Images, Plain HTML, CSS, Templates, Etc)
    755 CGI Scripts (*.cgi, *.pl, *.py, *.pm, *.e)

    PS: With the PHP you mentioned, stay away from mod_userdir
    (Mod_Userdir: where you use the ~username in addresses)
     
Loading...

Share This Page