20

Fresh LAMP server setup with Ubuntu 12.04 and VSFTPD.

I'm trying to access the /var/www folder (web root) with FTP user.

I created a new user ftpuser and added it to the www-data user group created automatically by Apache.
Home directory of that user is set to /var/www. I also changed the ownership of the /var/www to www-data group and changed permissions to 02775.

However, I'm still not able to upload files. Error is: "553 Could not create file".

  1. Can someone please explain me how to set these permissions properly?
  2. What is the correct setup? Should I set the home directory of ftpuser to /var/www or somehow diffeerently?

I found a lot of topics on the web but none of them offer a universal solution.

Thank you!


UPDATE:

Here is the output of ls -l of /var/www:

drwxr-sr-x 3 root ftpuser 4096

Content of vsftpd.conf file:

listen=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
chown_uploads=YES
chown_username=ftpuser
chroot_local_user=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
3
  • I have the same problem, did you find out anything? May 12, 2013 at 10:21
  • Unfortunately no - I gave up and started using git for pushing the code for all projects on that server. It is a dev/testing server only.. May 13, 2013 at 8:39
  • After some time, I ended up in the same situation on a new server, and Amin Y's answer was the right thing. Permissions were wrong and forcing them again on the folder fixed the issue. May 14, 2014 at 14:10

3 Answers 3

19

The problem is because your folder is owned by root, instead of ftpuser.

To fix it run:

sudo chown -R ftpuser:nogroup /var/www/ftuuserfolder
0
2

I found I had set the correct ownership, but not the correct permissions.


If your folder is owned by the user 'ftpuser' and group 'www-data' for example, like...

drwxr-sr-x 3 ftpuser www-data 4096

Then you probably haven't run...

sudo chmod -R g+w /var/www/ftpuserfolder

Which gives write permission to the group that owns those files/folders.

0

For me nothing worked. I figured out that the initial directory in my FTP Client was set to nothing, so it tried to access the linux root directory. I was letting it empty first, because I thought it will pick the users home directory.

I had to specify the full path to the project.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .