5

Trying to edit settings.php via Cpanel File Manager

I can CHMOD the file to anything I want and back but can't write to it.

I get the following message:

Could not write /home/testing/public_html/sites/default/settings.php: Permission denied

Do you think Apache suEXEC has anything to do with this?

6
  • This is server side issue not Drupal related. You need to check permission for sites, default and settings.php file. Nov 18, 2013 at 4:59
  • 1
    settings.php is write-protected. You can change the permissions to make it writable, but Drupal will change it back on the first page load, and set it write-protected again. So you should make any change in the settings.php without visiting your site after changing the permissions. Nov 18, 2013 at 5:38
  • sites/default folder permission setting is 555, is that correct? What should it be? Nov 18, 2013 at 6:02
  • @ShaneHouston ask your sysadmin. Webserver that runs Drupal must be able to enter it and all it's subfolders, read everything there, and write & delete in files subfolder. How to set that up depends on your server's configuration.
    – Mołot
    Nov 18, 2013 at 8:58
  • sites/defualt permission should be 755 Nov 18, 2013 at 9:42

4 Answers 4

13

As others have mentioned, you must set the permissions on the /sites/default folder. The default permissions are set to 0555, set them to 0755 for editing. Don't forget to restore the default values afterwards!

1
  • Thanks, I had to set permission 755 on sites folder first, then the default and finally on the files in it in order to be able to delete it all.
    – Lumis
    Nov 19, 2014 at 23:07
2

I will recommend to download the file on your local system if you can. Right click on the settings.php file and select Properties from the list. Uncheck the Read-only from Attributes. Click apply button and click OK. Make changes and upload the file back to the server.

NOTE: After editing the file Check the Read-only attribute before uploading.

enter image description here

1
  • Works. Remember that Drupal add Read-only back again as soon as Drupal is refreshed. Mar 22, 2022 at 9:16
0

You can edit the permissions of the folder it self. The folder "default" set to 0555, set them to 0755 for editing. Don't forget to restore the default values afterwards!

0

To prevent this issue in the future, add the following line to your settings.php file:

$settings['skip_permissions_hardening'] = TRUE;

This will prevent Drupal from re-enabling the read-only status of the /sites/default directory and the settings.php within. Drupal will no longer configure the permissions itself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.