Skip to content

Instantly share code, notes, and snippets.

@lajlev
Created January 3, 2014 10:41
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save lajlev/8236014 to your computer and use it in GitHub Desktop.
Save lajlev/8236014 to your computer and use it in GitHub Desktop.
Set Wordpress file permissions an FS method on localhost

Set Wordpress file permissions and FS method on localhost

On Mac OS X (Leopard), the Apache HTTP Server runs under the user account, _www which belongs to the group _www. To allow WordPress to configure wp-config.php during installation, update files during upgrades, and update the .htaccess file for pretty permalinks, give the server write permission on the files.

One way to do this is to change the owner of the wordpress directory and its contents to _www. Keep the group as staff, a group to which your user account belongs and give write permissions to the group.

Step 1

$ cd /<wherever>/Sites/<thesite>
$ sudo chown -R _www wordpress
$ sudo chmod -R g+w wordpress

This way, the WordPress directories have a permission level of 775 and files have a permission level of 664. No file nor directory is world-writeable.

Step 2

Add this to your wp-config.php

define('FS_METHOD', 'direct');
@chrisharrisonkiwi
Copy link

Great thanks for this, just for those running on linux/ubuntu, note the user wont be _www
Also, you can run these commands from the root of your project:

sudo chown -R www-data .
sudo chmod -R g+w .

@totallytotallyamazing
Copy link

Great thank you as well! For those running Mac 0S 10.8 (Mountain Lion):
Step 1
sudo cd /wherever/Sites/wordpress
sudo chmod -R _www /wherever/Sites/wordpress
sudo chmod -R _www /wherever/Sites/wordpress

for me localhost is /Library/WebServer/Documents/Sites/wordpress which is typical for Apache running in OS 10.8

then the same Step 2 as above
and add this to the end of your wp-config.php
define('FS_METHOD', 'direct');

@AElMehdi
Copy link

Thanks! That was helpful! 🙏

@rajeevbohan
Copy link

Hi all,

Can I just leave
define('FS_METHOD', 'direct');
this piece of code in my wp-config.php forever ?
will it attract any security issues?

is there anyway i can bypass this step ?

@lajlev
Copy link
Author

lajlev commented Sep 9, 2020

@rajeevbohan I don't see any security issues to do it on localhost, but would do it in production.

@JollyWizard
Copy link

If you have access to the wp cli command, you can use this command to avoid manually editing the wp-config.php file.

wp config set --add FS_METHOD direct

@rajeevbohan
Copy link

Thanks lajlev and JollyWizard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment