牛下载:绿色软件官方软件免费下载基地!
所在位置:首页 > 新闻资讯 > centos7安装配置gitlab(使用外部nginx)

centos7安装配置gitlab(使用外部nginx)

发布时间:2020-06-11 21:30:57来源:阅读:

1、安装依赖:

sudo yum install curl policycoreutils openssh-server openssh-clients
sudo systemctl enable sshd
sudo systemctl start sshd
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld

2、添加gitlab源:

curl -sS http://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

3、安装gitlab-ce

sudo yum install gitlab-ce

如果您不喜欢通过管道脚本安装存储库,您可以在这里找到整个脚本并手动选择并下载包并使用:

curl -LJO http://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-XXX.rpm/download
rpm -i gitlab-ce-XXX.rpm

4、配置gitlab:

sudo gitlab-ctl reconfigure
至此gitlab安装成功,默认用户名为root。

5、停止gitlab自带的nginx

打开文件$sudo vi /etc/gitlab/gitlab.rb。
将nginx['enable'] = ture改为nginx['enable'] = false
重启gitlab:sudo gitlab-ctl reconfigure。

6、修改gitlab域名:

打开/etc/gitlab/gitlab.rb文件,将external_url参数修改为自己的域名。

7、添加外部nginx的gitlab配置文件:

vim /etc/nginx/conf.d/gitlab.conf

添加以下内容:

upstream gitlab {
# 7.x 版本在此位置
# server unix:/var/opt/gitlab/gitlab-rails/tmp/sockets/gitlab.socket;
# 8.0 位置
server unix://var/opt/gitlab/gitlab-rails/sockets/gitlab.socket;
}

server {
 listen *:80;

 server_name gitlab.xuwanqiu.com; # 请修改为你的域名

 server_tokens off; # don't show the version number, a security best practice
 root /opt/gitlab/embedded/service/gitlab-rails/public;

 # Increase this if you want to upload large attachments
 # Or if you want to accept large git objects over http
 client_max_body_size 250m;

 # individual nginx logs for this gitlab vhost
 access_log /var/log/gitlab/nginx/gitlab_access.log;
 error_log /var/log/gitlab/nginx/gitlab_error.log;

 location / {
 # serve static files from defined root folder;.
 # @gitlab is a named location for the upstream fallback, see below
 try_files $uri $uri/index.html $uri.html @gitlab;
 }

 # if a file, which is not found in the root folder is requested,
 # then the proxy pass the request to the upsteam (gitlab unicorn)
 location @gitlab {
 # If you use http make sure you disable gzip compression
 # to be safe against BREACH attack

 proxy_read_timeout 300; # Some requests take more than 30 seconds.
 proxy_connect_timeout 300; # Some requests take more than 30 seconds.
 proxy_redirect off;

 proxy_set_header X-Forwarded-Proto $scheme;
 proxy_set_header Host $http_host;
 proxy_set_header X-Real-IP $remote_addr;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_set_header X-Frame-Options SAMEORIGIN;

 proxy_pass http://gitlab;
 }

 # Enable gzip compression as per rails guide: http://guides.rubyonrails.org/asset_pipeline.html#gzip-compression
 # WARNING: If you are using relative urls do remove the block below
 # See config/application.rb under "Relative url support" for the list of
 # other files that need to be changed for relative url support
 location ~ ^/(assets)/ {
 root /opt/gitlab/embedded/service/gitlab-rails/public;
 # gzip_static on; # to serve pre-gzipped version
 expires max;
 add_header Cache-Control public;
 }

 error_page 502 /502.html;
}

参考资料:

http://blog.csdn.net/peterxiaoq/article/details/73330302
http://www.cnblogs.com/lixiuran/p/6761299.html
http://segmentfault.com/q/1010000003695935?_ea=337139
http://laravel-china.org/topics/2829/centos-7-install-gitlab-ce-community-edition-and-modify-the-default-nginx
http://about.gitlab.com/installation/#centos-7
http://github.com/gitlabhq/gitlabhq/blob/master/doc/install/installation.md
http://jiankg.github.io/2015/06/12/%E5%9C%A8centos7%E4%B8%8A%E6%90%AD%E5%BB%BAgitlab%E7%9A%84%E6%AD%A3%E7%A1%AE%E5%A7%BF%E5%8A%BF/

反对
收藏
  • 热门资讯
  • 最新资讯
  • 应用排行榜
  • 游戏排行榜