Search code examples
cssamazon-web-servicesamazon-ec2webserver

Is it possible to have css in an ec2 instance


Using AWS I created an EC2 instance because I wanted to be able to execute php code. When I put my client side code in the /var/www/html folder, the html code comes up fine when I go to the public DNS. The css is not executed though. These are my permissions for my css file

-rw-r--r-- 1 ubuntu ubuntu 4236 Apr 4 00:08 home.css

and this is the head tab in my html

<head>
    <link rel="stylesheet" href="../css/home.css"></link>      
    <meta charset="utf-8">
</head>

This link says I can use something called an S3 browser for my css, but does this mean I can't use an EC2 instance? Also from what I've look up about S3, it's a windows application and I'm using MACOS. It also looks like s3 is only for simple static web pages.


Solution

  • It looks like the location of your CSS is incorrect. Assuming the HTML page is located at /var/www/html/index.html. Try changing the location of your css to /css/home.css

    <head>
       <link rel="stylesheet" href="/css/home.css"></link>      
       <meta charset="utf-8">
    </head>