Wordpress plugin install: Could not create directory

PhpWordpressFtp

Php Problem Overview


I'm using WordPress on centos 6.

I try to install a plugin. But I got this error:

> Installing Plugin: bbPress 2.5.9 > Downloading install package from https://downloads.wordpress.org/plugin/bbpress.2.5.9.zip…

> Unpacking the package…

> Could not create directory.

How can I resolve this?

P/S: I run this command:

sudo -u root touch /var/www/html/wordpress/wp-content/plugins/test.txt

and it works. But I still get that error.

Php Solutions


Solution 1 - Php

You only need to change the access permissions for your WordPress Directory:

chown -R www-data:www-data your-wordpress-directory

Solution 2 - Php

You can fix this by using the following commands. You should first be in the root folder of Wordpress.

sudo chown -R www-data:www-data wp-content/plugins/
sudo chmod 775 wp-content

sudo chown -R www-data:www-data wp-content/

Solution 3 - Php

The user that is running your web server does not have permissions to write to the directory that Wordpress is intending to create the plugin directory in. You should chown the directory in question to the user that is running Wordpress. It is most likely not root.

In short, this is a permissions issue. Your touch command is working because you're using it as root, and root has global permissions to write wherever it wants.

Solution 4 - Php

A quick solution would be to change the permissions of the following:

  • /var/www/html/wordpress/wp-content
  • /var/www/html/wordpress/wp-content/plugins

Change it to 775.

After installation, don't forget to change it back to the default permissions.. :D

Solution 5 - Php

I had to give ownership of /plugins and /upgrade to the server, nothing else.

$ cd /var/www/wordpress/wp-content
$ sudo chown www-data:www-data /plugings
$ sudo chown www-data:www-data /upgrade

Running Apache server on Ubuntu 18.04. Maybe more dirs will need to be changed later. Anyways, I plan to restore permissions once I finish editing, as suggested in this anwser.

Solution 6 - Php

To solve permission issue on plugins and themes on localhost or production quickly, you just run this

sudo chmod 757 wp-content/themes
sudo chmod 757 wp-content/plugins

if take care permission on production, you can run

sudo chown -R www-data:www-data wp-content/themes
sudo chown -R www-data:www-data wp-content/plugins

Solution 7 - Php

If you have installed wordpress using apt, the config files are split in multiple directories. In that case you need to run:

sudo chown -R -h www-data:www-data /var/lib/wordpress/wp-content/
sudo chown -R -h www-data:www-data /usr/share/wordpress/wp-content/

The -h switch changes the permissions for symlinks as well, otherwise they are not removable by user www-data

Solution 8 - Php

CentOS7 or Ubuntu 16


1.

WordPress uses ftp to install themes and plugins.
So the ftpd should have been configured to create-directory

vim /etc/pure-ftpd.confg

and if it is no then should be yes

# Are anonymous users allowed to create new directories?
AnonymousCanCreateDirs       yes

lastly

sudo systemctl restart pure-ftpd

https://raw.githubusercontent.com/k-five/badge-for-git/master/res/line/line5-900px-%23F80.svg?sanitize=true" />

2.

Maybe there is an ownership issue with the parent directories. Find the Web Server user name and group name if it is Apache Web Server

apachectl -S

it will print

...
...
User: name="apache" id=997
Group: name="apache" id=1000

on Ubuntu it is > User: name="www-data" id=33 not_used
> Group: name="www-data" id=33 not_used

then

sudo chown -R apache:apache directory-name

https://raw.githubusercontent.com/k-five/badge-for-git/master/res/line/line5-900px-%23F80.svg?sanitize=true" />

3.

Sometimes it is because of directories permissions. So try

sudo chmod -R 755 directory-name

in some cases 755 does not work. (It should & I do not no why) so try

sudo chmod -R 777 directory-name

https://raw.githubusercontent.com/k-five/badge-for-git/master/res/line/line5-900px-%23F80.svg?sanitize=true" />

4.

Maybe it is because of php safe mode. So turn it off in the root of your domain

vim php.ini

then add

safe_mode = Off

