Topic on Project:Support desk

Uploads failing on MediaWiki 1.29.1

5
Theanswriz42 (talkcontribs)

On a fresh install of MediaWiki running on top of CentOS 7.4, Nginx 1.10.2, and PHP 7.2.0RC4, I'm getting the following error when trying to upload an image:

Could not open lock file for "mwstore://local-backend/local-public/a/a3/test.png".

Typically this is indicative of bad file permissions on the images directory, however it's set to 777:

[root@Steve-VM mediawiki]# ll

total 1204

-rw-r--r--.  1 nginx nginx   4166 Aug 23 13:11 api.php

-rw-r--r--.  1 nginx nginx 128576 Aug 23 13:11 autoload.php

drwxr-xr-x.  2 nginx nginx     23 Aug 23 13:11 cache

-rw-r--r--.  1 nginx nginx   3379 Aug 23 13:11 composer.json

-rw-r--r--.  1 nginx nginx    102 Aug 23 13:11 composer.local.json-sample

-rw-r--r--.  1 nginx nginx  19419 Aug 23 13:11 COPYING

-rw-r--r--.  1 nginx nginx  10866 Aug 23 13:11 CREDITS

drwxr-xr-x.  8 nginx nginx   4096 Aug 23 13:11 docs

drwxr-xr-x. 19 nginx nginx   4096 Aug 23 13:11 extensions

-rw-r--r--.  1 nginx nginx     95 Aug 23 13:11 FAQ

-rw-r--r--.  1 nginx nginx  24038 Oct 13 07:47 favicon.ico

-rw-r--r--.  1 nginx nginx   2792 Aug 23 13:11 Gemfile.lock

-rw-r--r--.  1 nginx nginx   3810 Aug 23 13:11 Gruntfile.js

-rw-r--r--.  1 nginx nginx 847782 Aug 23 13:11 HISTORY

drwxrwxrwx.  2 nginx nginx     37 Aug 23 13:11 images

-rw-r--r--.  1 nginx nginx   7705 Aug 23 13:11 img_auth.php

drwxr-xr-x. 63 nginx nginx   8192 Aug 23 13:11 includes

-rw-r--r--.  1 nginx nginx   1623 Aug 23 13:11 index.php

-rw-r--r--.  1 nginx nginx   3663 Aug 23 13:11 INSTALL

-rw-r--r--.  1 nginx nginx   1723 Aug 23 13:11 jsduck.json

drwxr-xr-x.  6 nginx nginx    201 Aug 23 13:11 languages

-rw-r--r--.  1 nginx nginx   1965 Aug 23 13:11 load.php

-rw-r--r--.  1 nginx nginx   5505 Oct 13 09:21 LocalSettings.php

drwxr-xr-x. 17 nginx nginx   8192 Aug 23 13:11 maintenance

drwxr-xr-x.  4 nginx nginx    110 Aug 23 13:11 mw-config

-rw-r--r--.  1 nginx nginx   4059 Aug 23 13:11 opensearch_desc.php

-rw-r--r--.  1 nginx nginx   1897 Aug 23 13:11 phpcs.xml

-rw-r--r--.  1 nginx nginx  12011 Aug 23 13:11 profileinfo.php

-rw-r--r--.  1 nginx nginx    530 Aug 23 13:11 Rakefile

-rw-r--r--.  1 nginx nginx   1529 Aug 23 13:11 README

-rw-r--r--.  1 nginx nginx  21836 Aug 23 13:11 RELEASE-NOTES-1.29

drwxr-xr-x.  5 nginx nginx     88 Aug 23 13:11 resources

drwxr-xr-x.  2 nginx nginx    144 Aug 23 13:11 serialized

drwxr-xr-x.  6 nginx nginx     83 Aug 23 13:11 skins

-rw-r--r--.  1 nginx nginx   1703 Aug 23 13:11 StartProfiler.sample

drwxr-xr-x. 10 nginx nginx    141 Aug 23 13:11 tests

-rw-r--r--.  1 nginx nginx   1087 Aug 23 13:11 thumb_handler.php

-rw-r--r--.  1 nginx nginx  21756 Aug 23 13:11 thumb.php

-rw-r--r--.  1 nginx nginx  12244 Aug 23 13:11 UPGRADE

drwxr-xr-x. 21 nginx nginx   4096 Aug 23 13:12 vendor

The LocalSettings.php looks like this:

<?php

if ( !defined( 'MEDIAWIKI' ) ) {

        exit;

}

$wgSitename = "Test Wiki";

$wgMetaNamespace = "Test_Wiki";

$wgScriptPath = "";

$wgServer = "http://10.12.185.88";

$wgResourceBasePath = $wgScriptPath;

$wgLogo = "$wgResourceBasePath/resources/assets/wiki.png";

