顯示具有 Server::Git Server 標籤的文章。 顯示所有文章
顯示具有 Server::Git Server 標籤的文章。 顯示所有文章

2017年8月26日 星期六

在 CentOS / RHEL 7 上安裝 GitBook !!

學習目標:
  • 安裝 GitBook 套件,以利出版自己的電子書!
操作流程:
  1. 安裝相關的套件:
    # yum install epel-release
    # yum update
    # yum install gcc openssl-devel gcc-c++ compat-gcc-44 compat-gcc-44-c++
    # reboot
    
  2. 由網路上,安裝遣缺的套件:
    # rpm -ivh https://kojipkgs.fedoraproject.org//packages/http-parser/2.7.1/3.el7/x86_64/http-parser-2.7.1-3.el7.x86_64.rpm
    
  3. 安裝 Node.js 套件:
    # yum -y install nodejs
    
  4. 測試 Node.js 與 npm 套件是否正常運作:
    # node -v
    #npm -v
    
  5. 安裝 gitbook 套件:
    # npm install -g gitbook-cli
    
  6. 安裝 Calibre 套件:
    # wget -nv -O- https://download.calibre-ebook.com/linux-installer.py\
     | python -c "import sys; main=lambda:sys.stderr.write('Download failed\n'); exec(sys.stdin.read()); main()"
    
  7. 測試 gitbook 套件:
    # gitbook -V
    
  8. 開始利用 gitbook 開啟新電子書編輯內容:
    # mkdir /opt/test
    # cd /opt/test
    # gitbook init
    # gitbook build
    # gitbook pdf
    # gitbook serve 
    

2017年8月18日 星期五

在 CentOS / RHEL 7 上架設 GitLab 服務(二)

學習目標:
  • 安裝 GitLab 套件,以利程式開發的版本控制!
  • 本次實作安裝的套件為 Community 版本!
  • 本次實作,按照 GitLab 官方流程安裝,所有的套件放置目錄位置,將與平常的 CentOS7/RHEL7 不同!
  • 相關目錄位置,將列表於文章後面!
操作流程:
  1. 安裝必要的相關套件:
    # yum install curl policycoreutils openssh-server openssh-clients -y
    # systemctl enable sshd
    # systemctl start sshd
    # yum install postfix
    # systemctl enable postfix
    # systemctl start postfix
    # firewall-cmd --permanent --add-service=http
    # systemctl reload firewalld
    
  2. 安裝必要的相關套件:
    # curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
    # yum install gitlab-ce -y
    
  3. 設定以及啟動 GitLab 服務:
    # gitlab-ctl reconfigure
    
  4. 利用 firefox ,登入 GitLab 服務:
    # fireflx http://127.0.0.1
    
  5. PS:第一次登入時,會被要求修改 root 密碼!修改密碼後,再以 root 帳號登入即可!
參考文獻:
  • https://about.gitlab.com/installation/#centos-7

2017年6月14日 星期三

在 CentOS / RHEL 7 上架設 GitLab 服務(一)

學習目標:
  • 安裝 GitLab 套件,以利程式開發的版本控制!
