Report this

What is the reason for this report?

Attempting to host a website with HTML and CSS...

Posted on December 2, 2022

Hello!

I’ve been trying to figure this out all week and keep ending up the same solution. Maybe there’s a better way?

Anyways, I’m attempting to use my digital ocean server to host a website that has HTML and CSS. I have Nginx on my server and it is running and I have a website hosted. It turns out Nginx does not support CSS in any way or form.

How do I get around this? Or, is there something else I should be using outside of Nginx?

Thank you in advance!



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi @b54a07ce39b84b9987aec80a170775,

Nginx is a computer program that processes a server-side application, making bidirectional or unidirectional and synchronous or asynchronous connections with the client and generating or giving a response in any language or client-side application.

However, your CSS file is processed by your browser.

Check out this tutorial where explains how to create and configure a virtualhost for your new website.

How To Set Up Nginx Server Blocks (Virtual Hosts) on Ubuntu 16.04

Hope that helps,

Sergio Turpín

Hi @b54a07ce39b84b9987aec80a170775,

As explained by Sergio already, Nginx is not the cause of the CSS not displaying itself. Having said that, what you can add in your configuration file for your website is

 location ~* \.(js|jpg|png|css)$ {
    root /usr/share/nginx/html/;
  }

Of course change the path /usr/share/nginx/html/; to your actual website path.

Additionally, if you are finding Nginx difficult, you can always use Apache as an alternative:

https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-20-04

Thank you so much for the feedback!

How do I access the config file?

I’m also not opposed to Apache. It’s not necessarily Nginx where I believe the issue is. I’m really new and the amount of new “how to” Nginx content that is available is unreal. I can show you 100 videos on how to hook up a static html website and not one that shows how to host multiple websites on a single server.

Anyways, thank you again for your time.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.