CentOS源码安装GitLab汉化版

2016-07-12 10:25:32来源:oschina作者:董松人点击

GitLab官网未提供中文语言界面,网络搜了很久,终于找到了集成汉化补丁的源码库。从8.0开始,GitLab使用gitlab-git-http-server处理Web请求,该程序使用Go语言开发。如无法下载Go语言开发包,可以暂时从百度网盘地址:http://pan.baidu.com/s/1hq1mrDM下载。

示例环境:



软件
版本


CentOS
6.7x86_64


Git
2.6.2


Ruby
2.2.3


Node.js
4.2.2


Redis
3.0.5


MariaDB
10.0.21


GitLab
8.0.5汉化版


GitLab Shell
2.6.6


Nginx
1.8.0


Go
1.5.1


Gitlab-git-http-server
0.2.14


一、修改Yum源为阿里云提高下载速度


mv/etc/yum.repos.d/CentOS-Base.repo/etc/yum.repos.d/CentOS-Base.repo.backup
wget-O/etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-6.repo

二、安装依赖软件包


yum-yinstalllibicu-develpatchgcc-c++readline-develzlib-devellibffi-developenssl-develmakeautoconfautomakelibtoolbisonlibxml2-devellibxslt-devellibyaml-develzlib-developenssl-develcpioexpat-develgettext-develcurl-develperl-ExtUtils-CBuilderperl-ExtUtils-MakeMakercmakepcre-devel

三、安装Git

查看当前git版本

git--version

如果git版本小于1.7.10则先卸载

rpm-e--nodepsgit

下载最新git源码包并编译安装

cd/App/src/
wgethttps://www.kernel.org/pub/software/scm/git/git-2.6.2.tar.xz
tarJxfgit-2.6.2.tar.xz
cdgit-2.6.2
./configure--prefix=/App/git
make&&makeinstall
echo'exportPATH=/App/git/bin:$PATH'>>/etc/profile

四、安装Ruby


cd/App/src/
wgethttps://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.3.tar.gz
tarzxfruby-2.2.3.tar.gz
cdruby-2.2.3
./configure--prefix=/App/ruby--disable-install-rdoc
make&&makeinstall
echo'exportPATH=/App/ruby/bin:$PATH'>>/etc/profile

退出shell重新登录后修改RubyGems 镜像为淘宝提高下载速度

gemsources--addhttps://ruby.taobao.org/--removehttps://rubygems.org/
geminstallbundler--no-ri--no-rdoc

五、安装Node.js


cd/App/src/
wget
tarzxfnode-v4.2.2-linux-x64.tar.gz
mvnode-v4.2.2-linux-x64/App/nodejs
echo'exportPATH=/App/nodejs/bin:$PATH'>>/etc/profile

六、安装Go


cd/App/src/
wget'http://110.53.72.42/ws.cdn.baidupcs.com/file/73fe663350c79d73b16f3f7a899ae61e?bkt=p2-qd-111&xcode=045297b91be2c0d5abc14f790e7d3ffdf671caf5807981c0a271ffda32bcb45b&fid=4211908481-250528-339030289033817&time=1446094636&sign=FDTAXGERLBH-DCb740ccc5511e5e8fedcff06b081203-Ep%2BKrIXVu6atuVFIbrsENgAGYKI%3D&to=lc&fm=Nin,B,U,nc&sta_dx=74&sta_cs=18&sta_ft=gz&sta_ct=5&fm2=Ningbo,B,U,nc&newver=1&newfm=1&secfm=1&flow_ver=3&pkey=140073fe663350c79d73b16f3f7a899ae61e196a4a54000004a44a37&sl=75169870&expires=8h&rt=sh&r=730089280&mlogid=6993558648282556150&vuk=2013529015&vbdid=1317867065&fin=go1.5.1.linux-amd64.tar.gz&fn=go1.5.1.linux-amd64.tar.gz&slt=pm&uta=0&rtype=1&iv=0&isw=0&dp-logid=6993558648282556150&dp-callid=0.1.1&wshc_tag=0&wsts_tag=5631a72c&wsid_tag=6a02a842&wsiphost=ipdbm'-Ogo1.5.1.linux-amd64.tar.gz
tarzxfgo1.5.1.linux-amd64.tar.gz
mvgo/App/
cat>>/etc/profile<exportGOROOT=/App/go
exportGOARCH=amd64
exportGOOS=linux
exportGOBIN=/$GOROOT/bin
exportGOPATH=/root/code/go
exportPATH=/$GOBIN:/$PATH
EOF

七、安装Redis


cd/App/src/
wgethttp://download.redis.io/releases/redis-3.0.5.tar.gz
tarzxfredis-3.0.5.tar.gz
cdredis-3.0.5
makePREFIX=/App/redisinstall
echo'exportPATH=/App/redis/bin:$PATH'>>/etc/profile

