Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a LXC container on my Debian system. I want to setup a public Git server on it so that it's accessible to other people. How can I do this?

UPDATE #1

Link to apache2.conf: http://pastebin.com/Nvh4SsSH.

share|improve this question
    
Checkout gitlab or gitorious. Not only are they easy to setup, they give you 'github' like features (pull requests ect...) –  spuder Aug 10 '13 at 15:12

1 Answer 1

up vote 3 down vote accepted

Give this Howto a look. It's a little dated but should have the general steps you need to setup a Git server. The howto is titled: How To Install A Public Git Repository On A Debian Server.

General steps

  1. Install git + gitweb

    $ sudo apt-get install git-core gitweb
    
  2. Setup gitweb directories

    $ sudo mkdir /var/www/git
    $ [ -d "/var/cache/git" ] || sudo mkdir /var/cache/git
    
  3. Setup gitweb's Apache config

    $ sudo vim /etc/apache2/conf.d/git
    

    contents of file:

    <Directory /var/www/git>
       Allow from all
       AllowOverride all
       Order allow,deny
       Options ExecCGI
       <Files gitweb.cgi>
       SetHandler cgi-script
        </Files>
     </Directory>
    DirectoryIndex gitweb.cgi
    SetEnv  GITWEB_CONFIG  /etc/gitweb.conf
    
  4. Copy gitweb files to Apache

    $ sudo mv /usr/share/gitweb/* /var/www/git
    $ sudo mv /usr/lib/cgi-bin/gitweb.cgi /var/www/git
    
  5. Setup gitweb.conf

    $ sudo vim /etc/gitweb.conf
    

    Contents of gitweb.conf:

    $projectroot = '/var/cache/git/';
    $git_temp = "/tmp";
    #$home_link = $my_uri || "/";
    $home_text = "indextext.html";
    $projects_list = $projectroot;
    $stylesheet = "/git/gitweb.css";
    $logo = "/git/git-logo.png";
    $favicon = "/git/git-favicon.png";
    
  6. Reload/Restart Apache

    $ sudo /etc/init.d/apache2 reload
    
  7. Setup Git Repository

    $ mkdir -p /var/cache/git/project.git && cd project.git
    $ git init
    
  8. Configure Repository

    $ echo "Short project's description" > .git/description
    $ git config --global user.name "Your Name"
    $ git config --global user.email "you@example.com"
    $ git commit -a
    $ cd /var/cache/git/project.git && touch .git/git-daemon-export-ok
    
  9. Start Git Daemon

    $ git daemon --base-path=/var/cache/git --detach --syslog --export-all
    
  10. Test clone the Repository (from a secondary machine)

    $ git clone git://server/project.git project
    

Adding additional Repos + Users

To add more repos simply repeat steps #7 - #9. To add users just create Unix accounts for each additional user.

share|improve this answer
    
Thanks a lot except step 6 everything work fine but in step 10 it gives Cloning into 'project'... warning: You appear to have cloned an empty repository. I think that's because there nothing in my clone –  Sumit Rathore Aug 8 '13 at 7:33
    
@SumitRathore - correct there isn't anything in the repo as of yet. –  slm Aug 8 '13 at 7:34
    
Can you tell me how to add more users and projects in my newly created server? –  Sumit Rathore Aug 8 '13 at 7:34
    
no both commands does not work service httpd restart gives httpd: unrecognized service and /etc/init.d/apache2 restart gives apache2: Syntax error on line 265 of /etc/apache2/apache2.conf: Syntax error on line 9 of /etc/apache2/conf.d/git: </Directory> without matching <Directory> section Action 'configtest' failed. The Apache error log may have more information. failed! –  Sumit Rathore Aug 8 '13 at 8:10
2  
@SumitRathore - good luck. If you get stuck feel free to ask another question. –  slm Aug 9 '13 at 7:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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