I have a php script to git pull from my github repository set up in my webservice hook urls like so:

  echo shell_exec('~/git/usr/bin/git pull 2>&1');

When I open this script on the browser, I get this error:

git-remote-https: error while loading shared libraries: libcurl.so.3: cannot open shared object file: No such file or directory

I am on a godaddy server running CentOS release 5.9 and uname -mrs yields:

Linux 2.6.18-348.3.1.el5PAE i686

When I tried doing :

yum install curl

I get an error that the command yum cannot be found.

I seriously have no idea what's going on here because when I ssh into my server and do git pull from the terminal or run the script like php myscript.php, it works fine and all the changes are fetched. How are the dependencies changed when I run it in the browser?

Any help is deeply appreciated.

  • sudo apt-get install libcurl3 – nickanor Jun 9 '13 at 8:42
  • I am on centOS as I mentioned and commands like sudo and apt-get can't be used. Also. because I am on a godaddy shared hosting I don't exactly have the permissions for everything. Thanks again – Vivek Pradhan Jun 11 '13 at 9:57
  • The script is not running git pull, like you said you do in the terminal. Instead, it's looking for the git directory in the "user"'s home directory echo shell_exec('~/git/usr/bin/git pull. Additionally, the PHP script might be executed as different users, depending on your web server's configuration. So, ~ might not be what you expect. – ILMostro_7 May 16 '16 at 10:32
  • As for the yum command missing, this is from within your terminal? If so, there might be some cPanel crap hiding the yum command, or a way to use their scripts to install libcurl. Either way, you're far from using a regular Linux OS. AFAIK, godaddy servers are using cPanel, and that's not supported within this Q&A site. You might also be running "CloudLinux". What's the output of uname -a? – ILMostro_7 May 16 '16 at 10:34
  • Shared hosting with no permissions? Yet you have shell access? I'm assuming you don't have root permissions. You might want to ask your SysAdmin or GoDaddy. – ILMostro_7 May 16 '16 at 10:37

First of all, this is not an Ubuntu-related question, see What topics can I ask about here? – you are asking about PHP script running on CentOS on a shared hosting. Either Unix & Linux, Stack Overflow, Server Fault, or other Stack Exchange sites are better suited for this question.

Anyway, it seems you are somehow using different URLs to pull from GitHub; git-remote-https needs curl for HTTPS access. Use either SSH or Git (Read-Only) protocol, i.e. git@github.com:user/repository.git or git://github.com/user/repository.git; try changing your remote URL or cloning the repository again. Also, make sure that Git is executed in the right directory, for example add cd /my/repo; to the shell_exec command. Also, it's for the best to specify remote branch for automated pulls, i.e. git pull origin master.

It is possible that GoDaddy limits access of PHP scripts to certain libraries – which also affects shell scripts executed within PHP's context. If everything else fails, you may consider polling the remote repository, i.e. execute git pull periodically with Cron.

  • Thanks for guiding me @jnv. I will be more careful the next time I ask questions on stackexchange. curl is already installed on the server. When I try to do git://github.com/user/repository.git, I get an error saying that it could not connect a socket (Connection refused). I have the path of the git binary set up correctly. I think it has something to do with the dependency, may be it's not able to locate curl. All of the scripts are running when I execute them in the terminal after sshing into my server. – Vivek Pradhan Jun 11 '13 at 11:54
  • As far as establishing an ssh connection to the repository hosted on github is concerned. I don't have the permissions to do that. So once I ssh into my server, I cannot successfuly run ssh git@github.com. I get an error saying ssh: Permission denied. So I can only use http or http(s) solutions and I can clone repositories as I mentioed. The php script is not getting executed from the browser. That's the problem and the error I get is already posted in the question. Hope this helps. – Vivek Pradhan Jun 11 '13 at 11:58
  • I see; it's quite a common practice that PHP scripts are executed with different user/group, but it's also possible that shell_exec runs under the same account but doesn't get all environment variables to locate shared libraries for your local installation of git. You could try spawning a full shell from PHP, i.e. executing /bin/bash -lc 'YOUR COMMAND HERE'; also: locate libcurl.so.3 and make sure your Git can access it – check permissions and try making a symlink in ~/git/usr/lib/ or wherever shared libraries for your local git are placed. Also, try Cron as I've noted previously. – jnv Jun 11 '13 at 12:20
  • I tried spawning a full shell from PHP like you suggested but I still get the same error. Also there is no folder called lib where I have git installed. Do you think that's causing the problem? – Vivek Pradhan Jun 14 '13 at 7:20
  • I was just assuming there may be such directory but just because it's missing isn't probably the source of problem – I don't know how exactly did you install Git. Locate the missing library and check its permissions and/or whether PHP process has an access to it. And try polling through Cron. Otherwise I recommend contacting GoDaddy support, hopefuly they know limitations of their system and will be able to help you. – jnv Jun 15 '13 at 18:08
yum install curl

I get an error that the command yum cannot be found

Are you root? Is is possible that your $PATH doesn't contain /sbin:/usr/sbin? Try /sbin/yum and /usr/sbin/yum to make sure that it's not a $PATH issue.

I'm not a CentOS expert, but if you are in fact working as root, and yum is really not installed and working, then your system may be seriously broken. As far as I know, yum is the default package manager of CentOS and should absolutely both exist and work.


That is a very strange path. It looks like you manually extracted the git package into your home directory?

error while loading shared libraries: libcurl.so.3

Well, if you extracted the package manually, it's probably now missing the curl library that the git package depends on. You could try extracting this library too, but just putting it into your home directory won't magically make it work... you will probably need to fiddle with $LD_LIBRARY_PATH to make that work, which in my experience isn't very easy.

If you can get yum working and then use it to install the `git package properly, it would solve this problem for you.

  • Thanks a lot for your reply @Martin. Considering the fact that I haven't been able to resolve the issue yet, I will definitely follow your suggestions and see what I come up with. – Vivek Pradhan Sep 20 '13 at 19:05

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.