FTP open for write: permission denied

January 2, 2015 12.7k views

I'm new to linux. I have followed v.helpful on-line tutorials to setup CentosOS 6.5, and I have successfully installed LAMP server, SSH and vsftp.

I have setup a second user with the same privileges as root and I can access the droplet via FTP (with FileZilla) as that new user and successfully download a file *but * I can't upload any file - whether a new file or an edited version of an existing file. I've been trying a simple upload to "/var/www/html" where the owner=root and the group=root.

The error message is:
Error: /var/www/html/index.php: open for write: permission denied
Error: File transfer failed

I'm sure it is something simple; Any assistance gratefully received.


1 comment
  • Update: my second user is 'ted'. I CAN upload into /home/ted.

    I've edited the sudoers file for "ted ALL =(ALL) ALL", as well as the other typical file edits.

    I "thought" that this would give me all the same rights (including file permissions) as root. Clearly not, but surely I don't have to chown all the existing folders and files to ted as well?

    Still wondering


1 Answer

Giving the ted user sudo privileges will allow it to execute commands as root, but it will not effect what files it can access over FTP. FTP is only concerned about the user/group that owns the file.

Normally the Apache web root on a CentOS server will be owned by the apache user not the root user. Adding the ted user to the apache group and granting write ACLs to the folder should allow it to access files in that directory over FTP.

chown -R  apache:apache /var/www/html/
sudo usermod -a -G ted apache
sudo setfacl -R -m u:ted:rwx /var/www/html
  • I came across same issue. Tried following commands and came across the error followed:

    chown -R apache:apache /var/www/html/beta/
    *error1 - chown: invalid user: ‘apache:apache’
    sudo usermod -a -G myUser apache
    *error2 - usermod: user 'apache' does not exist
    sudo setfacl -R -m u:myUser:rwx /var/www/html/beta
    *error3 - The program 'setfacl' is currently not installed. You can install it by typing:
    apt-get install acl

    I ignored error1 and error2 and installed acl: apt-get install acl.
    Then I checked the permission of myUser for editing files through ftp. Still does not work.

    Could you please let me know what I should do?

    • Judging by the mention of apt-get, you are not running CentOS like the original poster. On Ubuntu and Debian, the Apache process is run by the www-data user not apache.

Have another answer? Share your knowledge.