LittleLebowski
LittleLebowski

Reputation: 7941

Nginx not serving javascript files

I'm setting up a Wordpress blog on nginx by following this guide: Installing Wordpress on EC2

I've followed it step-by-step. The blog is up. But there's a problem. In the blog, there's no javascript. The js is not served, either by nginx or php-fpm.

Can someone please guide me. I'm really stuck bad. I don't know much of nginx or php either. :(

Upvotes: 1

Views: 3832

Answers (1)

aychedee
aychedee

Reputation: 25569

From a quick glance at that tutorial you should be running this default.conf.

The relevant lines for serving static files are these ones:

root /var/www/;

and

location / {
        # This is cool because no php is touched for static content
                try_files $uri $uri/ /index.php?q=$uri&$args;
}

This means that Nginx returns a file if it is found OR loads index.php, passing it the URI and args. The root directive means that it only looks for files under /var/www. So if you have a folder at /var/www/js with a file inside it called my.js you should be able to load it by visiting http://<your-domain>/js/my.js.

Where are you trying to serve these js files from. What's the exact full path to them? Comment below and I'll keep editing this answer till we can figure it out.

Upvotes: 1

Related Questions