Question

Problem with WordPress file permissions

Posted February 6, 2020 1.1k views
Linux BasicsUbuntu

Hello gentlemen, ever since we moved our site to digital ocean we have issues with our site media library. We are using a premade image, running ubuntu on cyberportal with openlitespeed on it.

Our root www folder is /home/sitename/public_html/ and everything inside that is set to be under www-data ownership (we tried different options as well). While the whole dir is owned by www-data our media library can’t be updated and wordpress triggers the error (can’t move file to the folder, etc).

Even worse, site library can access all of the existing media (the ones that we moved manually) and display them properly, but all of the newly updated/crated posts and media won’t show properly. It looks like while posting something the media/file is saved but then it gets removed from a featured image (for example) and its thumbnail is broken. We can access the image through a direct link.

I tried everything I could find, from scripts to fix the permissions, through cyberpanel fix permissions and ssh but everything failed. Does anyone have any clue what this could be? Again, only images uploaded now are broken, not the ones that are there already.

Please advice

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
4 answers

Hello,

Sometimes incorrect file permissions may prevent you from doing the following:

  • Install or update themes and plugins
  • Move articles or pages to the trash
  • Upload files to your media library

The best way to organize permissions is to use FTP. After connecting to the server, select wp-admin,wp-includes,and wp-content. Right-click on them and select File Permissions:

In the window that appears, set Value to 755. Select recursively into subdirectories and apply only to directories. Repeat the process, but set the Value to 644, then choose to recurse into subdirectories and apply only to files:

Then, select the remaining files in public_html.Right-click on them and select File Permissions again. The value should be 644 again, but don’t worry about other settings.That is to say, the general permission of the file directory is 755, and the file permission is generally 644.

I am sorry that I have just used WordPress for a short while.If my suggestion doesn’t work,please wait for others’ awesome resolution.Go to forums connect to WordPress may helps you.

Best wishes.

Shiroka

Hi

CyberPanel did not used www-data by default. You can check the right owner from ls /home/DOMAIN from console. Or just upload files from file manager inside of the CyberPanel.

Best,
Eric

Unfortunately, that didn’t do the trick either. I tried fixing that (with the actual username - chown), but didn’t work.

Hello, @vladimir4899b75110bc126aca

Have you tried fixing the file and folder permissions via ssh as well? You can navigate to the folder where your WordPress site is hosted (the public_html directory) and then execute the command:

find . -type d -exec chmod 755 {} \; && find . -type f -exec chmod 644 {} \;

This will change the permissions of all folders to 755 and set the file permissions to 644.

I will recommend you to upload a file and then check the file’s permissions right after it’s been uploaded as this will help you to determinate if the issue is with the permissions itself or something else is causing the issue for you.

Also via ssh you can easily check and modify the ownership of all the directories and files as well.

Let me know how it goes.

Regards,
Alex

Submit an Answer