The MU forums have moved to WordPress.org

Installation Success - Finally - Tips for NGINX installs (4 posts)

  1. pipstar
    Member
    Posted 14 years ago #

    (Sorry, this was initially posted in the standard wordpress forums...)

    Hey, I recently installed Wordpress MU on an NGINX webserver and after much trial and error, everything is working beautifully

    (This install for WPMU is hosted under a subdomain and will use a subdirectory structure for the blogs).

    Note: Initially I had to add in / to

    define('PATH_CURRENT_SITE', '/' );
    in wp-config.php to fix up the fatal error below:

    Could Not Find Blog!
    Searched for blog.domain.com in database name

    Then, my problems were with my nginx configuration.

    I played a lot with various rewrite options and debugged wordpress for several hours.

    In the end thanks to this blog entry I realised that I had setup my location ~ \.php$ { configuration was wrong.

    I needed this setup:

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ \.php$ {

    root /usr/share/wpmu;

    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    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 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;
    fastcgi_param SCRIPT_FILENAME /usr/share/blogpath$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;
    }

    And with that setup I found that the nginx rewrite rules in the Codex worked perfectly.

    Good luck getting WPMU installed

  2. pipstar
    Member
    Posted 14 years ago #

    And whoops - I spoke too soon. It appears that my secondary blogs are visible, but that if I try to do anything within the secondary blogs admin I either have problems with style sheets loading (eg http://blog.domain.com/blog2/wp-admin/)

    or a
    No input file specified. when i go to sublevels of the secondary blog's admin eg:
    http://blog.domain.com/blog2/wp-admin/index.php?page=myblogs

    I'm guessing that this may have to do with my rewrites in the nginx.conf... any ideas?

  3. pipstar
    Member
    Posted 14 years ago #

    And... It's sorted...

    |Make an addition to the php location as below:

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ \.php$ {

    root /usr/share/wpmu;
    rewrite ^/.*(/wp-admin/.*\.php)$ $1;
    fastcgi_pass 127.0.0.1:9000;

  4. cafespain
    Member
    Posted 14 years ago #

    No doubt you'll decide to install wp-supercache at some point so here are my settings - I got the majority of this from a couple of different places and merged them (can't remember the sites, but when I find them I'll post the urls):

    location ~* ^.+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$
                    {
                            root /path/to/public_html/;
                            rewrite ^/.*(/wp-.*/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 last;
                            rewrite ^.*/files/(.*(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ /wp-content/blogs.php?file=$1 last;
                            expires 30d;
                            break;
                    }
                    location / {
                            root   /path/to/public_html/;
                            index  index.html index.htm index.php;
    
                            if (-f $request_filename) {
                                    expires max;
                                    break;
                            }
                            if (-d $request_filename) {
                                    break;
                            }
    
                            set $supercache_file '';
                            set $supercache_uri $request_uri;
    
                            if ($request_method = POST) {
                                    set $supercache_uri '';
                            }
    
                            if ($query_string) {
                                    set $supercache_uri '';
                            }
    
                            if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) {
                                    set $supercache_uri '';
                            }
    
                            if ($supercache_uri ~ ^(.+)$) {
                                    set $supercache_file /wp-content/cache/supercache/$http_host/$1index.html;
                            }
    
                            if (-f $document_root$supercache_file) {
                                    rewrite ^(.*)$ $supercache_file break;
                            }
    
                            if (!-e $request_filename) {
                                    rewrite . /index.php last;
                            }
                    }

About this Topic

  • Started 14 years ago by pipstar
  • Latest reply from cafespain