AWS LightSail Fix WordPress File permissions
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.
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 /var/www/html/ sudo find /var/www/html/ -type d -exec chmod 775 {} \; sudo find /var/www/html/ -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 /var/www/html/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:
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
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
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!
If it’s the tanic website on your profile, you have “HTTP ERROR 500”. Try re-creating your Permalinks
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…😖
Currently I am unable to log in to my WP dashboard since I only can see a white screen.
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.
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?
.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
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
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?
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.
بسیار عالی و کارآمد بود
متشکرم!
I love you men! Thanks a lot!!!
Glad to see that you found the article useful! Thanks for the comment
Thanks a lot!
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.
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.
That appeared to work, appreciate it. Unfortunately, can’t delete the old themes uploaded before I changed the permissions. Appreciate the help!
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!
I appreciate the comment! Glad to hear that you found the article useful
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!
This was perfect. Migrated from GoDaddy over to AWS via FTP and this was exaclty the issue I was facing. Appreciate the post!
Thanks Raddy. This did the trick!
Ty! This way is perfect!