$wgEnableEmail = true;

$wgEmergencyContact = "apache@10.12.185.88";

$wgPasswordSender = "apache@10.12.185.88";

$wgEmailAuthentication = true;

$wgDBtype = "mysql";

$wgDBserver = "localhost";

$wgDBname = "wikidatabase";

$wgDBuser = "root";

$wgDBpassword = "changeme";

$wgDBprefix = "";

$wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=binary";

$wgDBmysql5 = false;

$wgMainCacheType = CACHE_NONE;

$wgMemCachedServers = [];

$wgEnableUploads = true;

$wgUseImageMagick = true;

$wgImageMagickConvertCommand = "/usr/bin/convert";

$wgFileExtensions = array(

    'png', 'gif', 'jpg', 'jpeg', 'jp2', 'webp', 'ppt', 'pdf', 'psd',

    'mp3', 'xls', 'xlsx', 'swf', 'doc','docx', 'odt', 'odc', 'odp',

    'odg', 'mpp'

    );

$wgUseInstantCommons = true;

$wgPingback = true;

$wgShellLocale = "en_US.utf8";

$wgLanguageCode = "en";

$wgSecretKey = "removed";

$wgAuthenticationTokenVersion = "1";

$wgUpgradeKey = "removed";

$wgRightsUrl = "";

$wgRightsText = "";

$wgRightsIcon = "";

$wgDiff3 = "/usr/bin/diff3";

$wgGroupPermissions['*']['edit'] = false;

$wgDefaultSkin = "vector";

wfLoadSkin( 'CologneBlue' );

wfLoadSkin( 'Modern' );

wfLoadSkin( 'MonoBook' );

wfLoadSkin( 'Vector' );

wfLoadExtension( 'Cite' );

wfLoadExtension( 'CiteThisPage' );

wfLoadExtension( 'ConfirmEdit' );

wfLoadExtension( 'Gadgets' );

wfLoadExtension( 'ImageMap' );

wfLoadExtension( 'InputBox' );

wfLoadExtension( 'Interwiki' );

wfLoadExtension( 'LocalisationUpdate' );

wfLoadExtension( 'Nuke' );

wfLoadExtension( 'ParserFunctions' );

wfLoadExtension( 'PdfHandler' );

wfLoadExtension( 'Renameuser' );

wfLoadExtension( 'SpamBlacklist' );

wfLoadExtension( 'SyntaxHighlight_GeSHi' );

wfLoadExtension( 'TitleBlacklist' );

wfLoadExtension( 'WikiEditor' );

And the nginx.conf file:

user nginx;

worker_processes auto;

error_log /var/log/nginx/error.log;

pid /run/nginx.pid;

include /usr/share/nginx/modules/*.conf;

events {

    worker_connections 1024;

}

http {

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

                      '$status $body_bytes_sent "$http_referer" '

                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;

    tcp_nopush          on;

    tcp_nodelay         on;

    keepalive_timeout   65;

    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;

    default_type        application/octet-stream;

    include /etc/nginx/conf.d/*.conf;

    server {

        listen       80 default_server;

        listen       [::]:80 default_server;

        root         /var/www/mediawiki/mediawiki;

        include /etc/nginx/default.d/*.conf;

        location / {

          index index.php;

        }

       location @rewrite {

                rewrite ^/(.*)$ /index.php?title=$1&$args;

        }

        location ^~ /maintenance/ {

                return 403;

        }

        location ~ \.php$ {

                try_files $uri =404;

                fastcgi_split_path_info ^(.+\.php)(/.+)$;

                fastcgi_pass 127.0.0.1:9000;

                fastcgi_index index.php;

                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

                include fastcgi_params;

        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {

                try_files $uri /index.php;

                expires max;

                log_not_found off;

        }

        location = /_.gif {

                expires max;

                empty_gif;

        }

        location ^~ /cache/ {

                deny all;

        }

        location /dumps {

                root /var/www/mediawiki/mediawiki/local/;

                autoindex on;

        }

        location = /favicon.ico {

                alias /var/www/mediawiki/mediawiki/favicon.ico;

        }

    }

}

Ciencia Al Poder (talkcontribs)

Disable SELinux, then try again. If it works, be sure to configure it properly.

Theanswriz42 (talkcontribs)

Unfortunately selinux isn't running:

#systemctl stop selinux

Failed to stop selinux.service: Unit selinux.service not loaded.

Ciencia Al Poder (talkcontribs)

> Failed to stop selinux.service: Unit selinux.service not loaded.

This doesn't mean it's stopped. It only means there's no systemd service named "selinux". You may have spelled it wrong.

Please check the page I linked before for useful commands to check if selinux is enabled on your system.

Theanswriz42 (talkcontribs)

That worked, thanks for the heads up.