Hi guys,
I’m configuring a droplet to host multiple Wordpress sites.
I bought a droplet with Ubuntu 14.04.
Then I followed this tutorial : https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-14-04
Then this one : https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-14-04
Finally : https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-nginx-on-ubuntu-14-04
When I visit my website, everything seems to work except the CSS.
Here is the output of my Google Chrome’s console :
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://162.243.30.53/wp-content/themes/twentyfourteen/genericons/genericons.css/?ver=3.0.2". 162.243.30.53/:23
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://162.243.30.53/wp-content/themes/twentyfourteen/style.css/?ver=3.9.2". 162.243.30.53/:24
Resource interpreted as Script but transferred with MIME type text/html: "http://162.243.30.53/wp-includes/js/jquery/jquery.js/?ver=1.11.0". 162.243.30.53/:28
Uncaught SyntaxError: Unexpected token < 162.243.30.53/:1
Resource interpreted as Script but transferred with MIME type text/html: "http://162.243.30.53/wp-includes/js/jquery/jquery-migrate.min.js/?ver=1.2.1". 162.243.30.53/:29
Uncaught SyntaxError: Unexpected token < 162.243.30.53/:1
Resource interpreted as Script but transferred with MIME type text/html: "http://162.243.30.53/wp-content/themes/twentyfourteen/js/functions.js/?ver=20140319". 162.243.30.53/:136
Uncaught SyntaxError: Unexpected token < 162.243.30.53/:1
I found on Google that the problem must come from the http headers or something like that and I found somewhere (StackOverFlow I think) that I should add
include /etc/nginx/mime.types;
to my location / { … } block.
Here’s the result :
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/lesmauvaisgarcons.ca/html;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name XXX.XXX.XX.XX;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
include /etc/nginx/mime.types;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
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.
This is a pretty old thread by now, but I just got a similar issue.
From this example it would appear that you should
include mime.type
in the html section and not the location section.Hello,
Did solve your problem Antoine? I’m currently experiencing the same situation and have not clue what is going on, I already add include /etc/nginx/mime.types; but with no luck.
The only difference is I’m using nginx as a proxy behind it is apache.
Thanks,
Aldrin
Did you find any solution Antoine and Ines, ? I have the exact same issue and have no clue where it’s coming from
Hi,
I have a similar problem with 4 CSS stylesheets: I’m getting the following errors in the console for my website:
It’s most likely linked to an nginx config issue and was wondering if the solution you presented would work in my case. Here is my nginx file (/etc/nginx/sites-available/webmill):
I was wondering if I should have a new location section in the server setup (just like Antoine posted)? I created the config file above exactly as it was in this guide (https://www.digitalocean.com/community/tutorials/how-to-deploy-a-meteor-js-application-on-ubuntu-14-04-with-nginx) but I figured I could make ``` root /usr/share/nginx/html; # root is irrelevant index index.html index.htm; # this is also irrelevant
Andrew is right, the problem is with
try_files
. Change it to:The
$uri
variable is not required.It looks like you might have some sort of an issue with
try_files
Note that the url is:http://162.243.30.53/wp-content/themes/twentyfourteen/genericons/genericons.css/?ver=3.0.2
That is displaying html. If you go to:
http://162.243.30.53/wp-content/themes/twentyfourteen/genericons/genericons.css
without the
?ver=3.0.2
you get the actual CSS file.