To set the correct permissions for your web projects under the /var/www/html directory, first change the ownership to the Nginx user (www-data) using the chown command. Then, use the find command to set directory permissions to 755, which allows read and execute permissions for the owner, group, and others. For files, set permissions to 644 to ensure that owners can read and write, while group and others have read-only access. This configuration enhances security while maintaining necessary access.
To correctly apply permissions and ownership for your web project, set the ownership of website files to Nginx user www-data, and then adjust directory and file permissions.
Start by changing the owner of all website files using chown command to www-data, giving it access rights as the web server.
Next, set all directories to 755 for execute and read access by owners, group, and others, ensuring only necessary write access where it’s needed.
Finally, set all files to 644 to provide read access, but restrict write access for security, allowing only the owner to modify files.
Collection
[
|
...
]