Motivation:
- You have a WordPress instance on Ubuntu Nginx.
- You want to ensure that only the Nginx process can access WordPress files.
Procedure:
- View current file owner and group:
ls -l /var/html
The root folder should be owned by www-data user. www-data is the user that web servers like Apache and Nginx on Ubuntu use by default for their normal operation.
2. Change file owner and group to www-data if necessary:
sudo chown -R www-data:www-data /var/html
3. Set minimum permissions for folders:
cd /var/html
sudo find . -type d -exec chmod 755 {} \; # directory permissions rwxr-xr-x
4. Set minimum permissions for files:
cd /var/html
sudo find . -type f -exec chmod 644 {} \; # file permissions rw-r--r--
5. Verify the changes:
ls -l /var/html
(Visited 11 times, 1 visits today)