Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Completely frustrating me.

When I try and upload a small jpeg file I get the following error:

Warning: wfMkdirParents: failed to mkdir "/usr/local/mediawiki-1.20.5/images/5/5d" mode 0777 in /usr/local/mediawiki-1.20.5/includes/GlobalFunctions.php on line 2546

CentOS 6.4 MediaWiki 1.20.5 PHP 5.5.0RC1 (apache2handler) MySQL 5.5.31

php.ini

safe_mode = off;
file_uploads = On
max_file_uploads = 20

localsettings.php

$wgEnableUploads = true;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/bin/convert";

images folder

chown apache:apache images/
chmod 755 -R images/ (threw error)
chmod 777 -R images/ (threw error)

I've restart apache and still cannot upload. I'm stumped. Any ideas?

share|improve this question
1  
Has it ever worked? Did you check the audit.log? –  Michael Hampton Jun 27 '13 at 22:52
    
It's chmod for permissions, not chown. –  Nathan C Jun 27 '13 at 22:59
    
"chown -R" and "chmod -R", please :) –  GioMac Jun 27 '13 at 23:16
1  
And because it's centos, "setenforce permissive" –  GioMac Jun 27 '13 at 23:18
    
Yes I used chmod it was a typo. GioMac can you elaborate what you mean setenforce permissive? –  Michael Jun 28 '13 at 20:50

1 Answer 1

up vote 2 down vote accepted

This is caused by SELinux, rather than setting SELinux to only log and not enforce policy (permissive mode) you can modify the labels on the file system to allow the Apache to write the location while SELinux is enforcing:

Assuming /usr/local/mediawiki-1.20.5/images is the location you want to allow write access to:

semanage fcontext -a -t httpd_sys_content_t "/usr/local/mediawiki-1.20.5/images(/.*)?" 

Will change the SELinux context on the directory and anything below it, and

restorecon -Rv /usr/local/mediawiki-1.20.5/images 

Will relabel the files and directories as per the SELinux context.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.