Cannot upload anything via wordpress

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.

Read More

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/

Related posts

3 comments

  1. 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.

  2. 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.

  3. 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.

Comments are closed.