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: login.........admin@local.host 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!!!!! #login.........admin@local.host #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/
相關文章
相關標籤/搜索