添加Redis配置 /App/redis/redis.conf

daemonizeyes
pidfile/App/redis/redis.pid
port6379
tcp-backlog60000
timeout0
tcp-keepalive60
loglevelwarning
logfile"/App/redis/redis.log"
syslog-enabledno
databases16
save9001
save30010
save6010000
stop-writes-on-bgsave-erroryes
rdbcompressionyes
rdbchecksumyes
dbfilenamedump.rdb
dir/App/redis
slave-serve-stale-datayes
repl-diskless-syncyes
repl-diskless-sync-delay5
repl-ping-slave-period10
repl-timeout60
repl-disable-tcp-nodelayno
slave-priority100
maxclients60000
maxmemory-policynoeviction
appendonlyno
appendfilename"appendonly.aof"
appendfsynceverysec
no-appendfsync-on-rewriteno
auto-aof-rewrite-percentage100
auto-aof-rewrite-min-size64mb
aof-load-truncatedyes
lua-time-limit5000
slowlog-log-slower-than10000
slowlog-max-len128
latency-monitor-threshold0
hash-max-ziplist-entries512
hash-max-ziplist-value64
list-max-ziplist-entries512
list-max-ziplist-value64
set-max-intset-entries512
zset-max-ziplist-entries128
zset-max-ziplist-value64
hll-sparse-max-bytes3000
activerehashingyes
client-output-buffer-limitnormal000
client-output-buffer-limitslave256mb64mb60
client-output-buffer-limitpubsub32mb8mb60
hz10
aof-rewrite-incremental-fsyncyes

启动Redis

/App/redis/bin/redis-server/App/redis/redis.conf

八、安装配置MariaDB


cd/App/src/
wgethttp://mirrors.ctyun.cn/MariaDB/mariadb-10.0.21/source/mariadb-10.0.21.tar.gz
tarzxfmariadb-10.0.21.tar.gz
cdmariadb-10.0.21
cmake./
-DCMAKE_BUILD_TYPE:STRING=Release/
-DCMAKE_INSTALL_PREFIX:PATH=/App/mariadb/
-DDEFAULT_CHARSET=utf8/
-DDEFAULT_COLLATION=utf8_general_ci/
-DWITH_EMBEDDED_SERVER:BOOL=OFF/
-DWITH_UNIT_TESTS:BOOL=OFF/
-LAH
make&&makeinstall
cpsupport-files/mysql.server/etc/init.d/mariadb
chmodu+x/etc/init.d/mariadb
echo'exportPATH=/App/mariadb/bin:$PATH'>>/etc/profile

修改MariaDB配置 /etc/my.cnf

[client]
port=3306
socket=/tmp/mysql.sock
[mysqld]
user=mysql
port=3306
socket=/tmp/mysql.sock
server-id=1
log-bin=bin.log
log-error=error.log
pid-file=mysql.pid
long_query_time=1
slow_query_log
slow_query_log_file=slow.log
binlog_cache_size=4M
binlog_format=mixed
max_binlog_cache_size=16M
max_binlog_size=1G
expire_logs_days=30
ft_min_word_len=4
back_log=4096
max_allowed_packet=64M
max_connections=65536
max_connect_errors=100
join_buffer_size=1M
read_buffer_size=1M
read_rnd_buffer_size=1M
sort_buffer_size=1M
query_cache_size=64M
table_open_cache=2048
thread_cache_size=256
max_heap_table_size=64M
tmp_table_size=64M
thread_stack=192K
connect_timeout=600
interactive_timeout=600
wait_timeout=600
thread_concurrency=8
local-infile=0
skip-show-database
skip-name-resolve
skip-external-locking
#***MyISAM
key_buffer_size=512M
bulk_insert_buffer_size=64M
myisam_sort_buffer_size=32M
myisam_max_sort_file_size=1G
myisam_repair_threads=1
myisam_recover
#***INNODB
innodb_buffer_pool_size=4G
innodb_additional_mem_pool_size=32M
innodb_data_file_path=ibdata:32M:autoextend
innodb_read_io_threads=8
innodb_write_io_threads=8
innodb_file_per_table=1
innodb_flush_log_at_trx_commit=2
innodb_lock_wait_timeout=120
innodb_log_buffer_size=8M
innodb_log_file_size=256M
innodb_log_files_in_group=3
innodb_max_dirty_pages_pct=10
innodb_thread_concurrency=16
#innodb_force_recovery=4
#***ReplicationSlave
#read-only
#skip-slave-start
relay-log=relay.log
log-slave-updates
[mysqldump]
quick
max_allowed_packet=32M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size=512M
sort_buffer_size=512M
read_buffer=8M
write_buffer=8M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
open-files-limit=60000

