Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've just recently installed a local installation of Wordpress 3.5.2 on my laptop, running ubuntu 12.10. I installed following the guide from here. So far, everything else is working, except I cannot upload any media files via Media Library -> Add New.

The file seems to upload as the progress bar climbs from 0 to 100%. However after that, wordpress cannot display the thumbnail or the image anywhere. After looking at the uploads folder, it's empty. So I figured it's a permissions problem, after following directions from the support forums, no dice.

Wordpress is installed to /usr/share/wordpress. The uploads folder is by default in /var/lib/wordpress/wp-content/uploads. I've got 755 for wp-content/ and 777 for uploads. Folders are owned by www-data.

I can't see any errors, the files merely won't appear anywhere. I can manually copy files to the uploads/ folder as any user because of the permissions and I can view http://localhost/wordpress/wp-content/uploads/file.jpg with a web browser. I have no themes or additional plugins installed. I've added define('WP_DEBUG', true); to my config-file but no errors are displayed.

EDIT: Here's a line from /var/log/apache2/error.log if it's of any help.

[Thu Jun 27 22:35:02 2013] [error] [client 127.0.0.1] PHP Warning:  Creating default object from empty value in /usr/share/wordpress/wp-admin/includes/update.php on line 92, referer: http://localhost/wordpress/wp-admin/upload.php

EDIT2: Here's are example directory listings with permissions

msvalkon@Lunkwill:/var/www$ ll
total 20
drwxr-xr-x  2 www-data www-data 4096 Jun 27 12:21 ./
drwxr-xr-x 15 root     root     4096 Jun  7 10:06 ../
-rw-------  1 www-data www-data   46 Jun 27 12:21 .bash_history
-rw-r--r--  1 root     root      200 Jun 27 11:46 index.php
-rw-r--r--  1 root     root       11 Dec 14  2012 .profile
lrwxrwxrwx  1 msvalkon www-data   21 Jun 20 11:45 wordpress -> /usr/share/wordpress//

msvalkon@Lunkwill:/usr/share/wordpress$ ll
total 164
drwxr-xr-x   5 msvalkon www-data  4096 Jun 27 13:41 ./
drwxr-xr-x 349 root     root     12288 Jun 20 11:51 ../
lrwxrwxrwx   1 msvalkon www-data    23 Sep 13  2012 .htaccess ->  /etc/wordpress/htaccess
-rw-r--r--   1 msvalkon www-data   395 Jan  8  2012 index.php
-rw-r--r--   1 msvalkon www-data  9202 Sep 13  2012 readme.html
-rw-r--r--   1 msvalkon www-data  4264 Dec 14  2011 wp-activate.php
drwxr-xr-x   9 msvalkon www-data  4096 Jun 27 12:48 wp-admin/
--- SNIP ---
drwxr-xr-x   5 msvalkon www-data  4096 Jun 27 12:48 wp-content/


msvalkon@Lunkwill:/var/lib/wordpress$ ll wp-content/
total 28
drwxrwxrwx 7 msvalkon www-data 4096 Jun 27 12:58 ./
drwxrwxrwx 3 msvalkon www-data 4096 Jun  5 18:17 ../
drwxrwxrwx 2 msvalkon www-data 4096 Sep 13  2012 blogs.dir/
drwxrwxrwx 2 msvalkon www-data 4096 Jun 27 12:48 languages/
drwxrwxrwx 2 msvalkon www-data 4096 Jun 27 12:48 plugins/
drwxrwxrwx 2 msvalkon www-data 4096 Jun 27 12:48 themes/
drwxrwxrwx 2 msvalkon www-data 4096 Jun 27 13:17 uploads/
share|improve this question
    
Turn on error handling on your local server. –  Scott Simpson Jun 27 '13 at 16:17
    
@ScottSimpson I've added a log entry from /var/log/apache2/error.log but I don't think it's very helpful. –  msvalkon Jun 27 '13 at 19:55
    
Have you included yourself into the www-data group? –  tnog Jun 27 '13 at 20:42
add comment

3 Answers

up vote 1 down vote accepted

Right, I've managed to solve the problem. Maybe this answer helps other people who encounter the issue again. The problem is inherently in the installation procedure when installing via the package manager in ubuntu.

The actual issue was in the database configuration, the installation had set WP_CONTENT_DIR to /srv/www/wp-content/localhost, a directory I did not even know existed.

msvalkon@Lunkwill:/var/www/wordpress$ sudo cat /etc/wordpress/config-localhost.php 
<?php
# Created by /usr/share/doc/wordpress/examples/setup-mysql 
--- SNIP ----
define('WP_CONTENT_DIR', '/srv/www/wp-content/localhost');
define('WP_DEBUG', true);
?>

Apparently the .deb package creates the following directory structures:

/usr/share/wordpress <-- contains a wp-content-folder and symlinks to
                         /var/lib/wordpress/wp-content/uploads and /blogs.dir
/var/lib/wordpress <-- contains a wp-content-folder
/srv/www/wordpress <-- also contains a wp-content-folder

Modifying the permissions of /srv/www/wordpress/wp-content finally worked.

share|improve this answer
add comment

777 permissions are passably OK on localhost, but very bad in production. (You can temporarily set 777 and try a upload, and if it works, set the folder permissions back to 755; this is a work around for some host configs.)

See http://codex.wordpress.org/Changing_File_Permissions for the standard WP permission scheme.

From that doc:

Typically, all files should be owned by your user (ftp) account on your web server, and should be writable by that account. On shared hosts, files should never be owned by the webserver process itself (sometimes this is www, or apache, or nobody user).

And see http://codex.wordpress.org/Hardening_WordPress#File_Permissions for the best way to set secure permissions.

share|improve this answer
    
I currently have 777 everywhere, but it's still not working. I will of course revert everything to the strictest possible configuration once this problem is solved. I've checked phpinfo() and the service is running as www-data. That user owns all wordpress related folders, so I don't see how my user account is relevant? –  msvalkon Jun 27 '13 at 19:38
    
FTP user account on the server, not the WordPress user account; there's no relation to each other. See askubuntu.com/questions/214526/wordpress-permissions-ubuntu and follow the link to the Wordpress forums –  songdogtech Jun 27 '13 at 19:44
    
I'll check that link out in a bit but I have to mention that this is a local installation on my laptop. I don't have an FTP account, nor do I have an ftp daemon installed. I can manually transfer files to the uploads directory by using my own account or www-data. Or any other for that matter since the permissions are so loose at the moment. –  msvalkon Jun 27 '13 at 19:49
    
@sondogtech - I'm afraid that link does not offer any new information. I will not want to change apache to run as my user instead of a dedicated user account, because it is a clear security risk and Wordpress cannot possibly require this. Other than that the permissions are set as they are, I even chowned everything as myuser:www-data with no avail. –  msvalkon Jun 27 '13 at 20:05
add comment

On my 13.04 installation, there actually was a directory /srv/www/wp-content/localhost, with blogs.dir and uploads being actual directories inside it, while the other three directories are symlinks to /var/lib/wordpress/wp-content.

Replacing the two subdirs and making them symlinks similar to the other ones solved the issue for me.

share|improve this answer
add comment

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.