Categories
- FFMpeg (5)
- Libav (1)
- Google (3)
- iBeacon (1)
- LDAP (3)
- Me (2)
- Network (11)
- OS (149)
- RTMP (4)
- SIP (1)
- Kamailio (1)
- SNMP (1)
- VMware (20)
- VCP考試 (1)
- 伺服器 網站服務 (105)
- 名詞解釋 (4)
- 專案管理 (1)
- 工具軟體 (50)
- Adobe (1)
- FMS (1)
- Cloudera (1)
- Docker (1)
- Eclipse (4)
- Intellij (2)
- OBS (2)
- Office (10)
- Excel (4)
- PowerPoint (5)
- Postman (1)
- Splunk (13)
- Virtualbox (2)
- Visual Studio (2)
- 文字編輯器 (10)
- Sublime Text 2 (6)
- Sublime Text 3 (3)
- Vim (3)
- 連線工具 (1)
- Xshell (1)
- Adobe (1)
- 程式語言 (79)
- CSS (2)
- HTML (2)
- iOS (1)
- Java (30)
- JavaScript (5)
- jQuery (4)
- jsTree (2)
- JSP (3)
- PHP (16)
- Python (7)
- Ruby (1)
- sed (1)
- Shell Script (8)
- Windows Bash Script (1)
- XML (1)
- 資料庫 (37)
- FFMpeg (5)
Category Archives: Git
Git Server 安裝
OS: Ubuntu 12.04 Desktop x64 安裝Gitlab + MySQL 系統更新
1 2 3 |
apt-get update apt-get upgrade -y apt-get dist-upgrade |
安裝基本需求
1 2 |
update-alternatives --set editor /usr/bin/vim.basic sudo apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate |
安裝python
1 2 3 4 5 6 7 8 9 10 11 12 |
sudo apt-get install -y python python --version python2 --version # 確認 python版本,如果版本是3.x以上,則需額外安裝2.x版 # sudo apt-get install -y python2.7 # python --version # Python 2.7.3 # python2 --version # 命令執行會採用 python2, 所以需要確認 python2 的版本 # python2 不存在的話, 需要把 python 2.7 版 的 ln 過去. # sudo ln -s /usr/bin/python /usr/bin/python2 apt-get install -y python-docutils |
安裝Git
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
# 檢查Git目前可apt安裝的版本 apt-cache showpkg git-core # 如果版本大於1.7.10,則可以直接使用~否則建議手動安裝新版本 # 直接安裝 => apt-get install -y git-core # 如果原本就安裝舊有版本,移除 => apt-get remove git-core # 手動安裝Git apt-get install -y libcurl4-openssl-dev libexpat1-dev gettext libz-dev libssl-dev build-essential cd /tmp curl --progress https://git-core.googlecode.com/files/git-1.9.0.tar.gz | tar xz cd git-1.9.0/ make prefix=/usr/local all make prefix=/usr/local install |
安裝postfix,以便後續提供發信服務
1 2 |
# 選擇Internet Site並輸入Domain Name apt-get install -y postfix |
安裝Ruby
1 2 3 4 5 6 7 8 9 10 |
# 如果裝有1.8版,先行移除 # apt-get remove ruby1.8 mkdir /tmp/ruby && cd /tmp/ruby curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p481.tar.gz | tar xz cd ruby-2.0.0-p481/ ./configure --disable-install-rdoc make -j `cat /proc/cpuinfo | grep 'cpu cores' | awk '{if ($4=1) print $4; else print $4-1}'` make install gem install bundler --no-ri --no-rdoc |
新增Gitlab系統帳號
1 |
adduser --disabled-login --gecos 'GitLab' git |
安裝GitLab Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
cd /home/git sudo -u git -H git clone https://github.com/gitlabhq/gitlab-shell.git cd gitlab-shell #查看最新版本為何 sudo -u git -H git tag sudo -u git -H git checkout v1.9.6 sudo -u git -H cp config.yml.example config.yml #修改gitlab_url,改成要使用的domain sudo -u git -H editor config.yml sudo -u git -H ./bin/install |
安裝MySQL Database
1 2 3 4 5 6 7 8 |
apt-get install -y mysql-server mysql-client libmysqlclient-dev mysql -u root -p > CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'GITLAB_PASSWORD'; > CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; >GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost'; # 使用gitlab帳號測試MySQL sudo -u git -H mysql -u gitlab -p -D gitlabhq_production |
安裝GitLab
1 2 3 4 5 6 7 8 |
cd /home/git sudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab cd /home/git/gitlab # 檢查版本,找stable的 sudo -u git -H git branch -a sudo -u git -H git checkout 7-0-stable |
設定GitLab
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
cd /home/git/gitlab sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml # 所有 localhost 改成要使用的domain. # /usr/bin/git 改成 /usr/local/bin/git sudo -u git -H editor config/gitlab.yml #調整檔案權限 chown -R git log/ chown -R git tmp/ chmod -R u+rwX log/ chmod -R u+rwX tmp/ sudo -u git -H mkdir /home/git/gitlab-satellites sudo -u git -H mkdir tmp/pids/ sudo -u git -H mkdir tmp/sockets/ chmod -R u+rwX tmp/pids/ chmod -R u+rwX tmp/sockets/ sudo -u git -H mkdir public/uploads chmod -R u+rwX public/uploads sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb chmod -R u+rwX public/uploads sudo -u git -H mkdir public/uploads #如果硬體記憶體規格超過2G,可將worker_processes改成3 #sudo -u git -H editor config/unicorn.rb sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb sudo -u git -H git config --global user.name "GitLab" sudo -u git -H git config --global user.email "gitlab@localhost" sudo -u git -H git config --global core.autocrlf input |
GitLab DB設計
1 2 3 4 5 6 |
sudo -u git cp config/database.yml.mysql config/database.yml # 將production區塊的secure password值改成MySQL gitlab帳號設定的帳號、密碼 sudo -u git -H editor config/database.yml sudo -u git -H chmod o-rwx config/database.yml |
安裝Gems
1 2 |
cd /home/git/gitlab sudo -u git -H bundle install --deployment --without development test postgres aws |
初始化 Database
1 2 3 4 5 6 |
# 問啥就輸入yes以便建立Database sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production # 取得系統預設帳號、密碼 (所有新安裝都一樣,務必要更改) Administrator account created: login.........admin@local.host password......5iveL!fe |
Posted in Git, Ubuntu
Leave a comment
Git : non-fast-forward
當進行 gir push 發生 “non-fast-forward” 錯誤時 (如下面這個範例)
1 2 3 4 5 6 7 8 |
root@ubuntu:/mnt/tdg_logs/blacklist/Git/master# git push -u 20140821 master Enter passphrase for key '/root/.ssh/id_rsa': To git@cowman.no-ip.org:udn/udn_php-domain_name_query.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'git@cowman.no-ip.org:udn/udn_php-domain_name_query.git' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes (e.g. 'git pull') before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details. |
會有幾個可能性, 可以透過 git status 先查看是不是有需要手動 merge 的部分 假設有出現 Unmerged paths 的資訊就是需要手動處理一下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
root@ubuntu:/mnt/tdg_logs/blacklist/Git/master# git status # On branch master # Unmerged paths: # (use "git add/rm <file>..." as appropriate to mark resolution) # # both added: JobDaemon.php # both added: ReadME # both added: daily.sh # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # 20140801/ # 20140815.zip # 20140821.zip # JobDaemon.php.bak no changes added to commit (use "git add" and/or "git commit -a") |
這時候就要針對 JobDaemon.php、ReadME、daily.sh 進行編輯 在檔案中可以看到
1 2 3 4 5 |
<<<<<<<<<< HEAD 要新推上去的檔案內容 ========== 原始branch的檔案內容 >>>>>>>>>>> |
目前是先保留新推上去的檔案內容為主~將<<<、===、原始的內容、>>>刪除後重新 git add、git commit 後重新push即可 另外一個可能性是要進行 git pull 要推上去的remote 要推到的branch名稱
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
root@ubuntu:/mnt/tdg_logs/blacklist/Git# git pull 20140825 master Enter passphrase for key '/root/.ssh/id_rsa': warning: no common commits remote: Counting objects: 18, done. remote: Compressing objects: 100% (17/17), done. remote: Total 18 (delta 7), reused 0 (delta 0) Unpacking objects: 100% (18/18), done. From cowman.no-ip.org:udn/udn_php-domain_name_query * branch master -> FETCH_HEAD Merge made by the 'recursive' strategy. root@ubuntu:/mnt/tdg_logs/blacklist/Git# git push 20140825 master Enter passphrase for key '/root/.ssh/id_rsa': Counting objects: 2, done. Delta compression using up to 4 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (2/2), 305 bytes, done. Total 2 (delta 1), reused 0 (delta 0) To git@cowman.no-ip.org:udn/udn_php-domain_name_query.git 07152a6..ccd7420 master -> master |
Posted in Git
Leave a comment