Skip to content
Home » WordPress » How to Resolve Unable to write to wp-config.php file

How to Resolve Unable to write to wp-config.php file

WordPress - Sorry, but I can’t write the wp-config.php file.

Unable to write to wp-config.php file

During WordPress installation, you might see an error like this:

Unable to write to wp-config.php file.

You can create the wp-config.php file manually and paste the following text into it.

According to the instruction, you can create the wp-config.php and copy / paste the text into it.

Where is wp-config.php

The wp-config.php location is directly under the document root of this virtual host:

<DocumentRoot>/wp-config.php

But copying the content to wp-config.php manually does not get rid of the root cause. You may have chances to solve the problem more gracefully.

Disable SELinux

This is because SELinux is enforcing which prevents WordPress from writing files. You may need to know how to disable SELinux temporarily or permanently.

Afterwards, you can go back to the previous page, set the correct password and then submit the form again. You'll see a successful message on the page.

All right, sparky! You’ve made it through this part of the installation.
All right, sparky! You’ve made it through this part of the installation.

The successful message is as this:

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…

Run the installation

Let's check wp-config.php

[root@web ~]# ll /var/www/html/example/wp-config.php
-rw-rw-rw- 1 apache apache 3206 Dec 30 21:35 /var/www/html/example/wp-config.php

It's WordPress that made the file for us.

Leave a Reply

Your email address will not be published. Required fields are marked *