GitLab Installation on Ubuntu Server 12.04
来源:互联网 发布:电脑大型网络3d游戏 编辑:程序博客网 时间:2024/06/04 18:43
For the people not knowing what GIT is or what it’s used for here’s a link to read about it What is GIT. This post wouldn’t have been possible if it was not for the work done by the community at GitLab . Please donate to this project.
Installation
This installation was done on a Ubuntu 12.04 server. A clean install was done with no extra packages installed with the base installation. The server is setup on a VM running on VMWare ESX4.
The installation consists of 6 steps:
Install packages / dependencies
Install ruby
Install gitolite
Install and configure Gitlab.
Start the web front-end
Start a Resque worker (for background processing)
First 3 steps can be easily skipped with simply install script:
# Install curl and sudoapt-get install curl sudo# 3 steps in 1 commandcurl https://raw.github.com/gitlabhq/gitlabhq/master/doc/debian_ubuntu.sh | sh
Now you can go to step 4″
1. Install packages
Keep in mind that sudo is not installed for debian by default. You should install it with as root (to gain root access on Ubuntu login with your username and sudo -i ):
apt-get update && apt-get upgrade && apt-get install sudosudo apt-get updatesudo apt-get upgrade sudo apt-get install -y git-core wget curl gcc checkinstall libxml2-dev libxslt-dev sqlite3 libsqlite3-dev libcurl4-openssl-dev libreadline-dev libc6-dev libssl-dev libmysql++-dev make build-essential zlib1g-dev libicu-dev redis-server openssh-server git-core python-dev python-pip libyaml-dev sendmail # If you want to use MySQL:sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev
2. Install Ruby
wget <a href="http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p290.tar.gz">http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p290.tar.gz</a>tar xzfv ruby-1.9.2-p290.tar.gzcd ruby-1.9.2-p290./configuremakesudo make install
3. Install gitolite
Create user for git:
sudo adduser \--system \--shell /bin/sh \--gecos 'git version control' \--group \--disabled-password \--home /home/git \git
Create user for gitlab:
# ubuntu/debiansudo adduser --disabled-login --gecos 'gitlab system' gitlab
Add your user to git group:
sudo usermod -a -G git gitlab
Generate key:
sudo -H -u gitlab ssh-keygen -q -N '' -t rsa -f /home/gitlab/.ssh/id_rsa
Get gitolite source code:
cd /home/gitsudo -H -u git git clone git://github.com/gitlabhq/gitolite /home/git/gitolite
Setup:
sudo -u git sh -c 'echo -e "PATH=\$PATH:/home/git/bin\nexport PATH" > /home/git/.profile'sudo -u git -i -H /home/git/gitolite/src/gl-system-installsudo cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pubsudo chmod 777 /home/git/gitlab.pubsudo -u git -H sed -i 's/0077/0007/g' /home/git/share/gitolite/conf/example.gitolite.rcsudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gl-setup -q /home/git/gitlab.pub"
Permissions:
sudo chmod -R g+rwX /home/git/repositories/sudo chown -R git:git /home/git/repositories/
CHECK: Logout & login again to apply git group to your user
# clone admin repo to add localhost to known_hosts# & be sure your user has access to gitolitesudo -u gitlab -H git clone git@localhost:gitolite-admin.git /tmp/gitolite-admin# if succeed you can remove itsudo rm -rf /tmp/gitolite-admin
IMPORTANT! If you cant clone gitolite-admin
repository – DONT PROCEED INSTALLATION
4. Install gitlab and configuration. Check status configuration.
sudo gem install charlock_holmessudo pip install pygmentssudo gem install bundlercd /home/gitlabsudo -H -u gitlab git clone git://github.com/gitlabhq/gitlabhq.git gitlabcd gitlab# Rename config filessudo -u gitlab cp config/gitlab.yml.example config/gitlab.yml
Select db you want to use
# SQLitesudo -u gitlab cp config/database.yml.sqlite config/database.yml# Or# Mysqlsudo -u gitlab cp config/database.yml.example config/database.yml# Change username/password of config/database.yml to real one
Install gems
sudo -u gitlab -H bundle install --without development test --deployment
Setup DB
sudo -u gitlab bundle exec rake gitlab:app:setup RAILS_ENV=production
Checking status:
sudo -u gitlab bundle exec rake gitlab:app:status RAILS_ENV=production# OUTPUT EXAMPLEStarting diagnosticconfig/database.yml............existsconfig/gitlab.yml............exists/home/git/repositories/............exists/home/git/repositories/ is writable?............YESremote: Counting objects: 603, done.remote: Compressing objects: 100% (466/466), done.remote: Total 603 (delta 174), reused 0 (delta 0)Receiving objects: 100% (603/603), 53.29 KiB, done.Resolving deltas: 100% (174/174), done.Can clone gitolite-admin?............YESUMASK for .gitolite.rc is 0007? ............YES
If you got all YES – congrats! You can go to next step.
5. Server up
Application can be started with next command:
# For test purposessudo -u gitlab bundle exec rails s -e production# As daemonsudo -u gitlab bundle exec rails s -e production -d
6. Run resque process (for processing queue).
# Manuallysudo -u gitlab bundle exec rake environment resque:work QUEUE=* RAILS_ENV=production BACKGROUND=yes# Gitlab start script./resque.sh
*Ok – we have a working application now. * *But keep going – there are some thing that should be done *
Nginx && Unicorn
Install Nginx
sudo apt-get install nginx
Unicorn
cd /home/gitlab/gitlabsudo -u gitlab cp config/unicorn.rb.orig config/unicorn.rbsudo -u gitlab bundle exec unicorn_rails -c config/unicorn.rb -E production -D
Edit /etc/nginx/nginx.conf. Add next code to http section:
upstream gitlab {server unix:/home/gitlab/gitlab/tmp/sockets/gitlab.socket;}server {listen YOUR_SERVER_IP:80;server_name gitlab.YOUR_DOMAIN.com;root /home/gitlab/gitlab/public;# 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_redirect off;# you need to change this to "https", if you set "ssl" directive to "on"proxy_set_header X-FORWARDED_PROTO http;proxy_set_header Host gitlab.YOUR_SUBDOMAIN.com:80;proxy_set_header X-Real-IP $remote_addr;proxy_pass http://gitlab;}}
gitlab.YOUR_DOMAIN.com – change to your domain.
Restart nginx:
/etc/init.d/nginx restart
Create init script in /etc/init.d/gitlab
#! /bin/bash### BEGIN INIT INFO# Provides: gitlab# Required-Start: $local_fs $remote_fs $network $syslog redis-server# Required-Stop: $local_fs $remote_fs $network $syslog# Default-Start: 2 3 4 5# Default-Stop: 0 1 6# Short-Description: GitLab git repository management# Description: GitLab git repository management### END INIT INFODAEMON_OPTS="-c /home/gitlab/gitlab/config/unicorn.rb -E production -D"NAME=unicornDESC="Gitlab service"PID=/home/gitlab/gitlab/tmp/pids/unicorn.pidRESQUE_PID=/home/gitlab/gitlab/tmp/pids/resque_worker.pidcase "$1" instart)CD_TO_APP_DIR="cd /home/gitlab/gitlab"START_DAEMON_PROCESS="bundle exec unicorn_rails $DAEMON_OPTS"START_RESQUE_PROCESS="./resque.sh"echo -n "Starting $DESC: "if [ `whoami` = root ]; thensudo -u gitlab sh -c "$CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS && $START_RESQUE_PROCESS"else$CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS && $START_RESQUE_PROCESSfiecho "$NAME.";;stop)echo -n "Stopping $DESC: "kill -QUIT `cat $PID`kill -QUIT `cat $RESQUE_PID`echo "$NAME.";;restart)echo -n "Restarting $DESC: "kill -USR2 `cat $PID`kill -USR2 `cat $RESQUE_PID`echo "$NAME.";;reload)echo -n "Reloading $DESC configuration: "kill -HUP `cat $PID`kill -HUP `cat $RESQUE_PID`echo "$NAME.";;*)echo "Usage: $NAME {start|stop|restart|reload}" >&2exit 1;;esacexit 0
Adding permission:
sudo chmod +x /etc/init.d/gitlab
When server is rebooted then gitlab must starting:
sudo insserv gitlab
*This step didn’t work for me so what I did was to edit the rc.local file.
nano /etc/rc.local
And added the following to the rc.local file to start the GitLab when the server reboots
cd /home/gitlab/gitlabsudo -u gitlab bundle exec unicorn_rails -c config/unicorn.rb -E production -D/etc/init.d/nginx restartsudo /etc/init.d/gitlab restart
Now you can start/restart/stop gitlab like:
sudo /etc/init.d/gitlab restart
Test your installation
If all went well, you should be able to connect to your server at http://yoursevername. The default login info is as follows:
email: admin@local.hostpassword : 5ivel!fe
Enjoy your new GIT server!
Reference: GitLab
Posted in GIT
- GitLab Installation on Ubuntu Server 12.04
- ReviewBoard on ubuntu 9.0.4 Server --- Installation
- ReviewBoard on ubuntu 12 Server --- Installation
- OpenStack Installation on Ubuntu 12.04 LTS
- PostgreSQL installation on Ubuntu
- Install gitlab manually on ubuntu
- brl-cad installation on ubuntu
- Fastx-toolkit installation on Ubuntu
- PHP Composer: installation on ubuntu
- MATLAB_2015b installation on Ubuntu 16.04
- OpenNI2 Installation on Ubuntu 14.04
- TinyOS-2.1.1 Installation on Ubuntu 12.04 and Hello World
- Latest node.js & npm installation on Ubuntu 12.04
- Installation of the Robocup 3D simspark simulation server on Ubuntu
- VNC-Server installation on CentOS 7
- Wkhtmltopdf Installation on Centos 7 Server
- protractor installation problems on Windows 2012 Server
- Ubuntu 12.04 安装 GitLab
- 文件上传 带进度条 多种风格 非常漂亮!
- log4j:ERROR Category option " 1 " not a decimal integer.错误解决
- web.xml 配置
- FLASH组件 DataGrid中文及字体样式设置(写as3类)
- 如何制作[*.fla]形态的组件(Component)
- GitLab Installation on Ubuntu Server 12.04
- Android:getWritableDatabase/getReadableDatabase无法调用onCreate
- 爱情如江南的青花瓷
- HDU 4417 Super Mario(划分树)#by zh
- 黑马程序员——java集合元素排序存储操作
- 如何用zlib压缩内存数据
- Eclispse的adb.exe问题
- uifont 字体大全
- 音频放大器跟随小型化趋势