https://raw.githubusercontent.com/k-five/badge-for-git/master/res/line/line5-900px-%23F80.svg?sanitize=true" />

NOTE:
For not entering FTP username and password each time installing a theme we can configure WordPress to use it directly by adding

define('FS_METHOD','direct');

to the wp-config.php file.

Solution 9 - Php

If anyone using shared hosting and get same problem it may be disk space issue. In that case contact with your hosting support and ask them to increase disk space of your acocunt.

Solution 10 - Php

You need to change the permission of the directory

  1. At first change the user HTML folder (replace yourcomputerusername)

    sudo chown yourcomputerusername:yourcomputerusername /var/www/html

  2. Next change the permission for the user

    cd /var/www/html

    sudo chmod -R goa=rwx wordpress

    or

    sudo chmod -R 777 wordpress/wp-content

Solution 11 - Php

If you are mac user , using XAMP

Go to the htdocs folder and open the terminal on the folder , as shown in the screenshot

enter image description here

Then Type the following command on the Terminal

**sudo chmod -R 777 <your wordpress folder Name>/**

E.g sudo chmod -R 777 wordpress/

Solution 12 - Php

I was on XAMPP for linux localhost and this worked for me:

sudo chown -R my-linux-username wp-content

Solution 13 - Php

What I end up doing is every time I create a WordPress project. in /www/html

I run below command

sudo chown www-data:www-data  wordpress_folder_name -R

hope this will help someone.

Solution 14 - Php

For me the problem was FTP server that WP is using to upload update. It had writting disabled in configuration, so just enabling it fixed the problem.

Shame on WordPress for providing such misleading error message.

Solution 15 - Php

None of the above work for me except this one.

sudo chown daemon:daemon /opt/bitnami/apache/htdocs/

Don't forget to change /opt/bitnami/apache/htdocs/ to your directory

Solution 16 - Php

You could try

sudo chmod goa=rwx -R /var/www/html

Solution 17 - Php

Webserver user must have write access to directories to perform such operations, so you can try to change owner of files to webserver user (apache in this example, but can be differ from yours)

chown -R apache YOUR_BLOG_DIRECTORY

Solution 18 - Php

> To solve permission issue on ubuntu server, you just run this > > sudo chmod 777 -R 'wordpress wp-content file location' > > for example. > > sudo chmod 777 -R /usr/share/wordpress/wp-content

Solution 19 - Php

wordpressProject is the project name.

/var/www/html/wordpressProject sudo chmod -R 777 wp-content

Thanks. It will work.

Solution 20 - Php

Absolutely it must be work!

  • Use this chown -Rf www-data:www-data /var/www/html

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionfuryfishView Question on Stackoverflow
Solution 1 - Phpasb14690View Answer on Stackoverflow
Solution 2 - PhpAzam AlviView Answer on Stackoverflow
Solution 3 - PhpkevrView Answer on Stackoverflow
Solution 4 - PhpSeverino Lorilla Jr.View Answer on Stackoverflow
Solution 5 - PhpGabi LView Answer on Stackoverflow
Solution 6 - PhpTLbizView Answer on Stackoverflow
Solution 7 - PhpPelleView Answer on Stackoverflow
Solution 8 - PhpShakiba MoshiriView Answer on Stackoverflow
Solution 9 - PhpAsif AsgharView Answer on Stackoverflow
Solution 10 - PhpMD SHAYONView Answer on Stackoverflow
Solution 11 - PhpFitsum AlemuView Answer on Stackoverflow
Solution 12 - PhpSunil KumarView Answer on Stackoverflow
Solution 13 - PhpHitesh RanautView Answer on Stackoverflow
Solution 14 - PhpGoogieView Answer on Stackoverflow
Solution 15 - PhpUzairView Answer on Stackoverflow
Solution 16 - PhpMD SHAYONView Answer on Stackoverflow
Solution 17 - PhpMahdi BashirpourView Answer on Stackoverflow
Solution 18 - PhpIshwar Chandra TiwariView Answer on Stackoverflow
Solution 19 - PhpY. Joy Ch. SinghaView Answer on Stackoverflow
Solution 20 - PhpLouis ByunView Answer on Stackoverflow