简体   繁体   English

Nginx不提供JavaScript文件

[英]Nginx not serving javascript files

I'm setting up a Wordpress blog on nginx by following this guide: Installing Wordpress on EC2 我将按照以下指南在nginx上建立Wordpress博客: 在EC2上安装Wordpress

I've followed it step-by-step. 我已按部就班了。 The blog is up. 博客打开了。 But there's a problem. 但是有一个问题。 In the blog, there's no javascript. 在博客中,没有javascript。 The js is not served, either by nginx or php-fpm. ngs或php-fpm都不提供js。

Can someone please guide me. 有人可以指导我吗? I'm really stuck bad. 我真的很糟糕。 I don't know much of nginx or php either. 我也不了解nginx或php。 :( :(

From a quick glance at that tutorial you should be running this default.conf . 快速浏览该教程,您应该正在运行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. 这意味着如果找到Nginx或加载index.php并将其传递给URI和args,则Nginx返回一个文件。 The root directive means that it only looks for files under /var/www . root指令意味着它仅在/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 . 因此,如果您在/var/www/js有一个文件夹,其中有一个名为my.js的文件,则应该可以通过访问http://<your-domain>/js/my.js来加载它。

Where are you trying to serve these js files from. 您在哪里尝试提供这些js文件。 What's the exact full path to them? 通往他们的确切路径是什么? Comment below and I'll keep editing this answer till we can figure it out. 在下面发表评论,我将继续编辑此答案,直到我们弄清楚为止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM