How to Solve Error Message Sorry, but I can’t write the wp-config.php file

Posted on


The following article discuss a specific error message appear. The error message is in the title of this article. That error itself exist in one of a wordpress installation page. That page display the error in a specific error message. In the page, the error message appear in the top part of the page. Specifically, the error message is ‘Sorry, but I can’t write the wp-config.php file’. In order to give a better information, the following is the image of the error message occur upon installing a wordpress-based website :

The above page appear after the submission of the following page :

Actually, the above page is a MySQL database configuration connection for installing wordpress-based website. After finishing to fill all of the necessary value for the MySQL database server’s configuration connection, the process continue by clicking the ‘Submit’ button. But the wordpress installation process is stop because of the previous error message.

Solving the Problem

The solution for the above error is actually quite simple. The solution for the above problem exist with at least two types of solution. Those solutions are in the following description and explanation :

1. The error message actually hinting the solution indirectly. Following the error message, there is a solution given to solve the problem in the same page where the error message appear. The solution exist in the form of a sentence : ‘You can create the wp-config.php file manually and paste the following text into it’. Well, the solution is quite brief and clear. Just create the ‘wp-config.php’ file in the root directory of the website. Fill the file with the content available in the above page. Depend on the version of the wordpress for the installation purpose, just copy the content from the page to the ‘wp-config.php’ file.

root@hostname ~# touch wp-config.php
root@hostname ~#

The above command is a command for creating a new file with the name of ‘wp-config.php’. After creating that file, don’t forget to copy and paste the configuration script or snippet code exist in the above page where the solution to solve the problem is explained.

2. The other solution is actually quite simple. Rather than creating the file manually, just change the permission of the root directory of the wordpress-based installation. Changing the permission is an important step to achieve the solution. It will permit wordpress to create the ‘wp-config.php’ file automatically and write the necessary content to that file. The following is a step for changing the permission of the root folder containing the wordpress source code installation :

root@hostname ~# chown -Rv www-data.www-data

changed ownership of '' from root:root to www-data:www-data
root@hostname ~# 

By implementing one of the above solution explained, just click the button with the label of ‘Run the installation’. The following page will appear :

It means, all of the preparation step for the wordpress installation is finally finished. The last part of the wordpress installation is just running it by clicking the button with the label of ‘Run the installation’ as it shows in the above output image.

Leave a Reply