Aug 10, 2011
tom

How do you give execute permissions to Apache2 user and NOT to everyone else?

Question

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?

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.

Related posts:

  1. Apache doesn’t honor my file’s permissions?
  2. How to give PHP permissions to write to files without globally opening up permissions to the directory
  3. Copy a file’s owner permissions to group permissions
  4. Setting umask for www-data user (run via sudo) on Ubuntu 10.04 LTS
  5. phusion passenger, apache2 only works with www

Leave a comment