I'm installing my website on a new hosting company. All WordPress directories are chmod to 775 and the owner (plus group) is my account username, the same owner as when I create new files manually.

Files created by a a non WordPress related PHP script gets another owner ID, I'm guessing that's the webbserver? If I manually create a file and want the same script to write in that I also get this permission denied. Should the WordPress installation have the webbserver owner? Can I change this?

On a side note, WordPress also asks for FTP credentials every time a new theme installs or a plugin updates. If I specify define( 'FS_METHOD', 'direct' ); I get "Installation failed: Could not create directory." instead.

This is the full message:

Warning: file_put_contents(/home/vhosts/www.website.com/wordpress/wp-content/plugins/myplugin/logfile.log): failed to open stream: Permission denied in /home/vhosts/www.website.com/wordpress/wp-content/plugins/myplugin/myplugin.php on line 24
  • It seems that I even have to put 644 for the wp-config.php file and 777 on all directories to get it to work. After looking around it doesn't seem that SSH access is possible.
    – BootUp
    Feb 13, 2019 at 18:51

1 Answer 1

  • All files should be owned by the actual user's account, not the user account used for the httpd process.
  • Group ownership is irrelevant unless there are specific group requirements for the web-server process permissions checking. This is not usually the case.
  • All directories should be 755 or 750.
  • All files should be 644 or 640. Exception: wp-config.php should be 440 or 400 to prevent other users on the server from reading it.
  • No directories should ever be given 777, even upload directories. Since the PHP process is running as the owner of the files, it gets the owners permissions and can write to even a 755 directory.

You can use

chown www-data:www-data  -R * 
find . -type d -exec chmod 755 {} \;  
find . -type f -exec chmod 644 {} \;  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.