[Solved] Correct file and folder permissions for WordPress in Ubuntu

   RSS

1
Topic starter

What should be the correct File and Folder permissions while setting up WordPress in Ubuntu?

This topic was modified 2 years ago by CodeWithBishal-admin
1 Answer
1
Topic starter

This tutorial is valid for:

  • Ubuntu 18.04 LTS
  • Ubuntu 20.04 LTS
  • Ubuntu 22.04 LTS

Configuring the WordPress directory

A very important step before setting up your WordPress in your ubuntu VM is that you need to set the correct permission for some of the folders so that you don't run into any permission errors.

The www-data user and group should first be given ownership of all files. The Apache web server is started as this user, and in order to serve the website and carry out automated updates, Apache must be allowed to read and write to WordPress files.

The chown command lets you modify the file ownership, Be sure to point to your server’s relevant directory:

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

Here wordpress is the directory where you have the WordPress setup files.

To correctly configure the permissions on the WordPress folders and files, run two find commands after that. The first find command changes the permissions of each directory in the /var/www/<>^wordpress<^> directory to 750:

sudo find /var/www/wordpress/ -type d -exec chmod 750 {} \;

This one finds each file within the directory and sets their permissions to 640:

sudo find /var/www/wordpress/ -type f -exec chmod 640 {} \;

With these permissions, you should be able to use WordPress effectively.

 

This post was modified 2 years ago 2 times by CodeWithBishal-admin