在debian上搭建gitlab代码管理

简单记录我的配置的过程~~~~


自己懒的归类编辑啦,大家凑活的参考下吧~



在debian上搭建gitlab代码管理
## RUN AS ROOT
#配置 web环境
apt-get install -y lamp-server^
#Gitlab Requirements
apt-get install -y wget curl gcc checkinstall libxml2-dev libxslt-dev sqlite3 libsqlite3-dev libcurl4-openssl-dev libreadline6-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 postfix apache2-prefork-dev libapr1-dev libaprutil1-dev
#Install Ruby
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
tar xzvf ruby-1.9.3-p194.tar.gz
cd ruby-1.9.3-p194
./configure
make
make install
##Install Gitolite
                        
#Create user for git:
adduser \
  --system \
  --shell /bin/sh \
  --gecos 'git version control' \
  --group \
  --disabled-password \
  --home /home/git \
  git
#Create user for GitLab in ubuntu/debian
adduser --disabled-login --gecos 'gitlab system' gitlab
#Add your user to the git group:
usermod -a -G git gitlab
#Generate key:
sudo -H -u gitlab ssh-keygen -q -N '' -t rsa -f /home/gitlab/.ssh/id_rsa
#Clone GitLab's fork of the Gitolite source code:
cd /home/git
sudo -H -u git git clone -b gl-v304 https://github.com/gitlabhq/gitolite.git /home/git/gitolite
#Setup:
sudo -u git -H mkdir bin
sudo -u git sh -c 'echo -e "PATH=\$PATH:/home/git/bin\nexport PATH" >> /home/git/.profile'
sudo -u git sh -c 'gitolite/install -ln /home/git/bin'
cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub
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 -u git -H sed -i 's/0077/0007/g' /home/git/.gitolite.rc
#Permissions:
chmod -R g+rwX /home/git/repositories/
chown -R git:git /home/git/repositories/
#clone admin repo to add localhost to known_hosts
# & be sure your user has access to gitolite
sudo -u gitlab -H git clone git@localhost:gitolite-admin.git /tmp/gitolite-admin
# if succeed  you can remove it
sudo rm -rf /tmp/gitolite-admin
sudo gem install charlock_holmes --version '0.6.8'
sudo pip install pygments
sudo gem install bundler
cd /home/gitlab
# Get gitlab code. Use this for stable setup
sudo -H -u gitlab git clone -b stable https://github.com/gitlabhq/gitlabhq.git gitlab
cd gitlab
# Rename config files
sudo -u gitlab cp config/gitlab.yml.example config/gitlab.yml
mysql -u root -p
create database gitlabdb;
GRANT ALL PRIVILEGES ON gitlabdb.* to 'ugitlab'@'localhost' IDENTIFIED BY 'gitlabpass';
quit;
sudo -u gitlab cp config/database.yml.example config/database.yml
#Set your git info
git config --global user.name "GitLab Server"
git config --global user.email [email protected]
#Install gems
sudo -u gitlab -H bundle install --without development test --deployment
#setup database
sudo -u gitlab bundle exec rake gitlab:app:setup RAILS_ENV=production
#setup gitlab hooks
sudo cp ./lib/hooks/post-receive /home/git/.gitolite/hooks/common/post-receive
sudo chown git:git /home/git/.gitolite/hooks/common/post-receive
#check status
sudo -u gitlab bundle exec rake gitlab:app:status RAILS_ENV=production
#start application
# As daemon
sudo -u gitlab bundle exec rails s -e production -d
cd /home/gitlab/gitlab
sudo -u gitlab cp config/unicorn.rb.example config/unicorn.rb
sudo -u gitlab bundle exec unicorn_rails -c config/unicorn.rb -E production -D
sudo gem install passenger
sudo passenger-install-apache2-module
#配置apache 的proxy
sudo a2enmod proxy proxy_balancer proxy_http rewrite
LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.15/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.15
PassengerRuby /usr/local/bin/ruby
#加个虚拟主机
<VirtualHost *:80>
      ServerName git.frostybot.com
      # !!! Be sure to point DocumentRoot to 'public'!
      DocumentRoot /home/gitlab/gitlab/public
      <Directory /home/gitlab/gitlab/public>
         # This relaxes Apache security settings.
         AllowOverride all
         # MultiViews must be turned off.
         Options -MultiViews
      </Directory>
   </VirtualHost>
a2ensite gitlab
sudo service apache2 restart
#这样就可以了
URL http://your_ip_address
email [email protected]
password 5iveL!fe
gitlab的一些个管理
#get the id of resque (if running)
ps aux |grep -i resque
#Kill resque (if running)
sudo kill -QUIT RESQUE_PID shut resque down
#delete existing pid file
sudo rm /home/gitlab/gitlab/tmp/pids/resque_worker.pid
#Change owner if fileowner isn't gitlab
sudo find /home/gitlab/ -! -uid `id -u gitlab` -print0 |xargs -0r chown gitlab:gitlab
#run resque as gitlab user
sudo -u gitlab sh -l -c "cd /home/gitlab/gitlab > /dev/null 2>&1 && ./resque.sh"


本文出自 “峰云,就她了。” 博客,谢绝转载!

你可能感兴趣的:(Debian,centos,接口,gitlab,gitlab,gitlab)