操作流程:
  1. 安裝 GitLab 相關套件:
    # yum install curl openssh-server
    # systemctl enable sshd
    # systemctl start sshd
    # yum install postfix
    # systemctl enable postfix
    # systemctl start postfix
    # rpm -ivh https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.7-1.x86_64.rpm
    # yum install git
    # yum groupinstall "Development Tools"
    # yum install readline-devel zlib-devel libffi-devel libyaml-devel openssl-devel sqlite-devellibicu-devel
    # curl -sSL https://rvm.io/mpapis.asc | gpg --import -
    # curl -L get.rvm.io | bash -s stable
    # source /etc/profile.d/rvm.sh
    # rvm reload
    # rvm requirements run
    # rvm list known
    # rvm install 2.3.3
    # rvm use 2.3.3 --default
    # wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo
    # yum install yarn
    # rpm --import https://mirror.go-repo.io/centos/RPM-GPG-KEY-GO-REPO
    # curl -s https://mirror.go-repo.io/centos/go-repo.repo | tee /etc/yum.repos.d/go-repo.repo
    # yum install golang
    # yum install nodejs
    # firewall-cmd --permanent --add-service=http
    # firewall-cmd --permanent --add-service=smtp
    # firewall-cmd --permanent --add-service=ssh
    # systemctl reload firewalld
    
  2. 新增 git 使用者:
    #useradd -s /sbin/nologin -c "GitLab" git
    
  3. 安裝資料庫,並且設定資料庫內容:
    # yum install postgresql postgresql-server postgresql-devel postgresql-contrib
    (其餘細節,請參考...)
    # su - postgres
    $psql
    postgres=# CREATE USER git CREATEDB;
    postgres=# ALTER USER git WITH PASSWORD 'git';
    postgres=# CREATE DATABASE gitlabhq_production OWNER git;
    postgres=# \c gitlabhq_production;
    gitlabhq_production=# CREATE EXTENSION IF NOT EXISTS pg_trgm;
    gitlabhq_production=#\q
    $ psql -U git -h 127.0.0.1 -d gitlabhq_production
    gitlabhq_production=> SELECT true AS enabled
    FROM pg_available_extensions
    WHERE name = 'pg_trgm'
    AND installed_version IS NOT NULL;
    
    PS:如果是自行安裝的 postgreSQL 套件,請記得製作超連結:ln -s /usr/pgsql-9.4/bin/p* /usr/local/bin
  4. 取得 GitLab 套件:
    # mkdir /opt/git
    # cd /opt/git
    # git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 9-2-stable gitlab
    # chown -R git /opt/git
    
  5. 編修相關設定檔:
    # cd /opt/git/gitlab
    # rvm install ruby-2.4.0
    # rvm use ruby-2.4.0 --default
    # cp config/gitlab.yml.example config/gitlab.yml
    # vim config/gitlab.yml
    (修改下列設定...)
    host: test.example.com
    email_enabled: false
    (存檔離開...)
    # cp config/secrets.yml.example config/secrets.yml
    # chmod 0600 config/secrets.yml
    # chown -R git log/
    # chown -R git tmp/
    # chmod -R u+rwX,go-w log/
    # chmod -R u+rwX tmp/
    # chmod -R u+rwX tmp/pids/
    # chmod -R u+rwX tmp/sockets/
    # sudo -u git -H mkdir public/uploads/
    # chmod 0700 public/uploads
    # chmod -R u+rwX builds/
    # chmod -R u+rwX shared/artifacts/
    # chmod -R ug+rwX shared/pages/
    # sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
    # nproc
    # vim config/unicorn.rb
    (修改相對應的路徑,以及下列參數...)
    worker_processes 4
    # sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
    # sudo -u git -H git config --global core.autocrlf input
    # sudo -u git -H git config --global gc.auto 0
    # sudo -u git -H git config --global repack.writeBitmaps true
    # sudo -u git -H cp config/resque.yml.example config/resque.yml
    # vim config/resque.yml
    (修改 redis server 相關設定,請參考...)
    # chmod 777 /tmp/redis.socket
    #sudo -u git cp config/database.yml.postgresql config/database.yml
    #vim config/database.yml
    (修改連線帳密資料...)
    sudo -u git -H chmod o-rwx config/database.yml
    
  6. 整合 Ruby 的設定,並進行安裝:
    # su - git
    $ cd /opt/git/gitlab
    $ gem uninstall bundler
    $ gem install bundler:1.14.6
    $ bundle install -j4 --deployment --without development test mysql aws kerberos
    
  7. 安裝與檢查 git-shell 設定:
    $ bundle exec rake gitlab:shell:install REDIS_URL=unix:/tmp/redis.sock RAILS_ENV=production SKIP_STORAGE_VALIDATION=true
    
    or
    $ bundle exec rake gitlab:shell:install REDIS_URL=redis://127.0.0.1:6379 AUTH=xxxxxx RAILS_ENV=production SKIP_STORAGE_VALIDATION=true
    
    $ vim /opt/git/gitlab-shell/config.yml
    
  8. 安裝與檢查 gitlab-workhorse 設定:
    $ bundle exec rake "gitlab:workhorse:install[/opt/git/gitlab-workhorse]" RAILS_ENV=production
    
  9. 初始化資料庫設定:
    $ vim /opt/git/gitlab/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb
    (修改 redis 的連線 ip , db , 以及密碼!)
    $ bundle exec rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD=git GITLAB_ROOT_EMAIL=root@localhost
    (記得回答 yes)
    
  10. 保存重要的密碼設定:
    $ cp config/secrets.yml /home/git/
    
  11. 部署重要的初始設定:
    # cp /opt/git/gitlab/lib/support/init.d/gitlab /etc/init.d/gitlab
    # vim /etc/init.d/gitlab
    (修改路徑目錄)
    # cp /opt/git/gitlab/lib/support/init.d/gitlab.default.example /etc/default/gitlab
    # vim /etc/default/gitlab
    (修改路徑目錄)
    # chkconfig --add gitlab
    # chkconfig --list gitlab
    
  12. 安裝 Gitaly:
    # su - git
    $ bundle exec rake "gitlab:gitaly:install[/opt/git/gitaly]" RAILS_ENV=production
    $ chmod 0700 /opt/git/gitlab/tmp/sockets/private
    $ chown git /opt/git/gitlab/tmp/sockets/private
    $ cd /opt/git/gitaly
    $ vim config.toml
    
  13. 設定轉檔功能:
    $ exit
    # cp /opt/git/gitlab/lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
    # vim /etc/logrotate.d/gitlab
    (修改路徑目錄)
    
  14. 確認應用程式目前的狀態:
    # su - git
    $ bundle exec rake gitlab:env:info RAILS_ENV=production
    
  15. 其它設定:
    $ yarn install --production --pure-lockfile
    $ bundle exec rake gitlab:assets:compile RAILS_ENV=production NODE_ENV=production
    bundle exec rake gettext:compile RAILS_ENV=production
    
  16. 啟動 GitLab 服務:
    # service gitlab start
    
  17. 使用 Nginx 服務:
    # yum install -y nginx
    # cp /opt/git/gitlab/lib/support/nginx/gitlab /etc/nginx/conf.d/gitlab.conf
    # vim /etc/nginx/conf.d/gitlab.conf
    (修改至符合的項目...)
    

    參考文獻:
  • https://about.gitlab.com/installation/
  • https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
  • https://docs.gitlab.com/ce/install/installation.html
  • https://www.theshell.guru/install-ruby-2-4-centos-7-3/
  • https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/install/installation.md

2016年6月19日 星期日

在 CentOS7/RHEL7 上架設 Git Server

設定目標:
  • 在 Linux 上架設 Git Server ,方便專案開發的軟體可以管控軟體版本!
  • 事先準備事項:
    • 參考
快速設定流程:
  1. 利用 YUM 安裝 git 相關套件:
    #yum -y install git
    
  2. 建立一個帳號 git ,提供 git 上傳檔案用:
    #useradd -m -d /opt/git git
    #passwd git
    
  3. 切換至 git 帳號,建立一個測試用的專案:
    #su - git
    $mkdir test1
    $cd test1
    $git init --bare
    
  4. 在自己的本機 (Client 機) 上,建立一個 RSA key ,提供上傳檔案到 Git Server 用:
    $ssh-keygen -t rsa
    $ssh-copy-id -i ~/.ssh/id_dsa.pub git@gitserver
    
    測試:
    $ssh git@gitserver
    
  5. 在自己的本機上,先行進行設定:
    $git config --global user.email "test@localhost"
    $git config --global user.name "test"
    
  6. 在自己的本機上,下載剛才建立的專案來測試 Git Server:
    $cd ~
    $git clone git@gitserver:/opt/git/test1
    $cd test1
    $touch test1.txt
    $git add test1.txt
    $git commit -m "test server"
    $git push origin master
    
  7. 測試成功之後,可以將 Server 上的 git 帳號,進行功能上的限制:
    #usermod -s /bin/git-shell git
    
參考文獻:
  1. http://shazi.info/centos-%E5%AE%89%E8%A3%9D-git-server-%E5%85%B1%E4%BA%AB-repository-%E9%81%94%E5%88%B0%E5%A4%9A%E4%BA%BA%E9%96%8B%E7%99%BC%E7%92%B0%E5%A2%83/
  2. http://wznote.blogspot.tw/2014/09/instal-git-server-in-centos.html
  3. http://blog.feehi.com/linux/124.html