centos6.7 install gitlab7.13.5_zh

marksugar
2015-11-22 / 0 评论 / 3,073 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2015年11月25日,已超过2157天没有更新,若内容或图片失效,请留言反馈。

<p>
声明:本章内容由本章发布,其中感谢豆豆师兄,和郭师兄的鼎力相助才安装完成,如有看不懂的地方,那就看不懂吧!
请在下方留言,或者加群讨论!</p><pre class="brush:bash; toolbar:false;">## 环境`OS : CentOS 6.6 X86_64GitLab Version : 7.13.5_zhWeb Server : NginxDataBase : MySQLAuthor : YxnData : 2015-08-21 12:03:07</pre><p>
</p><p>
</p><pre class="brush:bash; toolbar:false;">#/etc/init.d/iptables stop# setenforce 0</pre>
## 简介
翻译于官方文档 Install/CentOS 此篇没有关于SSL、防火墙、SElinux、PgSQL(PostgreSQL)、Apache的安装配置,官方文档中包含SElinx、防火墙、SSL、PgSQL、Apache的配置。
由于GitLab为英文版本,所以选择了GitLab 中文版本。可能由于某些地区连接过慢,这里提供了一个国内的镜像版本库GitLab 中文版本
以上翻译为个人翻译,如有问题请邮箱联系或者留言。谢谢!<p>
</p><p> ### bug提交
如果你发现有BUG请提交于 Issue</p><pre class="brush:bash; toolbar:false;"><pre class="brush:as3; toolbar:false;">### 配置大纲- - - 此篇安装文档的步骤如下:1. 安装基本的操作系统(CentOS 6.6 x86_64)以及一些依赖的程序包2. Ruby3. System Users4. DataBase(MySQL)5. Redis6. GitLab7. Web Server (Nginx)---------</pre>
</pre><p> 提示: 安装方式随自己心情,不想用 YUM 就用编译,开心就好。
## 1. 安装基本的操作系统</p><p> 在这里操作系统的安装并不做任何演示操作,因为既然能看到这篇文章那么至少你是一个运维人员了,如果你连系统都不会装那就到这就可以结束了。</p><p> 注意: 保证开机自动连接网路,毕竟是放在公司使用的谁也不希望重启一下就连接不到了。
1,#### 添加EPEL源
从fedoraproject下载GPG key并且安装在系统中</p><p>
</p><pre class="brush:bash; toolbar:false;"> wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 https://www.fedoraproject.org/static/0608B895.txt rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6</pre><p>
</p><p> 查看Key是否安装成功:</p><p>
</p><pre class="brush:bash; toolbar:false;"> rpm -qa gpg gpg-pubkey-0608b895-4bd22942</pre>
   
在系统中安装epel源<p>
</p><p>    </p><pre class="brush:bash; toolbar:false;">rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm<;/pre>
   
提示: 也可以自己配置repo文件,看自己心情。<p>
</p><p> #### 添加PUIAS源
这段说明不会翻译 - -。</p><p> 下载 PUIAS repo文件</p><p>  </p><pre class="brush:bash; toolbar:false;">wget -O /etc/yum.repos.d/PUIAS_6_computational.repo https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/install/centos/PUIAS_6_computational.repo </pre>
   
接下来下载并安装gpg key<p>
</p><p>
</p><pre class="brush:bash; toolbar:false;"> wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-puias http://springdale.math.ias.edu/data/puias/6/x86_64/os/RPM-GPG-KEY-puias rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-puias</pre>
   
查看是否安装成功<p>
</p><pre class="brush:bash; toolbar:false;">rpm -qa gpg
gpg-pubkey-41a40948-4ce19266</pre>
   
查看源是否添加成功<p>
</p><p>
</p><pre class="brush:bash; toolbar:false;">yum repolistrepo id repo name statusPUIAS_6_computational PUIAS computational Base 6 - x86_64 2,678epel Extra Packages for Enterprise Linux 6 - x86_64 11,772</pre>
如果没有看到如上内容,则使用下面的命令来启用它们(需要安装yum-utils包)<pre class="brush:bash; toolbar:false;">yum-config-manager --enable epel --enable PUIAS_6_computational</pre>
 2,#### 为GitLab安装一些必须的包<p>  yum update  # 其实这一步可以不需要的</p><pre class="brush:bash; toolbar:false;"><pre class="brush:as3; toolbar:false;">yum -y groupinstall 'Development Tools'yum -y install readline readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel openssl-devel curl-devel expat-devel db4-devel byacc sqlite-devel libyaml libyaml-devel libffi libffi-devel libxml2 libxml2-devel libxslt libxslt-devel libicu libicu-devel system-config-firewall-tui redis sudo wget crontabs logwatch logrotate perl-Time-HiRes git cmake libcom_err-devel.i686 libcom_err-devel.x86_64 nodejs</pre>
