官网:https://github.com/gitlabhq/gitlabhq/blob/6-7-stable/doc/install/installation.md#important-notes系
官网:https://github.com/gitlabhq/gitlabhq/blob/6-7-stable/doc/install/installation.md#important-notes系统,ubuntu 14.01/64概述:gitlab安装包括安装下列组件1、Packages / Dependencies2、Ruby3、System Users4、GitLab shell5、Database6、GitLab7、Nginx首先修改ubuntu 更新源URL将 /etc/apt/sources.list 文件的 所有URL 改为: http://old-releases.ubuntu.com/ubuntu/1、依赖包/更新下。# run as root!apt-get update -yapt-get upgrade -yapt-get install sudo -y2、安装vimsudo apt-get install -y vimsudo update-alternatives --set editor /usr/bin/vim.basic3、安装所需要的包: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 logrotate4、确保你已经正确安装git# Install Gitsudo apt-get install -y git-core# Make sure Git is version 1.7.10 or higher, for example 1.7.12 or 1.8.4git --version5、删除它、编译源代码。# Remove packaged Gitsudo apt-get remove git-core# Install dependenciessudo apt-get install -y libcurl4-openssl-dev libexpat1-dev gettext libz-dev libssl-dev build-essential# Download and compile from sourcecd /tmpcurl --progress https://git-core.googlecode.com/files/git-1.8.5.2.tar.gz | tar xzcd git-1.8.5.2/make prefix=/usr/local all# Install into /usr/local/binsudo make prefix=/usr/local install# When editing config/gitlab.yml (Step 6), change the git bin_path to /usr/local/bin/git6、为了接收邮件通知,请确保安装邮件服务器。sudo apt-get install -y postfix7、 安装 rubysudo apt-get remove ruby1.8mkdir /tmp/ruby && cd /tmp/rubycurl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz | tar xzcd ruby-2.0.0-p353./configure --disable-install-rdocmakesudo make installsudo gem install bundler --no-ri --no-rdoc这步可能报错,使用淘宝源8、创建git用户sudo adduser --disabled-login --gecos 'GitLab' git9、gitlab Shell是一个SSH访问和存储管理软件的开发,专门为gitlab提供。# Go to home directorycd /home/git# Clone gitlab shellsudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-shell.git -b v1.9.1cd gitlab-shellsudo -u git -H cp config.yml.example config.yml# Edit config and replace gitlab_url# with something like 'http://domain.com/'sudo -u git -H editor config.yml# Do setupsudo -u git -H ./bin/install10、 数据库安装,官网建议用的数据库是 PostgreSQL 我用的是mysql数据库mysql数据库安装# Install the database packagessudo apt-get install -y mysql-server mysql-client libmysqlclient-dev# Pick a database root password (can be anything), type it and press enter# Retype the database root password and press enter# Secure your installation.sudo mysql_secure_installation# Login to MySQLmysql -u root -p# Type the database root password# Create a user for GitLab# do not type the 'mysql>', this is part of the prompt# change $password in the command below to a real password you pickmysql> CREATE USER 'git'@'localhost' IDENTIFIED BY '$password';# Create the GitLab production databasemysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;# Grant the GitLab user necessary permissions on the table.mysql> GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'git'@'localhost';# Quit the database sessionmysql> /q# Try connecting to the new database with the new usersudo -u git -H mysql -u git -p -D gitlabhq_production# Type the password you replaced $password with earlier# You should now see a 'mysql>' prompt# Quit the database sessionmysql> /q# You are done installing the database and can go back to the rest of the installation.启动数据库 ,看下是否启动11、进入git home目录cd /home/git克隆GitLab 库sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 6-7-stable gitlab 期间有些慢cd /home/git/gitlab配置cd /home/git/gitlab# Copy the example GitLab configsudo -u git -H cp config/gitlab.yml.example config/gitlab.yml# Make sure to change "localhost" to the fully-qualified domain name of your# host serving GitLab where necessary## If you installed Git from source, change the git bin_path to /usr/local/bin/gitsudo -u git -H editor config/gitlab.yml# Make sure GitLab can write to the log/ and tmp/ directoriessudo chown -R git log/sudo chown -R git tmp/sudo chmod -R u+rwX log/sudo chmod -R u+rwX tmp/# Create directory for satellitessudo -u git -H mkdir /home/git/gitlab-satellites# Create directories for sockets/pids and make sure GitLab can write to themsudo -u git -H mkdir tmp/pids/sudo -u git -H mkdir tmp/sockets/sudo chmod -R u+rwX tmp/pids/sudo chmod -R u+rwX tmp/sockets/# Create public/uploads directory otherwise backup will failsudo -u git -H mkdir public/uploadssudo chmod -R u+rwX public/uploads# Copy the example Unicorn configsudo -u git -H cp config/unicorn.rb.example config/unicorn.rb# Enable cluster mode if you expect to have a high load instance# Ex. change amount of workers to 3 for 2GB RAM serversudo -u git -H editor config/unicorn.rb# Copy the example Rack attack configsudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb# Configure Git global settings for git user, useful when editing via web# Edit user.email according to what is set in gitlab.ymlsudo -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 进行设置# Mysqlsudo -u git cp config/database.yml.mysql config/database.yml# Make config/database.yml readable to git onlysudo -u git -H chmod o-rwx config/database.yml12、安装Gemscd /home/git/gitlab# Or if you use MySQL (note, the option says "without ... postgres")sudo -u git -H bundle install --deployment --without development test postgres aws成功后,最下端会显示 登录gitlab的账号和密码 如下Administrator account created:[email protected]!fe13、初始化数据库,sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production# Type 'yes' to create the database tables.# When done you see 'Administrator account created:'13、安装脚本启动脚本sudo cp lib/support/init.d/gitlab /etc/init.d/gitlabsudo cp lib/support/init.d/gitlab.default.example /etc/default/gitlab14、gitlab开机启动:sudo update-rc.d gitlab defaults 21建立logrotatesudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab检查应用程序的状态检查gitlab及其环境的配置是正确的:sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production开始你的gitlab实例启动 gitlabsudo service gitlab start# orsudo /etc/init.d/gitlab restartsudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production15、nginx安装使用部署sudo apt-get install -y nginxsudo cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlabsudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab# Change YOUR_SERVER_FQDN to the fully-qualified# domain name of your host serving GitLab.sudo editor /etc/nginx/sites-available/gitlab启动nginxsudo service nginx restart完成确保你没有错过任何运行更彻底的检查sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production如果所有的项目都是绿色的,那么恭喜你成功安装gitlab!16、更改gitlab端口默认web端口为80:,为了便于开放到外部访问,肯定需要把端口改为其他的,比如3000root@ubuntu:/home/git/gitlab# vim /home/git/gitlab-shell/config.yml更改第四行URL gitlab_url: "http://192.168.83.113:3000/"root@ubuntu:/home/git/gitlab# vim /home/git/gitlab/config/gitlab.yml更改 host、port 为: host: 192.168.83.113 port: 3000./gitlab 配置文件的listen 192.168.1.80:99 的端口设置为一致 .18、初始登录root@ubuntu:/home/git/gitlab# vim /etc/nginx/sites-available/default 更改端口 listen 3000 default_server; listen [::]:3000 default_server ipv6only=on;root@ubuntu:/home/git/gitlab# vim /etc/nginx/sites-available/gitlab listen 192.168.83.113:3000 default_server; 检查端口被监听起来没有root@ubuntu:/home/git/gitlab# netstat -ano |grep 3000tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN off (0.00/0/0)tcp6 0 0 :::3000 :::* LISTEN off (0.00/0/0)root@ubuntu:/home/git/gitlab# netstat -ano |grep 80tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN off (0.00/0/0)unix 3 [ ] STREAM CONNECTED 148056 unix 3 [ ] STREAM CONNECTED 148083 /var/run/mysqld/mysqld.sockunix 3 [ ] STREAM CONNECTED 148055 unix 3 [ ] STREAM CONNECTED 148052 unix 3 [ ] STREAM CONNECTED 148058 unix 3 [ ] STREAM CONNECTED 148053 unix 3 [ ] STREAM CONNECTED 148059 unix 3 [ ] STREAM CONNECTED 148068 /var/run/mysqld/mysqld.sockunix 3 [ ] STREAM CONNECTED 10580 unix 3 [ ] STREAM CONNECTED 148067 unix 3 [ ] STREAM CONNECTED 148054 unix 3 [ ] STREAM CONNECTED 148082 unix 3 [ ] STREAM CONNECTED 148057 然后浏览器打开访问 http://192.168.83.113:3000/