Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7603761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:44:12+00:00 2026-05-30T23:44:12+00:00

I have a CentOS 6 server set up with git, gitosis, nginx, and php-fpm.

  • 0

I have a CentOS 6 server set up with git, gitosis, nginx, and php-fpm.

With our setup, nginx executes php scripts via php-fpm, which is configured on a per-site basis to run as a specific user for security purposes (i.e. not all under nginx:nginx) since we don’t want the situation where if one site is compromised, all sites are compromised.

Our environment works great, but, when git is involved, php-fpm creates a fundamental issue.

Upon successfully running the following command locally:

$ git push origin

My post-receive hook is run:

#!/bin/sh
GIT_WORK_TREE=/var/www/vhosts/example.com/httpdocs git checkout -f

Normally, this would copy the contents of the repo into the httpdocs folder, however since php-fpm is installed and the directory+files are owned by a specific user, gitosis (or any other non-root user) can not write to the directory. This is made evident by the following error:

remote: error: git checkout-index: unable to create file index.php (Permission denied)

It makes sense, and that is what I would expect. However, I am wondering if there is a way to get around this issue in this specific case? Is there a way I can modify the post-receive hook to run as root (it is currently run by the gitosis user) or in some other fashion in order for it to succeed?

Just to be clear: there are no other problems with the setup, git works fine, nginx/php-fpm work fine, but this is a permissions issue which I am not quite sure how to get around.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T23:44:13+00:00Added an answer on May 30, 2026 at 11:44 pm

    You could use sudo to get the hook to run as user1, user2, user3, or whatever your system needs. You would need to consider the security implications of having the gitosis user able to masquerade as your web users, even if to a limited extent.

    Example recipe

    Given that the post-receive hook runs as user gitorious and assuming your web users are called user1, user2, user3 etc…

    Move your current post-receive hook into /usr/local/sbin/update-user1.sh, or some other suitable place, and make sure it’s executable.

    Add something like these lines to /etc/sudoers:

    gitosis    localhost = (user1) NOPASSWD: /usr/local/sbin/update-user1.sh
    gitosis    localhost = (user2) NOPASSWD: /usr/local/sbin/update-user2.sh
    gitosis    localhost = (user3) NOPASSWD: /usr/local/sbin/update-user3.sh
    ... etc ...
    

    And then your post-receive hook for user1 could become something like:

    #!/bin/sh
    sudo -u user1 /usr/local/sbin/update-user1.sh
    

    Similarly for other users.

    Untested, so please test before implementing!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to install redmine on a Centos server. I already have PHP and
I have php 5.1.6 running on my CentOS 5 server running Apache 2.2.3 I
I have a server which is running CentOS with cpanel/whm. Otherwise, it is pretty
I have a Lighttpd(1.4.28) web server running on Centos 5.3 and PHP 5.3.6 in
I setup a server with gitosis (yum install gitosis (CentOS 6.2)) and configure my
Hi guys I run a busy CentOS webserver (nginx/php-fpm) an to protect it to
I have just installed CentOS, Apache and PHP. When I visit my site http://example.com/myapp/
I have a rackspace cloud where I want to set up LAMP. the server
I have recently installed and activated APC cache on a web server (Centos 5.7,
I have an iphone application that gets data from a set of php files.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.