I have Ubuntu Server running and I am setting up a separate directory as a cgi-bin. I have the directory ready and I changed the file for the site. However, to get it to work, I need to change the permissions of the Python script I have in the folder so that Apache can execute it. However, I don't want to give write or execute access to ANYONE other than root, me and Apache. I'm assuming this is possible, but how can it be done?
That sets it so only the www-data user and group can write the file, and only the www-data user can execute the file, everyone can read.
Two ways jump to mind. First, you could create a group with you, root and apache in it and change the group ownership of cgi-bin to that:
Alternatively, you could use ACLs to just add execute permissions for apache:
This will allow apache to execute any file under cgi-bin, but you'll need to have ACLs enabled on the filesystem and they're sometimes easy to miss when looking at files and directories.
You can enable ACLs by modifying your filesystem defaults and remounting the filesystem:
A file or directory with an ACL attached will have a + at the end of the ownership mode in the output of