初始化MariaDB

useradd-s/bin/false-Mmysql
/App/mariadb/scripts/mysql_install_db--basedir=/App/mariadb--datadir=/App/mariadb/data--user=mysql

启动MariaDB

/etc/init.d/mariadbstart

登录MariaDB创建数据库并授权

mysql-uroot-p
CREATEDATABASE`gitlabhq_production`;
GRANTSELECT,INSERT,UPDATE,DELETE,CREATE,CREATETEMPORARYTABLES,DROP,INDEX,ALTER,LOCKTABLESON`gitlabhq_production`.*TO'git'@'127.0.0.1'IDENTIFIEDBY'PASSWORD';
GRANTSELECT,INSERT,UPDATE,DELETE,CREATE,CREATETEMPORARYTABLES,DROP,INDEX,ALTER,LOCKTABLESON`gitlabhq_production`.*TO'git'@'localhost'IDENTIFIEDBY'PASSWORD';
FLUSHPRIVILEGES;
QUIT;

九、安装配置GitLab


useradd--system-s/bin/bash--comment'GitLab'-m-d/home/gitgit

修改git家目录权限,否则访问gitlab.socket报权限错误

chmod755/home/git

切换至git用户

su-git
gitclonehttps://gitlab.com/larryli/gitlab.git-b8-0-zhgitlab

配置GitLab

cdgitlab/
cpconfig/gitlab.yml.exampleconfig/gitlab.yml

修改gitlab.yml配置,将行host: localhost 修改为本机IP地址或者域名,如为域名,确保域名映射本机地址,此时需修改/etc/hosts文件


修改 gitlab.yml,配置git路径行bin_path: /usr/bin/git 为bin_path: /App/git/bin/git


新建卫星目录,拷贝示例文件,修改权限

mkdir-p/home/git/gitlab-satellites
cpconfig/secrets.yml.exampleconfig/secrets.yml
chmod0600config/secrets.yml
chmod-Ru+rwX,go-wlog/
chmod-Ru+rwXtmp/
chmod-Ru+rwXtmp/pids/
chmod-Ru+rwXtmp/sockets/
chmod-Ru+rwXpublic/uploads/
chmod0750public/uploads/
chmod-Rug+rwX,o-rwx/home/git/repositories/
chmod-Rug-s/home/git/repositories/
find/home/git/repositories/-typed-print0|xargs-0chmodg+s
cpconfig/unicorn.rb.exampleconfig/unicorn.rb
cpconfig/initializers/rack_attack.rb.exampleconfig/initializers/rack_attack.rb
gitconfig--globalcore.autocrlfinput
cpconfig/resque.yml.exampleconfig/resque.yml

修改Redis相关配置config/resque.yml文件 production:unix:/var/run/redis/redis.sock 为production: redis://127.0.0.1:6379


数据库配置

cpconfig/database.yml.mysqlconfig/database.yml

修改 config/database.yml 前段 PRODUCTION 部分内容,password: "secure password" 修改为password:"PASSWORD"

chmodo-rwxconfig/database.yml

修改Gemfile首行内容 source "https://rubygems.org" 修改为 source "https://ruby.taobao.org"。

bundleinstall--deployment--withoutdevelopmenttestpostgresawskerberos

十、安装GitLab Shell


bundleexecrakegitlab:shell:install[v2.6.6]REDIS_URL=redis://127.0.0.1:6379RAILS_ENV=production

十一、安装gitlab-git-http-server


cd/home/git
gitclonehttps://gitlab.com/gitlab-org/gitlab-git-http-server.git-b0.2.14
cdgitlab-git-http-server
make

注意:GitLab 8.0对应0.2.14版,安装最新版可能有未知问题。本人首次安装最新版0.3.0时,clone代码报错如下图:

wKioL1Y256Shudc5AAFiva4_eXU160.jpg


十二、初始化数据库并激活高级功能


bundleexecrakegitlab:setupRAILS_ENV=productionGITLAB_ROOT_PASSWORD=newpassword

GITLAB_ROOT_PASSWORD 值为管理员 root 登录密码本例设为 newpassword

十三、切换为root用户后拷贝服务脚本


exit
cp/home/git/gitlab/lib/support/init.d/gitlab/etc/init.d/

十四、root权限配置Logrotate


cp/home/git/gitlab/lib/support/logrotate/gitlab/etc/logrotate.d/

十五、检查应用状态


su-git
cdgitlab/
bundleexecrakegitlab:env:infoRAILS_ENV=production

十六、编译静态文件


bundleexecrakeassets:precompileRAILS_ENV=production

十七、切换至root用户安装Nginx


