tiistai 28. huhtikuuta 2015

Update Wordpress and file permissions under Linux

To update Wordpress without FTP, install plugins and upload media do the following:

Insert to Wordpress config.php file this line: define('FS_METHOD','direct');

Then set under wp-content folder plugins and uploads folder to user www-data

chown www-data plugins
chown www-data uploads



The left one in permissions list is user and on the right group.

TO UPDATE you need to give www-data access for a short time. So do sudo chown www-data wordpress/ -R then update, and after that give access back to your user.


Setting the folder upgrade for www-data should allow upgrading, but unfortunately I couldn't test this. Using chomd 777 -R for the whole wordpress folder allows updating, but that is not a good idea.

Wordpress defaults are 755 for folders, and 644 for files. To set things back use chmod 755 -R and then find:

To recursively give directories read&execute privileges:
find /path/to/base/dir -type d -exec chmod 755 {} +
To recursively give files read privileges:
find /path/to/base/dir -type f -exec chmod 644 {} +

Or, if there are many objects to process:
chmod 755 $(find /path/to/base/dir -type d)
chmod 644 $(find /path/to/base/dir -type f)

Or, to reduce chmod spawning:
find /path/to/base/dir -type d -print0 | xargs -0 chmod 755 
find /path/to/base/dir -type f -print0 | xargs -0 chmod 644

Ei kommentteja:

Lähetä kommentti