Linux Wordpress can't not write wp-config file Linux Wordpress can't not write wp-config file wordpress wordpress

Linux Wordpress can't not write wp-config file


This is what worked for me. (I'm a beginner and I'm using Debian 8)

First I checked the Apache config file to find the group that apache uses. In my case it was www-data.grep ^Group /etc/apache2/httpd.conf

I checked my /etc/group file and the group www-data was there.

Then I changed the group ownership of my wordpress directory from root to www-data.

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

I changed the permissions of my wordpress folder to 755 for directories and 644 for files, following the recommendations of other sites.

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

But since we want to give write permissions to the group www-admin for the wordpress folder and subfolders, I changed the permissions for directories to 775:

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

Then it worked: All right, sparky! You’ve made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to…

Notes: The username and password of my myssql database was root/root. The username I was using to login to my computer was root and the password was something different than root. Just in case I changed my password to root, so the credentials of mysql and my local account are the same. I don't know if by having the same name (root) they are the same account.


Sounds like www-data is not the group name used by apache on your system. To find what it actually uses, try the following:

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

(That's a capital O, not a zero). The column GID (probably the second column) is the numeric group ID that apache is running under. Look up its name in /etc/group.


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 (lack of write permission context).

To solve that - You can change Apache/HTTPD write context with in the web-content folder like this (Specific to the Debian environment, as mentioned in this question):

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

OR (on CentOS/Fedora):

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

You can validate the output like this (on CentOS/Fedora):

# pwd# /var/www

Notice the output of below command having changed RW (Read/Write) context on 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

NOTE: Do validate the Path, Web Server User-Names, and SELINUX write-context as per your environment before executing above commands.