Linux – Apache directory permissions for a company intranet

apache-http-serverlinuxpermissions

I have a company intranet that I have recently migrated from Novell to Linux. I am trying to set up user permissions and I am losing my mind.

There are a couple dozen departments, each with a dedicated directory in the web root.
There are also shared directories for css, templates, images, etc.

I want all users to have read-only access to the entire site and read-write access only to their department's directory.

What I have already tried:

  • Set up a user group for each directory and assigned users to the groups as needed. Running into permissions and ownership inheritance issues.

  • Created a test user and then created an htdocs folder in test user's home directory. Then created a link, renamed it to the dept. name, and dropped the link into the main htdocs directory. Read access is perfect but I cannot list the contents of that directory when using Dreamweaver or an FTP client from the htdocs root.

I feel that there is some simple-but-crucial piece of info I am missing. Selectively setting up read-write access to htdocs subdirectories cannot possibly be this difficult.

Any advice for a non-experienced user, used to Novell and IIS?

Best Answer

Let's say you have Sue & Sam in Sales and Harry and Hermione in HR.

  • Create users sue, sam, harry, hermione
  • Create groups hr and sales.
  • Add sue & sam to group sales.
  • Add harry and hermione to group hr.
  • create folders hr and sales in /var/www/htdocs
  • change group of folder hr to group hr
  • ditto sales
  • set the group bit so files created in sales & hr inherit group
  • set permissions so group can write, others can only read
  • for convenience, create a softlink to hr from hermione and harry's home directories
  • ditto sales folk.
  • edit Apache config as needed (e.g. name based virtual server for sales.example.com)

Useful commands (see man pages)

  • mkdir
  • chown
  • chgrp
  • groupadd
  • useradd
  • groupmod
  • ln

† or wherever Apache's docroot is

Related Question