CentOS 7系统安装wordpress无权限问题解决办法

如果你的wordpress安装目录是wordpress,则通过默认向导配置会出现权限不足的情况:

Sorry, but I can’t write the wp-config.php file.
You can create the wp-config.php manually and paste the following text into it.

或者

抱歉,但是向导在您的文件系统中没有足够的权限写入wp-config.php文件。

这时候,首先考虑wordpress文件夹的所属用户和组,根据httpd.conf中User和Group的配置,更新wordpress目录及其子目录的所有归属:

chown -R apache:apache wordpress/

如果该方法不解决问题,尝试以下命令:

ls -Z
drwxr-xr-x. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 wordpress

chcon -R -t httpd_sys_rw_content_t #为httpd添加读写权限
ls -Z
drwxr-xr-x. apache apache unconfined_u:object_r:httpd_sys_rw_content_t:s0 wordpress

注意

该问题通常是由于手动创建wordpress目录后,再将原版中的所有文件复制进去引起的。通过直接拷贝整个wordpress目录也可以解决。