Search code examples
csslamp

External style sheets aren't styling my page


I have checked using Firebug, and I get the following message:

Reload the page to get source for: https://IP ADDRESS/var/www/css/style.css

There is no reload button in Firebug, and refreshing the page returns the same error. The address is correct. I changed it to test it and received a 404 error instead of the page refresh error. However, I also receive a 404 error if I try to access the address through my browser.

I am hosting this locally on a virtual machine running LAMP on Ubuntu Server and have enabled full permissions (for testing purposes only) without luck.

Note that everything styles fine if I load my local files.

Anyone have any suggestions?


Solution

  • If you're using Apache you're going to need to set it up to serve static files if you want to link to a CSS file. There's a bit of info here that might get you started:

    http://book.seaside.st/book/advanced/deployment/deployment-apache/serving-files

    The example configuration setting up a proxy described there looks like this:

    <VirtualHost *>
        # set server name
        ProxyPreserveHost On
        ServerName www.appname.com
    
        # configure static file serving
        DocumentRoot /srv/appname/web
        <Directory /srv/appname/web>
            Order deny,allow
            Allow from all
        </Directory>
    
        # rewrite incoming requests
        RewriteEngine On
        RewriteCond /srv/appname/web%{REQUEST_FILENAME} !-f
        RewriteRule ^/(.*)$ http://localhost:8080/appname/$1 [proxy,last]
    </VirtualHost>
    

    This sets the document root for the site to /srv/appname/web, allows access from every source and rewrites requests to be served from http://localhost:8080/appname/.