php Wordpress 插件安装:无法创建目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37157264/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 01:05:41  来源:igfitidea点击:

Wordpress plugin install: Could not create directory

phpwordpressftp

提问by furyfish

I'm using WordPress on centos 6.

我在 centos 6 上使用 WordPress。

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.

安装插件:bbPress 2.5.9 从https://downloads.wordpress.org/plugin/bbpress.2.5.9.zip下载安装包...

拆开包装…

无法创建目录。

How can I resolve this?

我该如何解决这个问题?

P/S: I run this command:

P/S:我运行这个命令:

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

and it works. But I still get that error.

它有效。但我仍然收到那个错误。

采纳答案by kevr

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.

运行您的 Web 服务器的用户无权写入 Wordpress 打算在其中创建插件目录的目录。您应该将该目录告知运行 Wordpress 的用户。它很可能不是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.

简而言之,这是一个权限问题。您的 touch 命令正在运行,因为您以 root 身份使用它,并且 root 拥有在任何地方写入的全局权限。

回答by asb14690

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

您只需要更改 WordPress 目录的访问权限:

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

回答by Azam Alvi

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

您可以使用以下命令修复此问题。您应该首先位于 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/

回答by Severino Lorilla Jr.

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
  • /var/www/html/wordpress/wp-content
  • /var/www/html/wordpress/wp-content/plugins

Change it to 775.

将其更改为775.

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

安装后,不要忘记将其改回默认权限.. :D

回答by Gabi L

I had to give ownership of /pluginsand /upgradeto the server, nothing else.

我不得不放弃所有权/plugins/upgrade服务器,没有别的。

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

在 Ubuntu 18.04 上运行 Apache 服务器。也许以后需要更改更多目录。无论如何,我计划在完成编辑后恢复权限,如本 anwser 中所建议。

回答by TLbiz

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

回答by Shakiba Moshiri

CentOS7 or Ubuntu 16

CentOS7 或 Ubuntu 16



1.

1.

WordPress uses ftpto install themesand plugins.
So the ftpdshould have been configured to create-directory

WordPress 用于ftp安装主题插件
所以ftpd应该已经配置为create-directory

vim /etc/pure-ftpd.confg

and if it is nothen should be yes

如果不是,那么应该

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

lastly

最后

sudo systemctl restart pure-ftpd

2.

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

也许父目录存在所有权问题。如果是Apache Web Server,则查找Web Server 用户名和组名

apachectl -S

it will print

它会打印

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

on Ubuntu it is

在 Ubuntu 上它是

User: name="www-data" id=33 not_used
Group: name="www-data" id=33 not_used

用户:name="www-data" id=33 not_used
组:name="www-data" id=33 not_used

then

然后

sudo chown -R apache:apache directory-name

3.

3.

Sometimes it is because of directories permissions. So try

有时是因为目录权限。所以试试

sudo chmod -R 755 directory-name

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

在某些情况下755不起作用。(它应该&我不知道为什么)所以尝试

sudo chmod -R 777 directory-name

4.

4.

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

也许是因为 php 安全模式。因此,在您的域的根目录中将其关闭

vim php.ini

then add

然后加

safe_mode = Off

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

注意:
为了在每次安装主题时不输入FTP用户名和密码,我们可以通过添加配置 WordPress 直接使用它

define('FS_METHOD','direct');

to the wp-config.phpfile.

wp-config.php文件。

回答by Pelle

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

如果您使用 apt 安装了 wordpress,则配置文件将拆分到多个目录中。在这种情况下,您需要运行:

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 -hswitch changes the permissions for symlinks as well, otherwise they are not removable by user www-data

-h开关也会更改符号链接的权限,否则用户无法删除它们www-data

回答by Asif Asghar

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.

如果有人使用共享主机并遇到同样的问题,则可能是磁盘空间问题。在这种情况下,请联系您的托管支持并要求他们增加您帐户的磁盘空间。

回答by Sunil Kumar

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

我在 XAMPP for linux localhost 上,这对我有用:

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

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