Linux – How to give execute permissions to Apache2 user and NOT to everyone else

apache-2.2cgilinuxUbuntuuser-permissions

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?

Best Answer

chown the files to whatever your Apache group is called (Usually www-data) and set permissions to only give user/group permissions:

chown -R www-data:www-data /path/to/cgi-bin
chmod -R 764 /path/to/cgi-bin

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.