php - 在 Nginx 上安装 wordpress - Nginx 发送 install.php

标签 php wordpress nginx installation fastcgi

我正在尝试配置 Nginx 以服务于 wordpress 安装(和 rails 应用程序 - 但这不是问题所在)。

我有一个奇怪的问题:我设法让 PHP 正常工作(一个基本的 test.php 被正确解析),但是当我想安装 wordpress 时,Nginx 给我 install.php 文件- 我可以下载。

这是 Nginx 唯一执行此操作的文件:其他 wordpress 文件服务良好,并且需要更多时间重定向到 install.php。

我在 Gentoo 上。 我使用 spawn-fcgi,这里是我的 nginx.conf 下面。有关部分是第二个服务器(wp.domain.local):

    user nginx nginx;
    worker_processes 1;

    error_log /var/log/nginx/error_log info;

    events {
        worker_connections 1024;
        use epoll;
    }

    http {
        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        log_format main
            '$remote_addr - $remote_user [$time_local] '
            '"$request" $status $bytes_sent '
            '"$http_referer" "$http_user_agent" '
            '"$gzip_ratio"';

        client_header_timeout 10m;
        client_body_timeout 10m;
        send_timeout 10m;

        connection_pool_size 256;
        client_header_buffer_size 1k;
        large_client_header_buffers 4 2k;
        request_pool_size 4k;

        gzip on;
        gzip_min_length 1100;
        gzip_buffers 4 8k;
        gzip_types text/plain;

        output_buffers 1 32k;
        postpone_output 1460;

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;

        keepalive_timeout 75 20;

        ignore_invalid_headers on;

        index index.html;

        upstream rails_app {
            server unix:/tmp/.sock fail_timeout=0;
        }

        server {
            server_name domain.local www.domain.local;

            access_log /var/log/nginx/domain.local.access_log main;
            error_log /var/log/nginx/domain.local.error_log info;

            root /path/to/rails/app/public;

            try_files $uri/index.html $uri.html $uri @app;

            location @app {
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $http_host;
                proxy_redirect off;
                proxy_pass http://rails_app;
            }

            # Rails error pages
            error_page 500 502 503 504 /500.html;
            location = /500.html {
                root /path/to/rails/app/public;
            }
        }

        server {
            server_name wp.domain.local *.wp.domain.local;

            access_log /var/log/nginx/wp.domain.local.access_log main;
            error_log /var/log/nginx/wp.domain.local.error_log info;

            root /path/to/wordpress;

            try_files $uri $uri/ /index.php;

            index index.php index.html index.htm default.html default.htm;
            location ~ \.php$ {
                include /etc/nginx/fastcgi.conf;
                fastcgi_pass  127.0.0.1:65532;
                fastcgi_index index.php;
            }
        }

        server {
            server_name localhost www.localhost;

            access_log /var/log/nginx/localhost.access_log main;
            error_log /var/log/nginx/localhost.error_log info;

            root /var/www/localhost/htdocs;

            index index.php index.html index.htm default.html default.htm;
            location ~ \.php$ {
                include /etc/nginx/fastcgi.conf;
                fastcgi_pass  127.0.0.1:65532;
                fastcgi_index index.php;
            }
        }

    }

最佳答案

尝试将 try_files 指令更改为 try_files $uri $uri//index.php?$args; 以处理 WordPress 使用的查询字符串。

关于php - 在 Nginx 上安装 wordpress - Nginx 发送 install.php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8446168/

相关文章:

JavaScript hex2bin 实现

php - 删除 cookie

wordpress woocommerce 模板文件覆盖

magento - Nginx + PHP-FPM + Magento 的 FastCGI 缓存配置

php - 使用JWT auth缓存API请求

php - laravel 使用没有 Controller 的模型, "best practice"?

javascript - javascript 中的事件不起作用

php - nginx 上的 Laravel 显示 403,但我的路径是正确的

mysql - WordPress 安装在子文件夹中

javascript - Bootstrap Datepicker(避免文本输入或限制手动输入)