mysql> CREATE USER 'gitlab'@'localhost'> mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
mysql> GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX,> 6. 安装gitlab主程序
su - git #切换至git帐号下执行cd /home/git/# Clone GitLab repositorygit clone https://github.com/gitlabhq/gitlabhq.git gitlabcd /home/git/gitlab
# Checkout to stable> git checkout 5-2-stable
# Make sure GitLab can write to the log/ and tmp/ directories# 修改账户权限(注意保持/home/git目录及子目录属主、组为git用户) chmod -R u+rwX log/
chmod -R u+rwX tmp/
# Create directory for satellites
mkdir /home/git/gitlab-satellites
# Create directories for sockets/pids and make sure GitLab can write to them
mkdir tmp/pids
mkdir tmp/sockets
# Create public/uploads directory otherwise backup will fail
mkdir public/uploads
chmod -R u+rwX tmp/pids
chmod -R u+rwX tmp/sockets
chmod -R u+rwX public/uploads
# Copy the example Puma config
cp config/puma.rb.example config/puma.rb # 该配置文件默认即可
# Configure Git global settings for git user, useful when editing via web
# Edit user.email according to what is set in gitlab.yml
git config --global user.name "GitLab"
git config --global user.email "gitlab@localhost"
cp config/database.yml.mysql config/database.yml
vi config/database.yml # 修改数据库账号密码, 刚才添加过gitlab这个数据库用户 直接修改成该账号即可
cp config/gitlab.yml.example config/gitlab.yml
vi config/gitlab.yml #修改host:localhost为自己的域名 git.olymtech.com 7. 安装 Gems
cd /home/git/gitlab
sudo gem install charlock_holmes --version '0.6.9.4'
#修改Bundle源地址为taobao, 首行改成 source 'http://ruby.taobao.org/'
vi Gemfile
#使用mysql数据库,排除 postgres等
cd /home/git/gitlab
bundle install --deployment --without development test postgres
注:这里在安装过程中发现有个坑,无论是ruby官网还是淘宝都找不到modernizr-2.6.2版本。
错误如下:
git@gitserver:~/gitlab$ bundle install --deployment --without development test postgres
Fetching source index from http://ruby.taobao.org/
Could not find modernizr-2.6.2 in any of the sources
官网跟淘宝 ruby源 都没了这个包 解决办法是先手动去下载 然后安装
git@gitserver:~/gitlab$ wget http://rubygems.org/gems/modernizr-2.6.2.gem
git@gitserver:~/gitlab$ sudo gem install modernizr
sudo gem install modernizr
然后修改 gitlab源码包里面的 Gemfile 跟 Gemfile.lock文件 ,把里面 modernizr包名换成 modernizr-rails
版本全部换成 2.7.1 然后再运行 bundle install --deployment --without development test postgres 即可 8.初始化数据库并启用高级功能
bundle exec rake gitlab:setup RAILS_ENV=production
整个gitlab安装完成后默认创建的帐号密码:
Administrator account created:
login.........admin@local.host
password......5iveL!fe 9.检测一下程序状态
bundle exec rake gitlab:check RAILS_ENV=production
检测结果:
Checking Environment ...
Git configured for git user? ... yes
Has python2? ... yes
python2 is supported version? ... yes
Checking Environment ... Finished
Checking GitLab Shell ...
GitLab Shell version >= 1.4.0 ? ... OK (1.4.0)
Repo base directory exists? ... yes
Repo base directory is a symlink? ... no
Repo base owned by git:git? ... yes
Repo base access is drwxrws---? ... yes
post-receive hook up-to-date? ... yes
post-receive hooks in repos are links: ...
Administrator / olymtechtest ... repository is empty
Checking GitLab Shell ... Finished
Checking Sidekiq ...
Running? ... yes
Checking Sidekiq ... Finished
Checking GitLab ...
Database config exists? ... yes
Database is SQLite ... no
All migrations up? ... yes
GitLab config exists? ... yes
GitLab config outdated? ... no
Log directory writable? ... yes
Tmp directory writable? ... yes
Init script exists? ... yes
Init script up-to-date? ... no
Try fixing it:
Redownload the init script
For more information see:
doc/install/installation.md in section "Install Init Script"
Please fix the error above and rerun the checks.
Projects have satellites? ...
Administrator / olymtechtest ... can't create, repository is empty
Redis version >= 2.0.0? ... yes
Your git bin path is "/usr/bin/git"
Git version >= 1.7.10 ? ... yes (1.9.1)
Checking GitLab ... Finished 10.安装init脚本(以root身份,否则可能没权限)
wget https://raw.github.com/gitlabhq/gitlabhq/5-2-stable/lib/support/init.d/gitlab
mv gitlab /etc/init.d/
service gitlab start 启动gitlab服务。
至此:上面的git+gitlab+mysql+redis
环境安装完成 ====安装nginx作为web服务器====
nginx安装(以root身份):
apt-get install
nginx
增加nginx配置文件:
wget https://raw.github.com/gitlabhq/gitlabhq/5-2-stable/lib/support/nginx/gitlab -P /tmp
mv
/tmp/gitlab /etc/nginx/sites-enabled/
vi
/etc/nginx/sites-enabled/gitlab 编辑配置文件,修改配置文件中直接监听80端口,
域名为自定义的访问域名即可:
server {
listen
80;
server_name
git.abc.com;
.....
}
需注意的是nginx主配置文件/etc/nginx/nginx.conf
中开启include
/etc/nginx/sites-enabled/*;
使其子配置文件生效。
启动服务:
service nginx
restart
接下来手动hosts指向下,期待已久的站点页面就可以访问了: