添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
高大的板栗  ·  合并到git后的git-svn ...·  10 月前    · 

Linux版Wordpress不能不写wp-config文件

5 人关注

我在我的电脑上安装了最新版本的Apache2 / PHP / MYSQL

在/srv/www/htdocs目录下,我创建了一个包含所有wordpress文件的目录wordpress。

然后,当我试图通过网络界面创建wp-config文件时,我得到了这个错误。

Sorry, but i can't write the wp-config file.

我尝试用这个命令来改变/src/www/htdocs/wordpress的组别。

chown -R root:root /srv/www/htdocs/wordpress

但它并不奏效。经过一些研究,我看到很多人说要把组别改为www-data,但我没有看到www-data使用这个命令。

cut -d: -f1 /etc/group

有谁知道我做错了什么?

对不起,我的英语不好。

1 个评论
我在你的列表中看到一个叫做 www 的小组。 这可能就是你要找的东西。
linux
wordpress
file-permissions
seb
seb
发布于 2013-11-26
5 个回答
John
John
发布于 2018-06-11
已采纳
0 人赞同

这就是对我有用的东西。(我是个初学者,我使用的是Debian 8)

首先,我检查了Apache的配置文件,找到apache使用的组。在我的例子中,它是www-data。 替换代码0

我检查了我的/etc/group文件,www-data组在那里。

然后我把wordpress目录的组所有权从根目录改为www-data。

chown -R root:www-data /var/www/html/wordpress

根据其他网站的建议,我把wordpress文件夹的权限改为目录755,文件644。

find /var/www/html/wordpress -type d -exec chmod 755 {} \;
find /var/www/html/wordpress -type f -exec chmod 644 {} \;

但由于我们想给wordpress文件夹和子文件夹的www-admin组以写权限,我把目录的权限改为775。

find /var/www/html/wordpress -type d -exec chmod 775 {} \;

Then it worked:好了,小家伙!你已经完成了这部分的安装。WordPress现在可以和你的数据库通信了。如果你准备好了,现在是时候...

笔记。myssql数据库的用户名和密码是root/root。我用来登录电脑的用户名是root,密码是与root不同的东西。为了以防万一,我把密码改成了root,所以mysql的凭证和我的本地账户是一样的。我不知道是否因为有相同的名字(root),它们就是同一个账户。

alexis
alexis
发布于 2018-06-11
0 人赞同

听起来, www-data 不是你系统中apache使用的组名。要找到它实际使用的名称,请尝试以下方法。

ps xO gid | head -n 1; ps xO gid | grep httpd

(这是一个大写的O,而不是一个0)。GID这一栏(可能是第二栏)是apache正在运行的数字组ID。在/etc/group中查找其名称。

seb
GID返回0,这是否意味着没有?你可以在我的原帖中查看图片
组别id 0几乎可以肯定就是 root 所属的组别。请在 /etc/group 中查找它,它是第三列。它可能被称为 root ,或 staff wheel (或其他什么,谁知道)。不过,以较少的权限运行apache可能是个好主意......如果你能想出办法的话。
seb
是的,零是根。root拥有所有权限,目录/srv/www/htdocs被设置为root组。为什么我还是没有权限使用wordpress的web界面编写wp-config文件?
不要把root组和root uid混为一谈。但事实上,看起来一个gid为0的进程应该能够 创建 文件在 wordpress 子目录中(因为组写权限位被设置)。要么是文件已经存在,并且不能被零组写入,要么是apache(或wordpress)采取特殊措施来控制零组权限--这样运行apache真的不是一个好主意。
Pejman Kheyri
Pejman Kheyri
发布于 2018-06-11
0 人赞同

unable to write to wp-config.php file.

我的 ubuntu 20.04 WordPress 5.x 都有这个问题。我通过这些步骤解决了这个问题。

  • First, change the group ownership of the WordPress directory from root to www-data.
  • sudo chown -R root:www-data /var/www/html/wordpress
    
  • Then change your WordPress folders permission by this command.
  • sudo find /var/www/html/wordpress -type d -exec chmod 755 {} \;
    
  • Then change your WordPress files permission by this command.
  • sudo find /var/www/html/wordpress -type f -exec chmod 644 {} \;
    
  • Run the installation again.
  • Amit Verma
    Amit Verma
    发布于 2018-06-11
    0 人赞同

    Even though I implemented CHOWN & CHMOD steps, but the issue was still persisting, then I found another scenario where this/same error could occur because of SELINUX CONTEXT issue ( 缺乏写入权限的背景 ).

    为了解决这个问题 - 你可以改变Apache/HTTPD write context 与在web-content文件夹中像这样(特定于Debian环境,如本问题中提到的)。

    chcon -R -t httpd_sys_rw_content_t  /src/www/htdocs
    

    或者(在CentOS/Fedora上)。

    chcon -R -t httpd_sys_rw_content_t  /var/www/html
    

    你可以像这样验证输出(在CentOS/Fedora上)。

    # pwd
    # /var/www
    

    注意下面的命令的输出,有改变了RW(读/写)上下文在html (web-content) folder:

    # ls -ltrZ
    # drwxrwxr-x. 2 apache apache system_u:object_r:httpd_sys_script_exec_t:s0 4096 Jul  9 20:45 cgi-bin
    # drwxrwxr-x. 5 apache apache system_u:object_r:httpd_sys_rw_content_t:s0  4096 Jul 14 19:28 html