If you are like me and just tried installing WordPress on a server such as an AWS ec2 or any other server that you can access, and had trouble in the installation process this post might help you.
Upon entering the database setup information in the initial step, and you click the submit button you get along the lines of:
“Sorry, but I can’t write the wp-config.php file’
To solve this a possible solution is to create the file manually following the instructions provided under the error message. They tell you to create the file wp-config.php manually and to paste the text they show you. This may or may not solve your problem. In my case it did not.
The reason why this didn’t solve my problem is that my files did not have the same user name and group name that apache uses. To find the username for apache in your system you can run the command:
cat /etc/apache2/envvars | grep USER
and for the group
cat /etc/apache2/envvars | grep GROUP
in my case the output for both of these was www-data
The next step is to change the user name and group name for your apache’s root directory (or “localhost directory” as some call it)
in my case (ubuntu 16.04) it’s /var/www/html
sudo chown -R www-data:www-data /var/www/html
Then restart your apache server just in case
sudo service apache2 restart
After this if you try to run the config step one more time, you should get the success message, and then you can finish the installation process.