Home - Search - Site Map - Site Graph | Contact

( Last Modified: 2009 October 04th )

Install Git

< More Git Notes

Here are a few php scripts for building installing Git and Gitweb from source.

Note that Git is no longer dependent on libcurl so that the NO_CURL=1 option is no longer needed.

Using PHP scripts also means you can install Git without SSH access to your webhost.

execWithOutput.php

<?php
function execWithOutput( $cmd ) {

echo "Command: " . $cmd . "<br/>";

exec($cmd, $output, $return_var);

echo "Status:" . $return_var . "<br/>";

foreach ( $output as $line ) {
echo $line . "<br/>";
}
echo "<br/>";

return $return_var;
}

?>

A php file to install git. Upload this file (along with execWithOutput.php) to a private location on your web server and navigate to it in your broswer to execute the script.

installGit.php:

<?php

require_once 'execWithOutput.php';

//echo phpinfo();
echo exec('whoami') . "<br/>";

execWithOutput('cd ~/src/git-1.6.0.2; ls');

$ret = execWithOutput("cd ~/src; tar xvzf git-1.6.0.2.tar.gz");
if ( $ret != 0 ) { exit(0); }

// was : NO_CURL=1, for pre 1.5 versions of git.
$ret = execWithOutput('cd ~/src/git-1.6.0.2; ./configure --prefix=/home/bsharp/packages NO_MMAP=1');
if ( $ret != 0 ) { exit(0); }

$ret = execWithOutput('cd ~/src/git-1.6.0.2; chmod -R u+x *');
if ( $ret != 0 ) { exit(0); }

$ret = execWithOutput('cd ~/src/git-1.6.0.2; make');
if ( $ret != 0 ) { exit(0); }

$ret = execWithOutput('cd ~/src/git-1.6.0.2; make install');
if ( $ret != 0 ) { exit(0); }

execWithOutput('~/packages/bin/git --version');

Done: " . date('Y F dS h:i A') . "<br/>";
?>

A php file to install Gitweb

installGitWeb.php:

<?php
include 'execWithOutput.php';

$projectRoot = "pathToGitProjects folder"; // example: /home/username/git
$bindir = "pathToBinFolder"; //example: "/home/username/packages/bin"

$cmd = "cd ~/src/git-1.6.0.2; make GITWEB_PROJECTROOT=\"" . $projectRoot . "\" \\"

. "bindir=". $bindir . " \\"

. "gitweb/gitweb.cgi";

execWithOutput($cmd);

echo "Done: " . date('Y F dS h:i A') . "<br/>";

?>


References That Helped me:

Hosting Git on Dreamhost: http://craigjolicoeur.com/2008/04/hosting-git-repositories-on-dreamhost/