1

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. :(

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Hi, I'm trying to serve js files from the following path: /var/www/wp-content/themes/mythemename/theme-content/js/main.js
There seems to be a problem with the premium theme I'm using. I've raised a ticket with them. Looks like their custom widget is breaking things. I'll update this if the issue gets solved.
So if you visit http://<YOUR-DOMAIN>/wp-content/themes/mythemename/theme-content/js/main.js` you see the contents of main.js?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.