Skip to main content

Directory Permission

The "Permission denied" error you're encountering indicates that the user running the Gitea service does not have sufficient permissions to create directories or files in the specified location (/data/gitea/log). This issue typically occurs due to incorrect file or directory permissions.

To resolve this issue, follow these steps:

Option 1: Adjust Directory Ownership and Permissions

  1. Check Current Ownership and Permissions: First, verify the current ownership and permissions of the /data/gitea directory and its subdirectories:

    ls -ld /data/gitea
    ls -l /data/gitea/log
    
  2. Change Ownership to Gitea User: If Gitea is running under a specific user (e.g., gitea), change the ownership of the directory and its contents to this user:

    sudo chown -R gitea:gitea /data/gitea
    
  3. Adjust Permissions: Set appropriate permissions to allow the gitea user (or the user running Gitea) to read, write, and execute in the directories:

    sudo chmod -R 755 /data/gitea
    
  4. Retry Gitea Operations: Restart or retry the operation that caused the permission denied error in Gitea.

Option 2: Use ACLs (Access Control Lists)

If you need more granular permissions control, you can use ACLs to grant specific permissions to the Gitea user:

  1. Install ACL Package (if not already installed):

    sudo apt update
    sudo apt install acl
    
  2. Set ACLs on the Directory:

    sudo setfacl -R -m u:gitea:rwx /data/gitea
    sudo setfacl -d -R -m u:gitea:rwx /data/gitea
    

    This command grants read, write, and execute permissions recursively (-R) to the gitea user (u:gitea:rwx) on /data/gitea and sets the default ACL (-d) so that any new files or directories inherit these permissions.

  3. Verify ACLs: Check the ACLs to ensure they are correctly applied:

    getfacl /data/gitea
    
  4. Retry Gitea Operations: Restart or retry the operation that caused the permission denied error in Gitea.

Additional Considerations

  • SELinux or AppArmor: If your system uses SELinux or AppArmor, ensure that their policies allow Gitea to access the necessary directories.
  • Gitea Configuration: Double-check the configuration files (app.ini or similar) to ensure they are correctly pointing to /data/gitea/log for logging.

By following these steps, you should be able to resolve the "Permission denied" issue for Gitea and allow it to create directories and files as required. Adjust the ownership, permissions, or ACLs according to your specific security and access requirements.