exit
cd/App/src/
wgethttp://nginx.org/download/nginx-1.8.0.tar.gz
tarzxfnginx-1.8.0.tar.gz
cdnginx-1.8.0
./configure/
--prefix=/App/nginx/
--with-http_stub_status_module/
--with-http_gzip_static_module/
--without-http_auth_basic_module/
--without-http_autoindex_module/
--without-http_browser_module/
--without-http_empty_gif_module/
--without-http_geo_module/
--without-http_limit_conn_module/
--without-http_limit_req_module/
--without-http_map_module/
--without-http_memcached_module/
--without-http_referer_module/
--without-http_split_clients_module/
--without-http_ssi_module/
--without-http_userid_module/
--without-mail_imap_module/
--without-mail_pop3_module/
--without-mail_smtp_module/
--without-poll_module/
--without-select_module
make&&makeinstall
useradd-s/bin/falsenginx

修改Nginx配置 /App/nginx/conf/nginx.conf

usernginxnginx;
worker_processesauto;
error_loglogs/error.logerror;
pidlogs/nginx.pid;
worker_rlimit_nofile65536;
events
{
useepoll;
accept_mutexoff;
worker_connections65536;
}
http
{
includemime.types;
default_typetext/html;
charset UTF-8;
server_names_hash_bucket_size 128;
client_header_buffer_size 4k;
large_client_header_buffers 4 32k;
client_max_body_size20m;
open_file_cachemax=65536inactive=60s;
open_file_cache_valid80s;
open_file_cache_min_uses1;
log_formatmain'$remote_addr-$remote_user[$time_local]"$request"'
'$status$body_bytes_sent"$http_referer"'
'"$http_user_agent""$http_x_forwarded_for"';
access_loglogs/access.logmain;
sendfileon;
server_tokensoff;
keepalive_timeout60;
gzipon;
gzip_min_length 1k;
gzip_buffers4 64k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_typestext/plaintext/cssapplication/jsonapplication/x-javascripttext/xmlapplication/xmlapplication/xml+rsstext/javascript;
upstreamgitlab
{
serverunix:/home/git/gitlab/tmp/sockets/gitlab.socketfail_timeout=0;
}
upstreamgitlab-git-http-server
{
serverunix:/home/git/gitlab/tmp/sockets/gitlab-git-http-server.socketfail_timeout=0;
}
server{
listen80;
server_name_;
root/home/git/gitlab/public;
location/
{
try_files$uri$uri/index.html$uri.html@gitlab;
}
location/uploads/
{
proxy_read_timeout300;
proxy_connect_timeout300;
proxy_redirectoff;
proxy_set_headerHost$http_host;
proxy_set_headerX-Real-IP$remote_addr;
proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;
proxy_set_headerX-Forwarded-Proto$scheme;
proxy_set_headerX-Frame-OptionsSAMEORIGIN;
proxy_passhttp://gitlab;
}
location@gitlab
{
proxy_read_timeout300;
proxy_connect_timeout300;
proxy_redirectoff;
proxy_set_headerHost$http_host;
proxy_set_headerX-Real-IP$remote_addr;
proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;
proxy_set_headerX-Forwarded-Proto$scheme;
proxy_set_headerX-Frame-OptionsSAMEORIGIN;
proxy_passhttp://gitlab;
}
location~[-///w/.]+/.git//
{
proxy_read_timeout300;
proxy_connect_timeout300;
proxy_redirectoff;
proxy_bufferingoff;
proxy_set_headerHost$http_host;
proxy_set_headerX-Real-IP$remote_addr;
proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;
proxy_set_headerX-Forwarded-Proto$scheme;
proxy_passhttp://gitlab-git-http-server;
}
location~^/(assets)/
{
root/home/git/gitlab/public;
gzip_staticon;
expiresmax;
add_headerCache-Controlpublic;
}
error_page502/502.html;
}
}

十八、SMTP相关配置

复制smtp示例配置

cp/home/git/gitlab/config/initializers/smtp_settings.rb.sample/home/git/gitlab/config/initializers/smtp_settings.rb

修改smtp_settings.rb 将enable_starttls_auto: true 修改为enable_starttls_auto: false openssl_verify_mode: 'peer' 删除或添加 # 注释其余按照自己的邮箱正常配置即可


十九、启动GitLab实例


/etc/init.d/gitlabstart

二十、浏览器打开登录页面


wKiom1Y26KSDqwh_AAYW2wo0NK0342.jpg

二十一、输入账号 root,密码为初始化数据库时自定义变量 GITLAB_ROOT_PASSWORD值

wKioL1Yw4vvSSxJTAAYASydVQBg479.jpg

本文出自 “松松” 博客,请务必保留此出处http://dongsong.blog.51cto.com/916653/1706335


最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台