opensuse12.2安装gitlab详细教程

# opensuse 12.2 + gitlab 4.1
#email: 187343853 @qq.com
#opensuse下安装gitlab, 几尽折腾, 终于弄好了, 给大家分享!

#参考官方文档步骤: https://github.com/gitlabhq/gitlabhq/blob/stable/doc/install/installation.md


#1. Packages / Dependencies
zypper in checkinstall libxml2-devel libxslt-devel sqlite3 libicu-devel python-devel python-pip libyaml-devel sqlite3-devel


#2. Ruby
#from yast2, install ruby1.9 and ruby-devel
gem install bundler #or bundle install --deployment


#3. System Users
groupadd git
useradd -c "git version control" -m -g git git
useradd -c "gitlab system" gitlab
usermod -G git gitlab
passwd gitlab #my passwd: pi=3.141
passwd git    #my passwd: pi=3.141


cd /home
mkdir /home/gitlab
chown gitlab:git gitlab
mkdir -m 700 .ssh
sudo -u gitlab -H ssh-keygen -q -N '' -t rsa -f /home/gitlab/.ssh/id_rsa


#4. Gitolite
cd /home/git
sudo -u git -H git clone -b gl-v320 https://github.com/gitlabhq/gitolite.git /home/git/gitolite


sudo -u git -H mkdir /home/git/bin
sudo -u git -H sh -c 'printf "%b\n%b\n" "PATH=\$PATH:/home/git/bin" "export PATH" >> /home/git/.profile'
sudo -u git -H sh -c 'gitolite/install -ln /home/git/bin'
sudo cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub
sudo chmod 0444 /home/git/gitlab.pub
sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gitolite setup -pk /home/git/gitlab.pub"


sudo chmod 750 /home/git/.gitolite/
sudo chown -R git:git /home/git/.gitolite/


sudo chmod -R ug+rwXs,o-rwx /home/git/repositories/
sudo chown -R git:git /home/git/repositories/


#Add domains to list to the list of known hosts
sudo -u gitlab -H ssh git @localhost


#Test if everything works so far


#5. Database
#see https://github.com/gitlabhq/gitlabhq/blob/stable/doc/install/databases.md
#mysql方案 上一行参考内db配置与config/database.yml一致
  #config/database.yml
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: gitlabhq_development
  pool: 5
  username: gitlab
  password: "000000" #必须引号
  socket: /run/mysql/mysql.sock




#6. GitLab
cd /home/gitlab
#Clone the Source
sudo -u gitlab -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab
sudo -u gitlab -H git checkout 4-1-stable


#Configure it
cd /home/gitlab/gitlab
sudo -u gitlab -H cp config/gitlab.yml.example config/gitlab.yml
sudo -u gitlab -H vim config/gitlab.yml


sudo chown -R gitlab log/
sudo chown -R gitlab tmp/
sudo chmod -R u+rwX  log/
sudo chmod -R u+rwX  tmp/
sudo -u gitlab -H mkdir /home/gitlab/gitlab-satellites
sudo -u gitlab -H cp config/unicorn.rb.example config/unicorn.rb


#Configure GitLab DB settings
sudo -u gitlab cp config/database.yml.postgresql config/database.yml
sudo emacs config/database.yml


#Install Gems
sudo gem fetch charlock_holmes
sudo gem unpack charlock_holmes-0.6.9.gem
cd charlock_holmes-0.6.9/
sudo emacs ./ext/charlock_holmes/extconf.rb #{CWD}/dst/lib/libmagic.a改为#{CWD}/dst/lib64/libmagic.a
sudo bundle gem .
emacs lib/version.rb #将module后的.去掉, 否则ri doc安装报错
sudo gem build charlock_holmes.gemspec
su root
ReportServer:/home/gitlab/gitlab/charlock_holmes-0.6.9 # gem install -l charlock_holmes-0.6.9.gem      #这里要确保没有一个错误


chmod 777 /usr/lib64/ruby/gems/1.9.1/gems/bundler-1.2.4/lib/bundler/settings.rb
chmod 777 /home/gitlab/gitlab/charlock_holmes-0.6.9/.bundle/config
sudo -u gitlab -H bundle install --deployment --without development test postgres #必须先执行前面的chmod, 否则提示Permission denied


#Configure Git
sudo -u gitlab -H git config --global user.name "GitLab"
sudo -u gitlab -H git config --global user.email "gitlab@localhost"


#Setup GitLab Hooks
gitlab@ReportServer:~/gitlab> sudo cp ./lib/hooks/post-receive /home/git/.gitolite/hooks/common/post-receive #注意dir
sudo chown git:git /home/git/.gitolite/hooks/common/post-receive


#Initialise Database and Activate Advanced Features
#pg问题需要先安装postgresql-devel
#sudo -u gitlab -H bundle exec rake gitlab:setup RAILS_ENV=production
#安装icu




#安装mysql2
需要先修改Gemfile
gem "mysql2", "0.3.12" 原来的mysql2一行注释掉
之后安装musql2, bundle show查看是否正确安装


#Initialise Database and Activate Advanced Features
#事先到yast安装好redis, 并启动redis服务
sudo -u gitlab -H bundle exec rake gitlab:setup RAILS_ENV=production
正确的话:
Administrator account created:


[email protected]
password......5iveL!fe
Updating repo permissions ...
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 6 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (6/6), done.
... done


Creating satellites for ...skipping, because you have no projects


#Install Init Script
sudo curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/4-1-stable/init.d/gitlab
#sudo chmod +x /etc/init.d/gitlab #opensuse上方法不同


#Check Application Status
sudo -u gitlab -H bundle exec rake gitlab:env:info RAILS_ENV=production
sudo -u gitlab -H bundle exec rake gitlab:check RAILS_ENV=production
#此处可能会提示错误, 提示执行sudo -u gitlab -H bundle exec rake sidekiq:start


#修改Gemfile, 增加
gem 'rb-inotify'
gem 'ffi'
bundle install --no-deployment
bundle install
#再测试
sudo -u gitlab -H bundle exec rake sidekiq:start 
#log/sidekiq.log提示Access denied for user 'gitlab'@'localhost' to database 'gitlabhq_development'
#无此db, 新建, 并给权限


#再测试
sudo -u gitlab -H bundle exec rake gitlab:check RAILS_ENV=production #all green, passed!


#Start Your GitLab Instance
sudo service gitlab start #not tested


#7. Nginx
#通过yast先安装nginx
#参考配置: https://raw.github.com/gitlabhq/gitlab-recipes/4-2-stable/nginx/gitlab
#编辑/etc/nginx/nginx.conf
#########################
#user  nginx;
worker_processes  1;


error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;


#pid        /var/run/nginx.pid;




events {
    worker_connections  1024;
    use epoll;
}




http {
    include       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"';


    access_log  /var/log/nginx/access.log;


    sendfile        on;
    #tcp_nopush     on;


    #keepalive_timeout  0;
    keepalive_timeout  65;


    #gzip  on;


    #include conf.d/*.conf;


    #include vhosts.d/*.conf;


    upstream gitlab {
        server unix:/home/gitlab/gitlab/tmp/sockets/gitlab.socket;
    }


    server {
      listen 192.168.1.199:81;         # e.g., listen 192.168.1.1:80; 
      server_name suse.hxz;            # 见/etc/HOSTNAME
      root /home/gitlab/gitlab/public;
    
      # individual nginx logs for this gitlab vhost
      access_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 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 {
        proxy_read_timeout 300;    # https://github.com/gitlabhq/gitlabhq/issues/694
        proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
        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_pass http://gitlab;
      }
    }




}
###########################


登录http://192.168.1.199:81查看是否出现登录界面
若有错误 查看log: /home/gitlab/gitlab/log/production.log
可能出现问题: 500, tmp/cache下文件无权限
              no gateway, 查看是否有gitlab.socket文件
可能是/home/gitlab/gitlab/tmp权限问题, 土方法, 将tmp权限改为777, 清空tmp里面cache(或全部文件和文件夹), reboot后会生成tmp下文件
(权限问题可能是/etc/nginx/nginx.conf文件user声明原因, 首行为user root admin; 参考http://ruby-china.org/topics/5113) ##已改权限, 故未尝试
配置nginx问题查找/var/log/nginx下日记
登录http://192.168.1.199:81
success!!!!!
#[email protected]
#password......5iveL!fe




#参考
https://github.com/gitlabhq/gitlabhq/blob/stable/doc/install/installation.md
http://admirestator.diandian.com/post/2012-10-07/40040233692
http://articles.nakaji.me/gitlab-opensuse
http://dev.classmethod.jp/tool/gitlab-install-mac-os-x-mountain-lion/
https://github.com/gitlabhq/gitlabhq/issues/663
http://blog.csdn.net/ysjjovo/article/details/8032570
http://dev.classmethod.jp/tool/gitlab-install-mac-os-x-mountain-lion/

你可能感兴趣的:(linux,git,gitlab,opensuse)