Unable to create directory wp-content/uploads/2016/03. Is its parent directory writable by the server?

March 8, 2016 10.2k views

I have set up a droplet running ubuntu 14.04X64 with Sentora Control Panel. Within the sentora control panel, I have created FTP accounts. I uploaded wordpress via FTP and successfully installed on my droplet.

I attempted to upload a theme from my laptop via the wordpress Add Themes uploader. The theme upload is failing and I am getting the error below:

"Unable to create directory wp-content/uploads/2016/03. Is its parent directory writable by the server?"

I observed the same thing when attempting to install a theme from the wordpress theme repository.

The /wp-content, /wp-content/themes and /wp-content/uploads folder's permission is originally 755, I changed this to 777 and the theme upload succeeded each time.

What is a more practical way of resolving this issue as file permission 777 is a big security risk and not future proof?

1 comment
  • Its all about permissions:
    You need to add a group, e.g., www or www-data [ These are the common groups in web hosting, but you can choose what ever you want ]
    root@cubox208:/# useradd apache
    root@cubox208:/# usermod -a -G www apache
    root@cubox208:/# chown -R root:www /var/www
    root@cubox208:/# chmod 2775 /var/www
    root@cubox208:/# find /var/www -type d -exec chmod 2775 {} +
    root@cubox208:/# find /var/www -type f -exec chmod 0664 {} +
    reload your apache & mysql
    NOTE: We need to make sure the files in /var/www/ have 664 permissions and all directories have 755 permissions. Use sudo if you are not root. Also you can bypass the ftp user credentials while uploading the themes by adding this line at the end of the wp-config file.

2 Answers

This is typically an issue with file and directory ownership more often than permissions. Based on the Sentora configuration for your php deployment, verify with a phpinfo page what user the php code is executing as.

Once you know the system user, be sure your ftp account is configured to upload the files as that user. To address the issue as is, typically you will update the ownership of the base path using "chown" to match that user, so that the php execution ( running as that user ) has the permission to read, write and create additional paths under it. The base path being the document root your application is installed at based on the web server configuration.

Hope that helps.

  • Thank you jcastillo for the input, in case someone else is having the same challenge, these are the steps I followed to resolve the problem:

    1. I gave user ownership to the FTP account user that I am using to interact with my site.
      The group ownership, I gave to the web server process, which is apache. This will allow Apache to interact with the content as necessary.

      sudo chown -R myftp_user:apache *
    2. I allowed the web server itself to write to this directory. I did this by assigning group ownership of this directory to my web server, like this:

      chown -R :apache /path_to_root_directory/*

      This will allow the web server to create files and directories under this directory, which permited me to upload content to the server.


Have another answer? Share your knowledge.