Raddy Website Design & Development Tutorials

AWS LightSail Fix WordPress File permissions

By Raddy in Other / WordPress ·

Recently I moved this WordPress website from one Lightsail instance to another. As soon as I moved the website I noticed permission issues. I couldn’t update any of the plugins, and some of them came up with permission errors. On top of that, I noticed that I couldn’t update files using SFTP. It was giving me similar errors – permission denied.

Fix

1) Find your current bitnami folder structure

You can do that by connecting with SFTP. All you need to know is where your WordPress files are stored. In my latest case, they were under “opt/bitnami/wordpress/”.

2) Open Terminal in AWS

Log in to your AWS account and click on the orange terminal button.

aws wordpress premissions fix

This will open a Terminal window.

2) Change File and Folder permissions

Change the file permissions at your own risk. Encountering plugin errors after that is normal. They just need to be re-configured. It’s part of the process.

Once you have the Terminal window open, you need to run the following commands, one by one.

sudo chown -R bitnami:daemon /bitnami/wordpress/
sudo find /bitnami/wordpress/ -type d -exec chmod 775 {} \;
sudo find /bitnami/wordpress/ -type f -exec chmod 664 {} \;

// Once you are done with configuring your website you can lock the wp-config file back to chmod 640
sudo chmod 640 /bitnami/wordpress/wp-config.php

OR

sudo chown -R bitnami:daemon /opt/bitnami/wordpress/
sudo find /opt/bitnami/wordpress/ -type d -exec chmod 775 {} \;
sudo find /opt/bitnami/wordpress/ -type f -exec chmod 664 {} \;

// Once you are done with configuring your website you can lock the wp-config file back to chmod 640
sudo chmod 640 /opt/bitnami/wordpress/wp-config.php

Once you run each command, that should fix the problem. You don’t need to restart.

I hope this helps.

More Resources:

  1. Yaiza says:

    Hi there,

    I could not write in the wp-config.php so I tried to update the WordPress file system permissions as explained here.

    After running the code in the SSH console the website is inaccessible and I can only see a blank page. How can I fix this?

    TIA

    1. Raddy says:

      That could be a good thing. Next, you need to change the WP_DEBUG to true inside your wp-config.php file so you can see where the errors come from. Disable / Enable Plugins if you have to and so on. Let me know how it goes 🙂

      Edit* if you are getting Internal Server Error 500, it could be your old .htaccess file. Make a copy of it and remove it from the server. Then Login to your website, Settings -> Permalinks and Click Save changes. This will re-generate it

  2. Yaiza says:

    I’ve turned on the WP_DEBUG, however, I can’t find the log on the wp-content folder.

    Also, I’ve renamed the plugins folder to disable them all. But still only a blank page.

    I am not sure what else I can do to restore it. Let me know if you have any other suggestion. Thanks a lot!

    1. Raddy says:

      If it’s the tanic website on your profile, you have “HTTP ERROR 500”. Try re-creating your Permalinks

  3. Yaiza says:

    I’ve updated the permalinks via wp-config.php but still showing the HTTP ERROR 500. The error only came up after modifying the file’s permission.

    I am unable to find any information related to this issue…😖

  4. Yaiza says:

    Currently I am unable to log in to my WP dashboard since I only can see a white screen.

    1. Raddy says:

      You need to: turn on debugging, deactivate all plugins, fix .htaccess and maybe try increasing the memory limit. Let me know when you do all of them.

      You can also re-upload your website and get it to the stage where it was before. You might even have a restore point in AWS.

  5. Yaiza says:

    1/ Turned on debugging with this code:

    define( ‘WP_DEBUG’, true );
    // Enable Debug logging to the /wp-content/debug.log file
    define( ‘WP_DEBUG_LOG’, true );

    No record has been created.

    2/ The plugins folder has been renamed to disable all plugins, but no effects.

    3/ Memory limit is set to 512M define(‘WP_MEMORY_LIMIT’, ‘512M’);

    So, after this troubleshooting, the website still returns a 500 error or blank page. Would restoring an old backup be the only option?

    1. Raddy says:

      .htaccess? – That’s an important thing. You can re-upload your website if you wish. There is almost no point in going back as soon or later you will need to change the file permissions and face the issues that you are having now.

      Feel free to add me on Discord: Raddy#8190

  6. Yaiza says:

    I’ve reuploaded a backup of the .htaccess and also tried to disable it. None of those steps worked for me.

    That’s my main concern… I’ve already had some issues in the past with the Lightsail file permissions, so I am unsure if I’ll keep the website in AWS or just migrate it again.

    Thanks a lot, I’ll reach out to you on Discord

  7. Ryan Malham says:

    I ran the version 2 of these commands and it’s not allowing the config file to be editable. Also, another one of my import processes stopped working right after I made the changes. Is there a way to reverse the commands to what they were?

    1. Raddy says:

      That’s because the last command locks wp-config back to chmod 640. You can run the top 3 commands and leave the last one until you configure your website if you wish. The last command basically makes it more secure.

      What import process? Maybe try to re-import now that you’ve done the permissions.

      I guess you could revert it by locking back your files and feders. You’ll have to find out what the original chmod was for bitnami.

      There is no point of going back as you need the file permissions or your WordPress website won’t work properly. You might not be able to install plugins, upload media and so on.

  8. وردپرس says:

    بسیار عالی و کارآمد بود

    1. Raddy says:

      متشکرم!

  9. John says:

    I love you men! Thanks a lot!!!

    1. Raddy says:

      Glad to see that you found the article useful! Thanks for the comment

  10. Ramesh says:

    Thanks a lot!

  11. Craig says:

    Any help would be greatly appreciated on adding directories and files to a child theme in Lightsail. I have run these commands, permissions are set to 775 on child theme folder, but cannot add files or folders to directory.

    Thanks in advance for any help.

    1. Raddy says:

      This might sound strange, but you could try removing the Child Theme folder and then re-creating it manually using FTP (Filezilla) or the Terminal. Once you create the folder, re add the files and run the permissions command again.

      I hope that this fixes the issue

      You could also check the premissions of that folder using ls -l. You will just have to `CD` to your theme folder and then run it.

      1. Craig says:

        That appeared to work, appreciate it. Unfortunately, can’t delete the old themes uploaded before I changed the permissions. Appreciate the help!

  12. Marlo says:

    Man, thank you so much for the article, you saved my life! I was looking for the right solution for so long and your article finally helped me. Thank you!

    1. Raddy says:

      I appreciate the comment! Glad to hear that you found the article useful

  13. Russ says:

    Lifesaver! A month of not knowing how to fix this since latest WP update and AWS support doing nothing. And your post fixed it in three seconds. Thanks!

  14. Clint says:

    This was perfect. Migrated from GoDaddy over to AWS via FTP and this was exaclty the issue I was facing. Appreciate the post!

  15. Carlton says:

    Thanks Raddy. This did the trick!

  16. Moises says:

    Ty! This way is perfect!

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.