0

OS - Ubuntu 14.04 Well I am working on deployment using GIT webhooks for it. I havea added the deployment keys to git repo and now I want to trigger the git pull origin master command when a push happens from my local repo. This is the test.php file I call via browser.

<?php       
    //echo "THis is a test file on a test repo for testing the deploy functionality using github webhooks!!!!";
    echo exec('whoami');
    echo exec('sh -x /var/www/iq/deploy-test/git.sh');
?>

the shell file

#!/bin/bash
cd /var/www/proj-dir/deploy-test
git pull origin master

When I run this on terminal using

php test.php I get the correct result as expected

 ubuntu From github.com:repo/test
 * branch            master     -> FETCH_HEAD
 Already up-to-date.

ubuntu for whoami and the git pull output.

Now heres the issue when I call the same http://example.com/test.php on browser it shows the user or whoami output as www-data,which is apache user,but I tried updating the permissions of the php file to execute and changing the user to www-data but did not work.
What updates do I need to make so the file works via browser request?

If I need to update the sudoers file what should be the updates?

10
  • how can I fix it? apache. conf?
    – KillABug
    Aug 20, 2015 at 8:34
  • if calls for exec were blocked then whoami should not work right? @muru
    – KillABug
    Aug 20, 2015 at 10:36
  • hmm, yes. Do the Apache logs indicate anything?
    – muru
    Aug 20, 2015 at 10:43
  • Please make sure you have the correct access rights and the repository exists. + cd /var/www/proj/deploy-test + git pull origin master Host key verification failed. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. But when I run it via terminal(php test.php) it works fine.
    – KillABug
    Aug 20, 2015 at 10:57
  • "Host key verification failed" - if you're using Git over SSH, the web server a) won't have the Git server in it's known_hosts, and b) won't have access to your private key for authentication.
    – muru
    Aug 20, 2015 at 11:28

1 Answer 1

1

I got it working.In my case,I was missing the authorized_keys and the known_hosts files in my www-data users root folder.I added .ssh folder under /var/www/.ssh. I previously only moved the ssh key files hence I faced the issue for not able to connect to the git repository over http.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.