What are the best or most ideal Linux Permissions for Wordpress

Hello Support, I'm not sure if this is the best place to put this question (if not please move it), but I'm hoping that someone is able to provide some guidance on the best practices when using Wordpress on an ubuntu linux server.

I currently have several websites on a single VPS server running Ubuntu 14.

Currently all the permissions are set to user www-data and group www-data, with folder permissions are 755 and file permissions set as 644.

I am wanting to change the user to something other than www-data, as an example: myuser

So all WordPress files and folders will have the permissions of myuser:www-data

Doing this with WordPress is easy enough, however since this is WordPress as far as I can see I then need to alter the permissions for specific wordpress files / folder to make sure the user can access / write to them.

This is what I have so far...

1	find /var/www/mywebsite.com/wp-content/uploads -type d -exec sudo chmod 775 {} \;
2	find /var/www/mywebsite.com/wp-content/upgrade -type d -exec sudo chmod 775 {} \;
3	find /var/www/mywebsite.com/wp-content/themes -type d -exec sudo chmod 775 {} \;
4	find /var/www/mywebsite.com/wp-content/plugins -type d -exec sudo chmod 775 {} \;
5	 
6	find /var/www/mywebsite.com/wp-content/uploads -type f -exec sudo chmod 664 {} \;
7	find /var/www/mywebsite.com/wp-content/upgrade -type f -exec sudo chmod 664 {} \;
8	find /var/www/mywebsite.com/wp-content/themes -type f -exec sudo chmod 664 {} \;
9	find /var/www/mywebsite.com/wp-content/plugins -type f -exec sudo chmod 664 {} \;

From here, everything looks great until I try to upload an image through WordPress, and I receive a

HTTP Error

So, I make the group writeable, g+w and everything works as it should.

I then come to automatically update my plugins and it is now asking for FTP information. This is where I am now lost.

I've tried search online for the best solution, or the most appropriate permission setup for WordPress on linux when wanting to change the user from www-data to something different, and though there are many articles are there, I've come up short as to what is the best practice for wordpress, and making sure the site works as it does when using www-data as the user.

Any help or advice would be very much appreciated, and any guidance on using different user, while keeping my sites secure.

Many thanks,
Kriss

  • Rupok

    Hi Kriss

    Hope you had a wonderful day.

    I am wanting to change the user to something other than www-data, as an example: myuser

    You have to create new apache user for doing this. You will get idea about how you can create new apache user from this link: http://ubuntuforums.org/showthread.php?t=927142

    Your permission command seems ok to me but you don't need to explicitly change permission for specific folders. You can run the command for all files recursively in your website root directory. WordPress suggests all directories should be 755 or 750 and all files should be 644 or 640. So running the command for root directory recursively is suggested.

    Currently all the permissions are set to user www-data and group www-data, with folder permissions are 755 and file permissions set as 644

    If this is the scenario, then uploading should not want FTP details. I could tell you better if I could see the current configuration. Can you please send me message with SSH access credentials through our secure contact form here: https://premium.wpmudev.org/contact/

    Subject: "Attn: Rupok"
    - SSH User
    - SSH Password
    - IP Address of your Server
    - Link back to this thread for reference
    - Any other relevant URLs

    Select "I have a different question" for your topic. This and the subject line ensure that it gets assigned to me.

    I'm looking forward to hear from you and resolve this issue as soon as possible.

    Have a nice day. Cheers!

  • LDI IT

    Hi Rupok, thank you for your reply.

    Apologies for any confusion in my last post, currently I'm using www-data:www-data and the permissions are set at 644 / 755 and everything is working perfectly. No problems there.

    It is when I change the user over to someone else other than www-data, WordPress seems to need a lot of configuring in terms of permissions etc.

    I have created a new user on the server and added the new user to the www-data group. I've given the group write permissions, but still when I come to automatically updating plugins, wordpress throws up that it needs FTP details to connect.

    As far as I can tell, the permission are set correctly. The website works as it should, and I'm able to upload images etc through the site, but when it comes to updating I can't do this automatically.

    Any ideas or help would be great

    Again thanks for your help.

  • Nithin

    Hi Kriss,

    I have created a new user on the server and added the new user to the www-data group. I've given the group write permissions, but still when I come to automatically updating plugins, wordpress throws up that it needs FTP details to connect.

    This sounds right to me, WordPress only asks FTP connection details if the user doesn't have correct ownership, since the user belongs to a group that has write access, it should work. Can you check this link and see whether this helps.

    It has to be about having a correct permission or ownership. If you still have problem, it would be much easier if we can check your configuration, as mentioned by Rupok, if possible please provide your credentials as directed above.

    Best Regards,
    Nithin

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.