</pre> 
  3,Note: 配置默认的编辑器<p>  # 安装vim并且设置为默认的编辑器</p><pre class="brush:bash; toolbar:false;">yum -y install vim-enhancedupdate-alternatives --set editor /usr/bin/vim.basicln -s /usr/bin/vim /usr/bin/editor</pre><pre class="brush:bash; toolbar:false;"># reStructuredText markup语法支持,需要安装依赖包:yum install -y python-docutils</pre><p> 4,#### 可选:使用源码安装git
确认Git的版本>=1.7.10,如果低于此版本需要进行安装</p><p>     git --version
移除git</p><pre class="brush:bash; toolbar:false;">yum -y remove git</pre>
安装git编译所需要的包<pre class="brush:bash; toolbar:false;">yum install zlib-devel perl-CPAN gettext curl-devel expat-devel gettext-devel openssl-devel</pre>
下载并解压它<pre class="brush:bash; toolbar:false;">mkdir /tmp/git && cd /tmp/gitcurl --progress https://www.kernel.org/pub/software/scm/git/git-2.1.3.tar.gz | tar xzcd git-2.1.3/./configuremakemake prefix=/usr/local install</pre><p>
</p><p> 确认你的git路径,需要在后面编辑config/gitlab.yml时使用,</p><p> 5,## 2.Ruby
如果系统中Ruby的版本是2.0以前的那么请移除,GitLab只支持Ruby 2.0+版本</p><p>
</p><pre class="brush:bash; toolbar:false;">yum remove ruby</pre><p>
</p><p> ### 下载并编译</p><p>
</p><pre class="brush:bash; toolbar:false;">mkdir /tmp/ruby && cd /tmp/rubycurl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz | tar xzcd ruby-2.1.2./configure --disable-install-rdocmakemake prefix=/usr/local install</pre><p>
</p><p> <span style="background-color:#E56600;">### 安装Bundler Gem</span>
<span style="background-color:#E56600;">由于http://rubygems.org已被墙,这里替换源为http://ruby.taobao.org</span>
<span style="background-color:#E56600;">    </span>
<span style="background-color:#E56600;">    # 添加淘宝源并且移除官方源</span> </p><pre class="brush:bash; toolbar:false;">sudo git gem sources -a http://ruby.taobao.orggem sources -r https://rubygems.org/<;/pre>
    
    # 安装Bundler
<pre class="brush:bash; toolbar:false;">gem install bundler -v'1.5.2' --no-doc</pre><p>
</p><p> 检查ruby版本</p><p>
</p><pre class="brush:bash; toolbar:false;">ruby --versionruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]</pre>
   
6,## 3. System Users
为GitLab创建用户
 <pre class="brush:bash; toolbar:false;">adduser --system --shell /bin/bash --comment 'GitLab' --create-home --home-dir /home/git/ git</pre><p>
</p><p> 编辑sudoers文件,将ruby的程序路径添加到PATH中,使git用户作为root来使用gem命令</p><p>
</p><pre class="brush:bash; toolbar:false;"> visudo# 搜索如下行Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin# 追加/usr/local/binDefaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin</pre>
保存并退出<p>
</p><p> 7,## 4. DataBase
这里使用的是MariaDB,我用的是yum安装的自己配置的yum源(由于当时做实验的时候已经凌晨1点了为了赶快做完去睡觉)还是那句:用什么包随心情,开心就好
### 配置yum源</p><pre class="brush:bash; toolbar:false;">vim /etc/yum.repos.d/mariadb.repo# 增加如下内容:[mariadb]name=mariadbbaseurl=http://mirrors.aliyun.com/mariadb/mariadb-5.5.45/yum/centos6-amd64/gpgcheck=0<;/pre><pre class="brush:bash; toolbar:false;">### 安装MariaDByum install MariaDB MariaDB-devel</pre>    也可以使用编译安装,可以看本博客中Mariadb
#### 连接数据库并创建用户<pre class="brush:bash; toolbar:false;"><pre class="brush:as3; toolbar:false;">mysql -u root 创建数据库CREATE USER 'git1'@'10.215.50.3' IDENTIFIED BY 'gitpassword'; 确定你的innode引擎支持长索引SET storage_engine=INNODB;创建数据库CREATE DATABASE IF NOT EXISTS gitlabhq_production DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;</pre>
</pre><pre class="brush:bash; toolbar:false;">尝试使用新用户连接gitlab数据库sudo -u git -H mysql -u git -pgitpassword -D gitlabhq_production</pre><p> 8,## 5. Redis</p><pre class="brush:bash; toolbar:false;">开机启动redischkconfig redis on</pre><pre class="brush:bash; toolbar:false;"><pre class="brush:as3; toolbar:false;">配置Redis使用socketscp /etc/redis.conf /etc/redis.conf.orig 关闭Redis 监听于TCPsed 's/^port ./port 0/' /etc/redis.conf.orig | sudo tee /etc/redis.conf 在CentOS上启用Redis socketecho 'unixsocket /var/run/redis/redis.sock' | sudo tee -a /etc/redis.confecho -e 'unixsocketperm 0770' | sudo tee -a /etc/redis.conf 设置socket目录属主(组)为redischown redis:redis /var/run/redischmod 755 /var/run/redis 将git用户添加至redis组usermod -aG redis git 启动redis服务service redis start</pre></pre><p>  
9, 6. GitLab</p><p>
</p><pre class="brush:bash; toolbar:false;"><pre class="brush:as3; toolbar:false;">克隆源码cd /home/git/sudo -u git -H git clone http://git.oschina.net/Yxnt/gitlab配置gitlab进入Gitlab安装目录cd /home/git/gitlab复制gitlab的模板文-件sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml编辑gitlab配置文件sudo -u git -H editor config/gitlab.yml 访问地址host:10.1.13.5port:80https: false # 关闭https</pre>
</pre> ====================我是分割线=================================
<pre class="brush:bash; toolbar:false;"><pre class="brush:as3; toolbar:false;">创建satellites目录sudo -u git -H mkdir /home/git/gitlab-satelliteschmod u+rwx,g=rx,o-rwx /home/git/gitlab-satellites确认gitlab可以写入tmp/pids、tmp/sockets以及public/uploads/目录chmod -R u+rwX tmp/pids/chmod -R u+rwX tmp/sockets/chmod -R u+rwX public/uploads复制Unicorn配置文件sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb复制Rack attack配置文件sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb配置Git 全局设置sudo -u git -H git config --global user.name "GitLab"sudo -u git -H git config --global user.email "example@example.com"sudo -u git -H git config --global core.autocrlf input配置Redis连接设置sudo -u git -H cp config/resque.yml.example config/resque.ymlsudo -u git -H editor config/resque.yml # 更改配置development: unix:/var/run/redis/redis.sock### 配置Gitlab 数据库设置MySQL Onlysudo -u git cp config/database.yml.mysql config/database.yml确定database.yml文件只为git用户可读sudo -u git -H chmod o-rwx config/database.yml</pre></pre>   
10,### 安装Gems<p>
</p><p>  </p><pre class="brush:bash; toolbar:false;"><pre class="brush:as3; toolbar:false;">cd /home/git/gitlabgem sources --add https://rubygems.org --remove https://ruby.taobao.orgbundle config mirror.https://rubygems.org https://ruby.taobao.orggem install rails -V sudo -u git -H bundle install --deployment --without development test postgres awssudo -u git -H bundle install --deployment --without development test postgres aws安装gitlab-shellsudo -u git -H bundle exec rake gitlab:shell:install[v2.6.3] REDIS_URL=unix:/var/run/redis/redis.sock RAILS_ENV=production配置gitlab-shellsudo -u git -H editor /home/git/gitlab-shell/config.ymlgitlab_url: http://10.1.13.5<;/pre></pre><p>    
11,### 初始化数据并且激活高级特性</p><pre class="brush:bash; toolbar:false;">这里会提示输入yes/no,输入yes即可sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production 设置管理员密码,其中newpassword替换成你的密码sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD=gitpassword</pre><pre class="brush:bash; toolbar:false;">安装启动脚本wget -O /etc/init.d/gitlab https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/init/sysvinit/centos/gitlab-unicorn<;/pre><pre class="brush:bash; toolbar:false;">chmod +x /etc/init.d/gitlabchkconfig --add gitlab</pre><p>  </p><pre class="brush:bash; toolbar:false;">开机启动 Gitlabchkconfig gitlab on设置日志滚动cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab检查应用程序状态sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production[git@gitlab gitlab]$ bundle exec rake gitlab:env:info RAILS_ENV=productionSystem informationSystem: CentOS 6.7Current User: gitUsing RVM: noRuby Version: 2.1.2p95Gem Version: 2.2.2Bundler Version:1.5.2Rake Version: 10.4.2Sidekiq Version:3.3.0GitLab informationVersion: 7.13.5Revision: 851306aDirectory: /home/git/gitlabDB Adapter: mysql2URL: http://10.215.50.3HTTP Clone URL: http://10.215.50.3/some-project.gitSSH Clone URL: git@10.215.50.3:some-project.gitUsing LDAP: noUsing Omniauth: noGitLab ShellVersion: 2.6.3Repositories: /home/git/repositories/Hooks: /home/git/gitlab-shell/hooks/Git: /usr/bin/git[git@gitlab gitlab]$</pre><p>  </p><pre class="brush:bash; toolbar:false;">启动gitlabservice gitlab start</pre><p>
</p><p> 7.Web Server</p><p> ### 安装nginx</p><p> 我这里是编译的,细节不在批示,可在本站搜索nginx编译安装</p><p>
</p><pre class="brush:bash; toolbar:false;">./configure --prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf --user=nginx --group=nginx --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-http_mp4_module --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi</pre><p>
</p><p>   </p><p> 如果你用的是install,则可以使用一下范式</p><pre class="brush:bash; toolbar:false;"><pre class="brush:as3; toolbar:false;">配置nginxwget -O /etc/nginx/conf.d/gitlab.conf https://gitlab.com/gitlab-org/gitlab-ce/raw/master/lib/support/nginx/gitlabwget -O /etc/nginx/gitlab.conf https://gitlab.com/gitlab-org/gitlab-ce/raw/master/lib/support/nginx/gitlab修改代理服务器[root@gitlab nginx]# sed -ie "38s/.
/server localhost:8080;/g" /etc/nginx/gitlab.conf[root@gitlab nginx]# sed -ie "s/YOUR_SERVER_FQDN/hostname/g" /etc/nginx/gitlab.conf[root@gitlab nginx]# sed -ie "52d" /etc/nginx/gitlab.conf[root@gitlab nginx]# usermod -a -G git nginx[root@gitlab nginx]# chmod g+rx /home/git/[root@gitlab nginx]# service nginx startupstream gitlab {server localhost:8080;} 修改server_nameserver_name www.baidu.com;</pre></pre><p> 如果你是编译的请复制一下内容到nginx.conf,<span style="background-color:#E53333;">请自行修改配置文件中的编译文件路径</span> </p><p>
</p><pre class="brush:bash; toolbar:false;"><pre class="brush:as3; toolbar:false;">user root git;worker_processes 2;pid /var/run/nginx/nginx.pid;events {worker_connections 1024;}http {include /etc/nginx/mime.types;default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';#GITLAB# Maintainer: @randx# App Version: 5.0upstream gitlab {server unix:/home/git/gitlab/tmp/sockets/gitlab.socket;}server {listen *:80 default_server; # e.g., listen 192.168.1.1:80; In most cases *:80 is a good ideaserver_name YOUR_SERVER_FQDN; # e.g., server_name source.example.com;server_tokens off; # don't show the version number, a security best practiceroot /home/git/gitlab/public;# Set value of client_max_body_size to at least the value of git.max_size in gitlab.ymlclient_max_body_size 5m;# individual nginx logs for this gitlab vhostaccess_log /var/log/nginx/gitlab_access.log;error_log /var/log/nginx/gitlab_error.log;location / {# serve static files from defined root folder;.# @gitlab is a named location for the upstream fallback, see belowtry_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 {proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694proxy_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_pass http://gitlab;}}}</pre>
</pre>
<pre class="brush:bash; toolbar:false;"># 添加nginx到git组usermod -a -G git nginxchmod g+rx /home/git/ # 启动nginxservice nginx start</pre> <pre class="brush:bash; toolbar:false;">##附录(发送邮件配置),未经测试,请斟酌使用</pre><pre class="brush:bash; toolbar:false;"><pre class="brush:as3; toolbar:false;">### 复制gitlab自带的模板cd /home/git/gitlabsudo -u git -H cp config/initializers/smtp_settings.rb.sample config/initializers/smtp_settings.rb### 替换邮箱sudo -u git -H vim config/initializers/smtp_settings.rb if Rails.env.production?Gitlab::Application.config.action_mailer.delivery_method = :smtpActionMailer::Base.smtp_settings = {address: "smtp.163.com", ## 发信地址port: 25, ## 发信端口user_name: "wpgitlab", ## 用户名password: "123456", ## 密码domain: "163.com", ## 域authentication: :plain, enable_starttls_auto: true}end### 修改gitlab.ymlcd /home/git/gitlabsudo -u git -H vim config/gitlab.yml email_from: wpgit@163.com 这里的邮箱配置和上面的一样</pre>
</pre><p>  
## 结束语
yum安装可能是有点影响智商了,如果你被领导用刀夹着脖子的话那就还是用吧。</p><p> 邮件内容未测试,请自行测试</p><p> 由于文章的代码高亮问题,可下载此文章链接:gitlab文档下载 </p>

0

评论 (0)

取消