dsrruefh12970 2013-11-17 20:48
浏览 40

try_file没有使用fastcgi

I am running Wordpress through nginx and php-fpm. When a file that exists is requested, it works fine but when try_pass attempts to rewrite the URL to index.php, the browser just downloads the source of the PHP file. How can I get try_files to pass index.php to fastcgi?

Here is my nginx config

server {
        listen 80;
        listen [::]:80;

        root /home/gausie/mywebsite.com/;
        index index.php;

        server_name mywebsite.com;

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }

        location / {
                try_files $uri $uri/ /index.php?$args;
        }

        location ~* \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }

}

I've basically borrowed this from the nginx wiki so I can't see why it doesn't work!

  • 写回答

1条回答 默认 最新

  • douzhi6365 2013-11-17 22:27
    关注

    So... with no changes to the file at all it's fixed itself after just waiting.

    I'd appreciate if anyone knows why it took so long to work though...

    评论

报告相同问题?

悬赏问题

  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站