<Directory "/opt/gitlab-7.8.1-0/apps/gitlab/htdocs/public">
Options -MultiViews
AllowOverride All
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.3>
Require all granted
</IfVersion>
SetEnv RAILS_RELATIVE_URL_ROOT "/gitlab"
PassengerEnabled on
PassengerAppRoot "/opt/gitlab-7.8.1-0/apps/gitlab/htdocs/"
<IfModule pagespeed_module>
ModPagespeedDisallow "*"
</IfModule>
PassengerUser git
PassengerGroup git
SetEnv MAGIC "/opt/gitlab-7.8.1-0/ruby/lib/ruby/gems/2.0.0/gems/charlock_holmes-0.6.9.4/ext/charlock_holmes/src/file-5.08/magic/magic.mgc"
SetEnv PATH "/opt/gitlab-7.8.1-0/Python/bin:${PATH}"
</Directory>
PassengerPreStart :80/gitlab
不同之处在于:
SetEnv RAILS_RELATIVE_URL_ROOT "/gitlab"
PassengerPreStart :80/gitlab
4.5 config.yml
...
gitlab_url: :80/gitlab/
...
这样我们访问gitlab就是按照下面的地址:
5 主机nginx配置
上面的配置都是在vm-gitlab上进行的,注意打开80:http端口。下面要给主机nginx增加配置,配置文件:
/etc/nginx/conf.d/redmine.conf
内容如下(我同时还提供了redmine服务):
# 指向内网redmine的web服务(192.168.122.21:80)
#
upstream redmine {
server 192.168.122.21:80;
}
upstream gitlab {
server 192.168.122.20:80;
}
server {
server_name pepstack.com;
# /var/log/nginx 本地目录必须存在
access_log /var/log/nginx/redmine_access.log;
error_log /var/log/nginx/redmine_error.log;
location /redmine {
try_files $uri @red; # @red 名字是任意的
}
location /gitlab {
try_files $uri @git;
}
location @red {
proxy_set_header Host $host;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_redirect off;
proxy_pass ; # 指向 upstream redmine
}
location @git {
proxy_set_header Host $host;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_redirect off;
proxy_pass ; # 指向 upstream gitlab
}
}
即注释掉:include /etc/nginx/sites-enabled/*;
6 启动服务
大功告成,在主机启动nginx:
$ sudo nginx -s reload
在vm-gitlab启动gitlab:
# cd /opt/gitlab-7.8.1-0/
# ./ctlscript.sh restart
CentOS源码安装GitLab汉化版
在 Ubuntu 12.04 上安装 GitLab
在 CentOS 上部署 GitLab (自托管的Git项目仓库)
在RHEL6/CentOS6/ScientificLinux6上安装GitLab 6.0.2