LNMP 跑了个 wordpress,页面 CSS 和图片展示不起来,后台 GET 图片出来个问号 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
sxchen2012
V2EX    NGINX

LNMP 跑了个 wordpress,页面 CSS 和图片展示不起来,后台 GET 图片出来个问号

  •  1
     
  •   sxchen2012 2018-01-29 01:38:50 +08:00 4010 次点击
    这是一个创建于 2891 天前的主题,其中的信息可能已经有所发展或是发生改变。

    不知道标题描述清楚没有 wordpress 页面现在丑的雅痞,CSS 和图片感觉加载不起来,就在浏览器里面去专门访问图片,拿到个一个问号。 后台用 curl 去 GET,跟浏览器情况一致。 是图片太大,buffer 太小,感觉跟 NGINX 配置有关系,萌新求指导?

    [root@host images]# pwd

    /opt/nginx/html/blog/wp-content/themes/twentyseventeen/assets/images [root@host images]# l total 536 -rwxrwxrwx 1 nginx nginx 117713 Nov 23 2016 coffee.jpg -rwxrwxrwx 1 nginx nginx 93540 Nov 23 2016 espresso.jpg -rwxrwxrwx 1 nginx nginx 114854 Nov 17 2016 header.jpg -rwxrwxrwx 1 nginx nginx 171858 Nov 23 2016 sandwich.jpg -rwxrwxrwx 1 nginx nginx 42656 Sep 25 09:49 svg-icons.svg

    [root@host ~]# curl -i -X GET http://104.225.150.251/wp-content/themes/twentyseventeen/assets/images/header.jpg

    HTTP/1.1 200 OK Server: nginx/1.12.2 Date: Sun, 28 Jan 2018 17:24:52 GMT Content-Type: text/html Transfer-Encoding: chunked Connection: keep-alive X-Powered-By: PHP/5.3.27

    ?[root@host ~]# l

    NGINX 配置

    worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; error_page 500 502 503 504 /50x.html; fastcgi_buffers 512 128k; location = /50x.html { root html; } location / { root html/blog; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } } }

    17 条回复    2018-01-29 23:23:13 +08:00
    norain
        1
    norain  
       2018-01-29 01:47:39 +08:00 via Android
    折腾什么,直接宝塔
    sxchen2012
        2
    sxchen2012  
    OP
       2018-01-29 01:51:09 +08:00
    不知道标题描述清楚没有
    wordpress 页面现在丑的雅痞,CSS 和图片感觉加载不起来,就在浏览器里面去专门访问图片,拿到个一个问号。
    后台用 curl 去 GET,跟浏览器情况一致。
    是图片太大,buffer 太小,感觉跟 NGINX 配置有关系,萌新求指导?

    [root@host images]# pwd
    <pre><code>/opt/nginx/html/blog/wp-content/themes/twentyseventeen/assets/images
    [root@host images]# l
    <pre><code>total 536
    -rwxrwxrwx 1 nginx nginx 117713 Nov 23 2016 coffee.jpg
    -rwxrwxrwx 1 nginx nginx 93540 Nov 23 2016 espresso.jpg
    -rwxrwxrwx 1 nginx nginx 114854 Nov 17 2016 header.jpg
    -rwxrwxrwx 1 nginx nginx 171858 Nov 23 2016 sandwich.jpg
    -rwxrwxrwx 1 nginx nginx 42656 Sep 25 09:49 svg-icons.svg</code></pre>

    [root@host ~]# curl -i -X GET http://104.225.150.251/wp-content/themes/twentyseventeen/assets/images/header.jpg
    <pre><code>HTTP/1.1 200 OK
    Server: nginx/1.12.2
    Date: Sun, 28 Jan 2018 17:24:52 GMT
    Content-Type: text/html
    Transfer-Encoding: chunked
    Connection: keep-alive
    X-Powered-By: PHP/5.3.27

    ?[root@host ~]# l</code></pre>

    NGINX 配置
    <pre><code>worker_processes 1;
    events {
    worker_connections 1024;
    }
    http {
    include mime.types;
    default_type application/octet-stream;
    sendfile on;
    keepalive_timeout 65;
    server {
    listen 80;
    server_name localhost;
    error_page 500 502 503 504 /50x.html;
    fastcgi_buffers 512 128k;
    location = /50x.html {
    root html;
    }
    location / {
    root html/blog;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    include fastcgi.conf;
    }
    }
    }</code></pre>
    sxchen2012
        3
    sxchen2012  
    OP
       2018-01-29 01:52:02 +08:00
    @norain 只是感觉很奇怪,想瞅瞅
    0ZXYDDu796nVCFxq
        4
    0ZXYDDu796nVCFxq  
       2018-01-29 02:13:19 +08:00 via iPhone
    把图片等静态资源扔给 PHP 处理
    fastcgi 不是这么用的
    mingl0280
        5
    mingl0280  
       2018-01-29 04:04:11 +08:00
    去 /var/log 看日志咯……
    precisi0nux
        6
    precisi0nux  
       2018-01-29 04:16:58 +08:00 via iPhone
    新手还是推荐宝塔之类的面板的,但是不要依赖宝塔,要去学它怎么写配置。
    schema
        7
    schema  
       2018-01-29 08:19:08 +08:00 via Android   2
    别听他们的什么宝塔,直接 oneinstack
    tan90
        8
    tan90  
       2018-01-29 08:50:06 +08:00
    不建议用面板吧!用起来感觉很怪,而且我一般都认为我自己都能写一个,还能做更好的管理优化,要这个东西来干嘛?日积月累的脚本,比这个强大多了,但是没有好看的包装,拿不出手!
    tan90
        9
    tan90  
       2018-01-29 08:57:19 +08:00
    歪了! 我之前也是无法访问部分图片,加上这段代码就可以了,这代码包含了防盗链的,就是第二行和下面的 IF 语句
    singer
        10
    singer  
       2018-01-29 08:58:58 +08:00 via iPhone
    lnmp.org ,包你满意。
    你还可以学一下他的配置
    0ZXYDDu796nVCFxq
        11
    0ZXYDDu796nVCFxq  
       2018-01-29 09:05:03 +08:00 via iPhone
    你们在开发、测试、生产环境都用面板吗?
    yingfengi
        12
    yingfengi  
       2018-01-29 09:13:47 +08:00 via Android   1
    @schema OneinStack 还可以
    zjsxwc
        13
    zjsxwc  
       2018-01-29 11:06:54 +08:00   1
    只是缺一行 nginx 代理 jpg css 这种静态资源的配置而已,

    楼主去 wp 官网撸个 nginx 配置不就好了

    https://codex.wordpress.org/Nginx#General_WordPress_rules
    hsie
        14
    hsie  
       2018-01-29 11:22:12 +08:00
    规则错了。
    zeo
        16
    zeo  
       2018-01-29 12:23:47 +08:00
    应该不是 LNMP 的锅,阿里云+LNMP 跑好几个 wordpress,都没有问题,除了开始的时候遇到不能更新
    sxchen2012
        17
    sxchen2012  
    OP
       2018-01-2923:23:13 +08:00
    感谢各位,按照 13 楼的建议,撸了个配置,已经 ok 了,多谢 @zjsxwc
    刚接触 Nginx,想都理解下
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     3352 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 28ms UTC 04:38 PVG 12:38 LAX 20:38 JFK 23:38
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86