首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >FastCGI + Wordpress + NGINX

FastCGI + Wordpress + NGINX
EN

Stack Overflow用户
提问于 2014-06-05 10:56:49
回答 1查看 502关注 0票数 0

嘿,我已经在nginxproxy服务器上安装了Fastcgi,站点正在打开,但是WordPress的管理面板没有打开/wp,我得到了错误:您要查找的页面是临时unavailable.Please,稍后再试一次。

这是我的conf文件:

nginx.conf

代码语言:javascript
复制
user nginx;

worker_processes 2;
worker_rlimit_nofile 1024;

pid /var/run/nginx.pid;

events {
    worker_connections 2048;

    use epoll;
}

http {
    add_header Cache-Control public;

    server_names_hash_max_size 4096;
    server_names_hash_bucket_size 2048;

    types_hash_bucket_size 64;
    types_hash_max_size 2048;

    client_header_buffer_size 2k;
    client_header_timeout 180s;
    client_body_timeout 180s;
    send_timeout 180s;
    client_max_body_size 20M;
    client_body_buffer_size 128k;

    sendfile        on;
    tcp_nopush      off;
    tcp_nodelay     on;
    server_tokens   off;    
    include '/etc/nginx/conf.d/*.conf';
}

custom.proxy.conf

代码语言:javascript
复制
    proxy_ignore_headers Expires Cache-Control;
    proxy_cache_use_stale error timeout invalid_header http_502;
    proxy_cache_bypass $cookie_session;
    proxy_no_cache $cookie_session;

    ## MR - increasing upload size to 64M (declare inside 'location /' not work
    client_max_body_size 64M;
    client_body_buffer_size 128k;

    proxy_connect_timeout 180s;
    proxy_send_timeout 180s;
    proxy_read_timeout 180s;
    #proxy_buffers 32 4k;
    proxy_buffers 8 128k;
    proxy_buffer_size 128k;

    ### MR -- change enable = @wp when using wordpress
    error_page 404 /404.html;

    location = /404.html {
        root '/usr/share/nginx/html';
    }

    error_page 500 502 503 504 /50x.html;

    location = /50x.html {
        root '/usr/share/nginx/html';
    }

    ### MR -- must be using nginx-special (including ngx_purge_cache)
    location ~ /purge(/.*) {
        ### MR -- just enough remove # below for enable
        #proxy_cache_purge pcache "$scheme://$host$1$request_method";
        allow 127.0.0.1;
        deny all;
    }
location ~* \.php$ {
    fastcgi_index   index.php;
    fastcgi_pass    127.0.0.1:9000;
    #fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
    include         fastcgi_params;
    fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
}
    location / {
        limit_conn addr 25;

        ## MR - no need try_files because permalink handle by apache
        #try_files $uri $uri/ /index.php;

        proxy_pass http://127.0.0.1:30080/;

        proxy_redirect off;

        ## MR - change $host to $domain importance for access via ip on exclusive ip domain but add X-Host still with $host
        proxy_set_header Host $domain;
        proxy_set_header X-Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-For $remote_addr;


        proxy_pass_header Set-Cookie;

        proxy_headers_hash_max_size 512;

        ### MR -- just enough remove # below for enable cache
        #proxy_cache pcache;
        proxy_cache_valid 10m;
        proxy_cache_valid 404 1m;

        proxy_cache_key "$scheme://$host$request_uri";

        proxy_cache_use_stale error timeout invalid_header
                              http_500 http_502 http_504 http_404;

        open_file_cache max=1024 inactive=600s;
        open_file_cache_valid 2000s;
        open_file_cache_min_uses 1;
        open_file_cache_errors on;
    }

    ### MR -- Enable this if not using nginx cache and not for wordpress
#    location ~* ^.+\.(jpe?g|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf|avi|mp3)$ {
 access_log        off;
    log_not_found     off;
    expires           360d;
#        root $rootdir;
#    }

    location ~ /\.ht {
        deny all;
    }

    if (-f $request_filename) {
        break;
    }

    if (-d $request_filename) {
        break;
    }

Fastcgi.conf

代码语言:javascript
复制
fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  HTTPS              $https if_not_empty;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;

有什么建议吗?提前感谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-06-06 14:06:32

rewrite /wp-admin$ $scheme://$host$uri/ permanent;之前添加关于error_page的部分之后添加location /purge/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24058362

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档