Search code examples
web-hostinghttp-status-code-403permission-deniedchown

I cannot set use chown and change permission to www-data :www-data


I'm confused about those file permissions.now my website is suffering a forbidden access when i try to get access from the url. and I find out that the ownership in my FTP is set to myusername/myusername, and I was told to set it to www-data:www-data in order for public to view your website. I tried the following command

chown -R www-data:www-data /public_html

And it says

chown: invalid user: `www-data:www-data'

How can i set the file permission to www-data:www-data and what does it mean for setting it to www-data:www-data and what is the different between myusername:www-data


Solution

  • That's the error message you get when you have no www-data user (if the user is okay but the group is bad, it complains about the group):

    pax> chown -R x:x qq.cpp           # Bad user and group
    chown: invalid user: `x:x'
    
    pax> chown -R pax:pax qq.cpp       # Good user and group
    
    pax> chown -R pax:x qq.cpp         # Good user, bad group
    chown: invalid group: `pax:x'
    

    So that'd be the first thing I'd be checking, that the user actually exists:

    grep www-data /etc/passwd
    

    I think you may find that some set-ups have the www-data group, and you're meant to add whatever users that need access to that group. You can certainly create a www-data user and add that to the group but I don't think it's mandatory.


    And, as an aside, this is not setting the permissions, that's done with chmod and is a separate issue. The chown command merely sets up the file ownership (and groupship, for want of a better word).