apache and sftp permissions for wordpress automatic update in ubuntu

It’s my first time trying to set up WordPress or any website on a cloud hosting. I am on Ubuntu server, and WordPress is located in var/www/mydomain/public folder.

What I want to achieve is this: Both WordPress (PHP) and SFTP users can access and modify the same files. And WordPress should be able to do it’s automatic update for plugins, etc.

Read More

This is what I have done so far:

  • I have chmodded this folder to 775 to allow group read/write permissions.
  • I have added apache user (www-data) and SFTP user (suser) both to group wp.
  • I have made wp as the group owner of all files inside the wordpress folder.

What works:

  • I can edit theme and plugin files with WordPress’s built-in theme/plugin editor.

What does not work:

  • WordPress update still asks for the FTP details to carry out the update
  • When I create a new file with SFTP user, it’s permissions will be 644, but they should be 775

What I’ve tried

As far as I understand, the problem lies somewhere with the permissions/umask thing. I know very little about linux so this may be a stupid question with a simple solution, but I have no idea how to fix it.

UPDATE: I did not know that I would have to restart the ssh server. I did it with this command /etc/init.d/ssh restart and after that files created with SFTP have permissions 664 (as they are supposed to)
Also, it seems that Apache has to be restarted as well, with this command: /etc/init.d/apache2 restart

However, WordPress still won’t do automatic update (asks for FTP credentials)

Related posts

Leave a Reply

2 comments

  1. If you’re able to install the SSH2 PHP Module WordPress will then give you the option to upgrade over SFTP.

    In Ubuntu:

    sudo apt-get install libssh2-php
    

    In CentOS (EPEL required):

    sudo yum install php-pecl-ssh2
    
  2. I was trying to do the same thing with WordPress updates, until I realized that WordPress only supports FTP which, confusingly, SFTP is not. From Wikipedia:

    FTPS should not be confused with the SSH File Transfer Protocol
    (SFTP), an incompatible secure file transfer subsystem for the Secure
    Shell (SSH) protocol. It is also different from Secure FTP, the
    practice of tunneling FTP through an SSH connection.

    I’m still trying to figure out if there’s a secure way to do WordPress updates automatically; I don’t know yet whether or not FTPS is truly secure.