Nginx上的Wordpress不提供.css或.js或图片

时间:2017-06-26 13:03:56

标签: wordpress windows nginx

我正在尝试设置Nginx,以便我可以从中运行wordpress。 到目前为止我有两台PC都赢了10。 第一个(让我们称之为RED)有最新的Nginx安装,它带有php 7.x(zip)和mysql(最新安装,因为zip是如此破碎的windows)和phpMyAdmin(zip)。

当从localhost访问时,一切都在localhost上运行(mysql,php,css加载,js与wordpress一起工作),安装wordpress没有问题。

RED有一个最新的Wordpress安装,插件经过测试,可以在apache 2.4上运行

我已将RED设置为静态192.168.0.52并且它永远不会更改,以便我可以从其他笔记本电脑访问它(让我们称之为黑色)。

黑色笔记本电脑已设置为LAN卡为静态IP以及192.168.0.50

一旦我在chrome中输入http://192.168.0.52/,我就能看到php渲染的wordpress网站,唯一的问题是没有样式,没有js,也没有图像。

检查页面后,我看到所有.css,.js和图像都找不到404。这是因为图像的URL指向我的localhost(在黑色笔记本电脑上)看起来像这样

http://localhost/wp-content/plugins/quick-chat/js/jquery.c00kie.js?ver=4.13 

动态生成菜单上的链接也指向localhost。比如

http://localhost/myaccount/

如果我将localhost替换为RED PC的IP,那么我可以访问像这样的内容

 http://192.168.0.52/wp-content/plugins/quick-chat/js/jquery.c00kie.js?ver=4.13 

我在下面包含了访问日志,错误日志和Nginx配置,但我没有看到任何错误(也许是因为我不知道该寻找什么)。在互联网上搜索也没有给我任何结果(但我发现了许多其他的东西,如缓存和重写规则和权限和其他东西)

Nginx有什么问题,为什么它没有提供正确的链接?

这不应该是某种与网络相关的问题吗? 红色与Wi-Fi连接,黑色与rj45跳线连接到Dlink DWR-921,因为RED上的LAN端口无法正常工作。

访问日志粘贴箱https://pastebin.com/mWVGhRgs

127.0.0.1 - - [26/Jun/2017:14:19:31 +0200] "POST /wp-cron.php?doing_wp_cron=1498479570.4888958930969238281250 HTTP/1.1" 499 0 "-" "WordPress/4.8; http://localhost"
192.168.0.50 - - [26/Jun/2017:14:19:31 +0200] "GET / HTTP/1.1" 200 26934 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"

错误记录pastebin https://pastebin.com/4GFjyRjY

Nginx配置pastebin https://pastebin.com/DARtqUgs

worker_processes  4;
error_log  logs/error.log  debug;
pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    client_max_body_size 150M;

    server{
          listen  *:80 default_server;
          server_name  localhost;
          root C:/nginx/public_html/localhost/;

          location / {
            index  index.php index.html;
          }
           location ~ \.php$ {
           fastcgi_pass   127.0.0.1:9000;
           fastcgi_index  index.php;
           fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
           include        fastcgi_params;
           }  
    }

    server{

          listen 127.0.0.1:8088;
          server_name  www.karamba.dev;
          root C:/nginx/public_html/karamba.dev/;

          location / {
            index  index.php index.html;
          }
           location ~ \.php$ {
           fastcgi_pass   127.0.0.1:9000;
           fastcgi_index  index.php;
           fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
           include        fastcgi_params;
           }  
    }
}

0 个答案:

没有答案