I try to set up a deployer user for CI with Teamcity. I followed the instructions from this question on ServerFault: What's the best way of handling permissions for apache2's user www-data in /var/www?
The problem is that the Teamcity application is creating directories with 755
permissions and the apache(2.4) can't write in some of them. If I change the permissions to 775
manually, apache can write them.
Here's what I did to set uo the permissions:
- I created a user
teamcity
. - Added
www-data
group to the user as secondary group - Changed the ownership of
/var/www
toroot:www-data
Changed permissions for directories with:
find /var/www -type d -exec chmod 2775 {} +
and for files with:
find /var/www -type f -exec chmod 0664 {} +
- Added
umask 0002
to/etc/profile
Tested:
su teamcity umask >0002 touch testfile ls -l >-rw-rw-r-- 1 teamcity teamcity 0 May 25 10:38 testfile cd /var/www touch testfile ls -l >-rw-rw-r-- 1 teamcity www-data 0 Mai 25 10:42 testfile
For directories its the same. They are rw
for user and group.
After a deployment the permissions of directories and files are 755
and not 775
as expected.
The Teamcity application is started as a service:
start-stop-daemon --start -c teamcity --exec /opt/TeamCity/bin/runAll.sh start
It seems that I missed some detail, but can't find it.
System:
- Debian jessie
- Apache 2.4
- Teamcity 9
Solution:
I changed the startup script for the Teamcity service by adding umask 002
before the startup command.