代码之家  ›  专栏  ›  技术社区  ›  Brian Deterling

在与Rails应用程序相同的域上运行WordPress的最佳方法是什么?

  •  12
  • Brian Deterling  · 技术社区  · 16 年前

    我有一个标准的Rails应用程序,nginx和mongrel运行在 http://mydomain . 我需要在 http://mydomain.com/blog . 我的首选是用运行在同一个服务器或单独的框中的Apache来承载博客,但我不希望用户在URL中看到不同的服务器。这是可能的吗?如果不可能,你会推荐什么来实现这个目标?

    5 回复  |  直到 16 年前
        1
  •  5
  •   Patrick McKenzie    16 年前

    upstream myBlogVPS {
            server 127.0.0.2:80;  #fix me to point to your blog VPS
    }
    
     server {
        listen       80;
    
    
        #You'll have plenty of things for Rails compatibility here
    
        #Make sure you don't accidentally step on this with the Rails config!
    
        location /blog {
            proxy_pass         http://myBlogVPS;
            proxy_redirect     off;
    
            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        }
    

        2
  •  7
  •   community wiki 3 revs joelhardi    16 年前

    in the Nginx wiki

    server {
        listen       example.com:80;
        server_name  example.com;
        charset      utf-8;
        error_log    /www/example.com/log/error.log;
        access_log   /www/example.com/log/access.log  main;
        root         /www/example.com/htdocs;
    
        include /www/etc/nginx/fastcgi.conf;
        fastcgi_index index.php;
    
        # Send *.php to PHP FastCGI on :9001
        location ~ \.php$ {
            fastcgi_pass 127.0.0.1:9001;
        }
    
        # You could put another "location" section here to match some URLs and send
        # them to Rails. Or do it the opposite way and have "/blog/*" go to PHP
        # first and then everything else go to Rails. Whatever regexes you feel like
        # putting into "location" sections!
    
        location / {
            index index.html index.php;
            # URLs that don't exist go to WordPress /index.php PHP FastCGI
            if (!-e $request_filename) {
                rewrite ^.* /index.php break;
                fastcgi_pass 127.0.0.1:9001;
            }
    
        }
    }
    

    # joelhardi fastcgi.conf, see http://wiki.codemongers.com/NginxFcgiExample for source
    fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
    fastcgi_param  SERVER_SOFTWARE    nginx;
    
    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_FILENAME    $document_root$fastcgi_script_name;
    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  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;
    

        3
  •  1
  •   Jauder Ho    15 年前

        5
  •  0
  •   Ian P    16 年前