Using ProFTP and Wordpress Together in /var/www/

Posted September 14, 2014 9.2k views

I’ve set up a Wordpress installation. I’d like to be able to SFTP into the wp-content directory in Wordpress to create a custom theme by saving files directly to the server in the theme directory.

I followed this SFTP using ProFTPd tutorial and modified a few other things in /etc/proftpd/modules.conf:

  • I set DefaultRoot to /var/www/
  • As I had issues creating files (despite being able to connect and see the structure of /var/www/, I also created a directory configuration directive:
  <Directory /var/www/>

I still had issues creating files or this point and assumed it was a result of some unix permissions issues. I went to the var/www/ directory and entered the following two commands:

  • sudo chown -R username:username *
  • sudo chmod -R 0755 *

At this point, the .htaccess file is still owned by www-data but everything else is owned by my unix username (not root). At this point, I could finally SFTP into my server and post files. Terrific!

…Except… When I use Wordpress at this point, I have trouble installing themes or plugins due, I assume, to (yet again) a unix a permissions issue. The error message I get is Unpacking the package… Could not create directory..

I’m no unix expert but it seems like in order to SFTP files into /var/www/ I need to own the files, but that prevents Wordpress from installing items through its web interface.

Can anyone help me configure things in such a way that things will work whether I manually SFTP or try to install a theme or plugin from Wordpress?

Thank you so much for reading. I hope this explanation was helpful.

1 comment
  • after you upload files via sftp, you may need to change permissions on those files/folders. this command:

    sudo chown -R www-data:www-data /var/www

    should do the trick. …

    Although, I am wondering> why not just use open-ssh server, which comes installed by default on Ubuntu servers.

    Any pros out there that can answer: does proFTPd have some features that do not come with open-ssh?

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.

Submit an Answer
1 answer

Thanks @sierracircle – seems like you’re saying I’d have to manually switch back and forth each time I wanted to switch between SFTP and installing updates via wordpress. That’ll be fine once the project launches, I suppose, but a poor solution while I’m building the site.

I was unaware that open-ssh server would allow me to do this, since searching for ftp in the community did not suggest that I could do this via open-ssh server.

  • There are different ways to tackle that. We need someone who is more expert with permissions to chime in here, but off the top of my head, you could try one of these:

    create a new user who has www-data as their default group. Then log in as that user to upload web-files and such. You would run this command to create a user named webmaster:

    sudo useradd -g www-data webmaster

    and then set a password for webmaster:

    sudo passwd webmaster

    then log in as webmaster to add your files. www-data should be able to access those files and folder since they both share the www-data group.

    Another (hackery) method might be to create a little cronjob that changes permissions on your www folder.


    crontab -e

    then add this to the bottom of your crontab:

    * * * * * chown -R www-data:www-data /var/www

    I am not sure if that is a really secure thing to do, or efficient use of resources, but I run something like that on a media server I have, so when friends add media (music and photos and such), it makes sure the files are set to the correct permissions. It is crude, but it works!