C4f1151075b447779af31e99d6cf70e2c6eb47ac
By:
newbie

Wordpress update error

March 28, 2017 568 views
WordPress LEMP Ubuntu 16.04

Hi,
today i got an error when i went to update my wordpress on to the latest version. its a sub-directory multi-site setup by the way.

when i click on update, after some time i get the following error on browser

mysite.com is currently unable to handle this request.
HTTP ERROR 500

and this is what i got from error log

user@mysite:~$ sudo tail -50 /var/log/nginx/error.log
2017/03/28 09:52:34 [error] 3559#3559: *2 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Call to undefined function get_user_locale() in /var/www/html/wp-admin/about.php:22
Stack trace:
#0 /var/www/html/wp-admin/network/about.php(13): require()
#1 {main}
thrown in /var/www/html/wp-admin/about.php on line 22" while reading response header from upstream, client: 192.205.134.114, server: mysite.com, request: "GET /wp-admin/network/about.php?updated HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "mysite.com", referrer: "http://mysite.com/wp-admin/network/update-core.php?action=do-core-upgrade"

but when i again access to wp-admin i found the wordpress is updated. but i am worried that i got a broken update and that might occur issues in future.
anyone got any idea whats could be the reason?

this is what i got inside location php by the way

        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.0-fpm.sock;
                include fastcgi_params;
                fastcgi_param REQUEST_METHOD $request_method;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_cache MYAPP;
                fastcgi_cache_valid 200 60m;
                fastcgi_cache_bypass $no_cache;
                fastcgi_no_cache $no_cache;
        }

thanks in advance.

1 comment
  • i just noticed another thing,
    the site, which is installed under sub-directory, fasctcgi is caching the wp-admin area for that site.

    this is my cache ignore settings inside server block. do i have to add anything else for sub-directory multi-site?

            #Cache everything by default
           set $no_cache 0;
    
            #Don't cache POST requests
           if ($request_method = POST) {
                   set $no_cache 1;
           }
    
            #Don't cache if the URL contains a query string
           if ($query_string != "") {
                   set $no_cache 1;
           }
    
            #Don't cache the following URLs
           if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
                   set $no_cache 1;
           }
    
            #Don't cache if there is a cookie called PHPSESSID
           if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
                   set $no_cache 1;
           }```
    
2 Answers

Seems like it actually updated, since the error comes from the about.php?updated page, which is the "welcome to the new version".
Something went wrong, but that could be several things involving cache, like you've already pointed out. Besides FastCGI cache, there's also PHP opcache. And if you're running memcached/Redis, then that might mess up something.
EDIT: What version did you upgrade from and to?

  • i updated to the latest version 4.7.3 and it was 4.7.1 i believe.

    i think everything is causing from FastCGI. because, any changes i make in the second site is not applying, but it works when i disable FastCGI. but no problem with the main site even with FastCGI.
    so what should i look in to now?

  • @hansen
    i just find out everything is from FastCGI. my site acts strangely when FastCGI is turned on. seems all the pages inside wp-admin area are also being cached in fastCGI. i restored my droplet from earlier point, disabled FastCGI and updated wordpress without any issue. also all strange things are also gone when i disabled FastCGI.

    could you tell me where i have done wrong setting up FastCGI?

    Here is my FastCGI setup just like described in DO tutorial

    fastcgi_cache_path /var/run/cache levels=1:2 keys_zone=MYAPP:100m inactive=60m;
    fastcgi_cache_key "$scheme$request_method$host$request_uri";
    add_header X-Cache $upstream_cache_status;
    fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
    
            #Cache everything by default
           set $no_cache 0;
    
            #Don't cache POST requests
           if ($request_method = POST) {
                   set $no_cache 1;
           }
    
            #Don't cache if the URL contains a query string
           if ($query_string != "") {
                   set $no_cache 1;
           }
    
            #Don't cache the following URLs
           if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
                   set $no_cache 1;
           }
    
            #Don't cache if there is a cookie called PHPSESSID
           if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
                   set $no_cache 1;
           }
    
            location / {
                    try_files $uri $uri/ /index.php$is_args$args;
                    # try_files $uri $uri/ /index.html;
                    # try_files $uri $uri/ =404;
            }
    
            location ~ \.php$ {
                    fastcgi_split_path_info ^(.+\.php)(/.+)$;
                    include snippets/fastcgi-php.conf;
                    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
                    include fastcgi_params;
                    fastcgi_param REQUEST_METHOD $request_method;
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                    fastcgi_cache MYAPP;
                    fastcgi_cache_valid 200 60m;
                    fastcgi_cache_bypass $no_cache;
                    fastcgi_no_cache $no_cache;
            }
    
    
    

    and this is my multi-site setup

            if (!-e $request_filename) {
                    rewrite /wp-admin$ $scheme://$host$uri/ permanent;
                    rewrite ^(/[^/]+)?(/wp-.*) $2 last;
                    rewrite ^(/[^/]+)?(/.*\.php) $2 last;
            }
    

@newbie

Please post the entire server block, top to bottom, so that we can take a look at the full configuration as well as order and location.

  • @jtittle @hansen
    heres my entire server block

    fastcgi_cache_path /var/run/cache levels=1:2 keys_zone=MYAPP:100m inactive=60m;
    fastcgi_cache_key "$scheme$request_method$host$request_uri";
    add_header X-Cache $upstream_cache_status;
    fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
    
        # Expires map
        map $sent_http_content_type $expires {
        default         off;
        text/html       epoch;
        text/css        30d;
        application/javascript  30d;
        ~image/         max;
        font/woff2      max;
        font/woff       max;
        image/x-icon        max;
        application/font-woff2  max;
    }
    
    server {
        listen 80 default_server;
        listen [::]:80 default_server;
    
        expires $expires;
    
        server_name mydomain.com www.mydomain.com;
    
        # SSL configuration
        #
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
    
        # include snippets/snakeoil.conf;
    
        root /var/www/html/website;
    
        # Add index.php to the list if you are using PHP
        index index.php index.html;
    
        if (!-e $request_filename) {
            rewrite /wp-admin$ $scheme://$host$uri/ permanent;  
            rewrite ^(/[^/]+)?(/wp-.*) $2 last;                     
            rewrite ^(/[^/]+)?(/.*\.php) $2 last;                   
        }
    
        #Cache everything by default
        set $no_cache 0;
    
        #Don't cache POST requests
        if ($request_method = POST) {
            set $no_cache 1;
        }
    
        #Don't cache if the URL contains a query string
        if ($query_string != "") {
            set $no_cache 1;
        }
    
        #Don't cache the following URLs
        if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
            set $no_cache 1;
        }
    
        #Don't cache if there is a cookie called PHPSESSID
        if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
            set $no_cache 1;
        }
    
        location / {
            try_files $uri $uri/ /index.php$is_args$args;
            # try_files $uri $uri/ /index.html;
            # try_files $uri $uri/ =404;
        }
    
        location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/run/php/php7.0-fpm.sock;
            include fastcgi_params;
            fastcgi_param REQUEST_METHOD $request_method;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_cache MYAPP;
            fastcgi_cache_valid 200 60m;
            fastcgi_cache_bypass $no_cache;
            fastcgi_no_cache $no_cache;
        }
    
        location ~ /\.ht {
            deny all;
        }
    
        location /xmlrpc.php {
            deny all;
        }
    
        location = /favicon.ico { log_not_found off; access_log off; }
        location = /robots.txt { log_not_found off; access_log off; allow all; }
    }
    

    in my php.ini

    cgi.fix_pathinfo = 0
    

    i have noticed few other things from https://codex.wordpress.org/Nginx
    i installed multi-site and FastCGI according DO tutorials and few things from above link is missing in those tutorials. just want to confirm they are not the reason im facing this problem.

    map $uri $blogname{
        ~^(?P<blogpath>/[^/]+/)files/(.*)       $blogpath ;
    }
    

    thanks in advance

Have another answer? Share your knowledge.