[[ Установка cgit (в связке с nginx) ]]

Установка cgit (в связке с nginx)

cgit – веб-интерфейс для системы управления версиями git, написанный на C, что обеспечивает быструю скорость работы, и также имеет удобный интерфейс.

Статья рассказывает об установке и настройки cgit на системе Gentoo Linux с использованием nginx (в качестве веб-сервера).

Установка

Перед установкой убедитесь, что в системе установлен сам git:

emerge dev-util/git -av

Перейдите во временный каталог для сборки:

cd /usr/src

Скачивание последней версии cgit:

git clone git://hjemli.net/pub/git/cgit

Переходим в каталог сборки:

cd /usr/src/cgit # 

Если вы хотите использовать стабильную ветку выполните:

git checkout -b stable origin/stable

Отредактируйте файл Makefile:

nano Makefile

# задайте каталог установки cgit
CGIT_SCRIPT_PATH = /var/www/localhost/htdocs/cgit

Сборка:

git submodule init # инициализация дополнительных модулей
git submodule update 
make # сборка

Если сборка прошла успешно выполним установку:

make install

CGit работает как cgi приложение, но nginx сам не поддерживает выполнение cgi, поэтому устанавливает mini_httpd который будет выполнять cgi:

emerge www-servers/mini_httpd

Редактирует конфигурацию:

nano /etc/conf.d/mini_httpd

# Заменяем на путь установки cgit
MINI_HTTPD_DOCROOT="/var/www/localhost/htdocs/cgit"

# обязательно удалите параметр -r
# задайте в параметре -u имя пользователя которому разрушен доступ на чтение к репозиториям git
MINI_HTTPD_OPTS="-p 8080 -u git -i /var/run/mini_httpd.pid -l /var/log/mini_httpd.log -d ${MINI_HTTPD_DOCROOT}"

# это строчка разрешает выполнение cgi
MINI_HTTPD_OPTS="$MINI_HTTPD_OPTS -c **.cgi"

Редактирование конфигурации nginx:

в конфигурации хостов

server {
        listen  *:80;

        # замените git.server на имя вашего сервера
        server_name     git.server; 

        root /var/www/localhost/htdocs/cgit;

        rewrite ^/$ /cgit.cgi last;

        location /cgit.cgi {
                proxy_pass      http://127.0.0.1:8080;
        }
}

Редактирование конфигурации cgit. Создайте файл /etc/cgitrc:

nano /etc/cgitrc

# cgit config

# Enable caching of up to 1000 output entriess
cache-size=1000

# Specify some default clone prefixes
#clone-prefix=git://foobar.com ssh://foobar.com/pub/git http://foobar.com/git

# Specify the css url
css=/cgit.css

# Show extra links for each repository on the index page
enable-index-links=1

# Show number of affected files per commit on the log pages
enable-log-filecount=1

# Show number of added/removed lines per commit on the log pages
enable-log-linecount=1

# Add a cgit favicon
#favicon=/favicon.ico

# Use a custom logo
#logo=/img/mylogo.png

# Enable statistics per week, month and quarter
max-stats=quarter

# Set the title and heading of the repository index page
root-title=git.my git repositories

# Set a subheading for the repository index page
root-desc=tracking the my development

# Include some more info about foobar.com on the index page
#root-readme=/var/www/htdocs/about.html

# Allow download of tar.gz, tar.bz2 and zip-files
snapshots=tar.gz tar.bz2 zip

##
## List of repositories.
## PS: Any repositories listed when repo.group is unset will not be
##     displayed under a group heading
## PPS: This list could be kept in a different file (e.g. '/etc/cgitrepos')
##      and included like this:
##        include=/etc/cgitrepos
##

repo.url=my-project
repo.path=/pub/git/my-project.git
repo.desc=the my-project repository
repo.owner=YOU@EMAIL.COM
repo.readme=info/web/about.html

# The next repositories will be displayed under the 'extras' heading
#repo.group=extras
#
#repo.url=baz
#repo.path=/pub/git/baz.git
#repo.desc=a set of extensions for bar users
#
#repo.url=wiz
#repo.path=/pub/git/wiz.git
#repo.desc=the wizard of foo

# Disable adhoc downloads of this repo
repo.snapshots=0

# Disable line-counts for this repo
repo.enable-log-linecount=0

# Restrict the max statistics period for this repo
repo.max-stats=month

Создание папки кэша cgit:

mkdir /var/cache/cgit/
# сделайте её владельцем пользователя под которым запускается mini_httpd
chown git:git /var/cache/cgit/

Запуск:

/etc/init.d/mini_httpd start
/etc/init.d/nginx start

Обсуждение

Fd, 2009/08/24 09:18

всё хорошо, только зачем городить огород из костылей в виде mini_httpd, если есть прекрасное под названием fcgiwrap? http://nginx.localdomain.pl/wiki/FcgiWrap

Ваш комментарий. Вики-синтаксис разрешён:
112 +6 = 
 
howto/cgit_install.txt · Последнее изменение: 2022/08/31 14:53 — 127.0.0.1
Gentoo Linux Gentoo Linux Driven by DokuWiki