CentOS源码安装GitLab汉化版

GitLab官网无中文版网络找了很久才找到集成汉化补丁的源码库。从GitLab 8.0开始使用gitlab-git-http-server处理Web请求。该程序使用Go语言开发相对旧版GitLab需加装Go编译器可以从网上下载最新的Go SDK(可能需要科学)。

示例环境

软件版本
CentOS6.7 x86_64
Git2.6.2
Python2.7.10
Ruby2.2.3
Redis3.0.5
MariaDB10.0.21
GitLab8.0.5汉化版
GitLab Shell2.6.6
Node.js4.2.1
Nginx1.8.0
Go1.5.1

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

1 2 mv  /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backupwget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

二、安装依赖软件包

1 yum -y install  libicu-devel patch gcc-c++ readline-devel zlib-devel libffi-devel openssl-devel make  autoconf automake libtool bison libxml2-devel libxslt-devel libyaml-devel zlib-devel openssl-devel cpio expat-devel gettext-devel curl-devel perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker cmake pcre-devel

三、安装Git

  • 查看当前git版本

1 git --version
  • 如果git版本小于1.7.10则先卸载

1 rpm -e --nodeps git
  • 下载最新git源码包并编译安装

1 2 3 4 5 6 7 8 9 cd  /App/src/wget https://www.kernel.org/pub/software/scm/git/git-2.6.2.tar.xz tar  Jxf git-2.6.2.tar.xzcd  git-2.6.2./configure  --prefix=/App/gitmake  && make  install   # 修改环境变量echo  'export PATH=/App/git/bin:$PATH'  >> /etc/profile

四、安装Python

1 2 3 4 5 6 7 8 9 cd  /App/src/wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tar.xztar  Jxf Python-2.7.10.tar.xzcd  Python-2.7.10./configure  --prefix=/App/pythonmake  && make  install   # 修改环境变量echo  'export PATH=/App/python/bin:$PATH'  >> /etc/profile

 

五、安装Ruby

1 2 3 4 5 6 7 8 9 cd  /App/src/wget https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.3.tar.gz tar  zxf ruby-2.2.3.tar.gzcd  ruby-2.2.3./configure  --prefix=/App/ruby  --disable-install-rdocmake  && make  install   # 修改环境变量echo  'export PATH=/App/ruby/bin:$PATH'  >> /etc/profile
  • 退出shell重新登录后修改RubyGems 镜像为淘宝提高下载速度

1 2 gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/ gem install  bundler --no-ri --no-rdoc

六、安装Go

1 2 3 4 5 6 7 8 9 10 11 12 13 14 cd  /App/src/curl -O --progress https://storage.googleapis.com/golang/go1.5.1.linux-amd64.tar.gz tar  zxf go1.5.1.linux-amd64.tar.gzmv  go /App/   # 修改环境变量cat  >> /etc/profile  << EOFexport  GOROOT=/App/goexport  GOARCH=amd64export  GOOS=linuxexport  GOBIN=\$GOROOT/binexport  GOPATH=/App/goexport  PATH=$GOBIN:\$PATHEOF

七、安装Redis

1 2 3 4 5 6 7 8 cd  /App/src/wget http://download.redis.io/releases/redis-3.0.5.tar.gz tar  zxf redis-3.0.5.tar.gzcd  redis-3.0.5make  PREFIX=/App/redis  install   # 修改环境变量echo  'export PATH=/App/redis/bin:$PATH'  >> /etc/profile
  • 添加Redis配置 /App/redis/redis.conf

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 daemonize yespidfile /App/redis/redis.pidport 6379tcp-backlog 60000timeout 0tcp-keepalive 60loglevel warninglogfile "/App/redis/redis.log"syslog-enabled nodatabases 16save 900 1save 300 10save 60 10000stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum yesdbfilename dump.rdbdir /App/redisslave-serve-stale-data yesrepl-diskless-sync yesrepl-diskless-sync-delay 5repl-ping-slave-period 10repl-timeout 60repl-disable-tcp-nodelay noslave-priority 100maxclients 60000maxmemory-policy noevictionappendonly noappendfilename "appendonly.aof"appendfsync everysecno-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100auto-aof-rewrite-min-size 64mbaof-load-truncated yeslua-time-limit 5000slowlog-log-slower-than 10000slowlog-max-len 128latency-monitor-threshold 0hash-max-ziplist-entries 512hash-max-ziplist-value 64list-max-ziplist-entries 512list-max-ziplist-value 64set-max-intset-entries 512zset-max-ziplist-entries 128zset-max-ziplist-value 64hll-sparse-max-bytes 3000activerehashing yesclient-output-buffer-limit normal 0 0 0client-output-buffer-limit slave 256mb 64mb 60client-output-buffer-limit pubsub 32mb 8mb 60hz 10aof-rewrite-incremental-fsync yes
  • 启动Redis

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

八、安装Node.js

1 2 3 4 5 6 7 cd  /App/src/wget https://nodejs.org/dist/v4.2.1/node-v4.2.1-linux-x64.tar.xztar  Jxf node-v4.2.1-linux-x64.tar.xzmv  node-v4.2.1-linux-x64 /App/nodejs   # 修改环境变量echo  'export PATH=/App/nodejs/bin:$PATH'  >> /etc/profile

九、安装MariaDB

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 cd  /App/src/wget http://mirrors.ctyun.cn/MariaDB/mariadb-10.0.21/source/mariadb-10.0.21.tar.gz tar  zxf mariadb-10.0.21.tar.gzcd  mariadb-10.0.21cmake . \-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  && make  installcp  support-files/mysql.server /etc/init.d/mariadbchmod  u+x /etc/init.d/mariadb   # 修改环境变量echo  'export PATH=/App/mariadb/bin:$PATH'  >> /etc/profile
  • 修改MariaDB配置 /etc/my.cnf

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 [client]port = 3306socket = /tmp/mysql.sock[mysqld]user = mysqlport = 3306socket = /tmp/mysql.sockserver-id = 1log-bin = bin.loglog-error = error.logpid-file = mysql.pidlong_query_time = 1slow_query_logslow_query_log_file = slow.logbinlog_cache_size = 4Mbinlog_format = mixedmax_binlog_cache_size = 16Mmax_binlog_size = 1Gexpire_logs_days = 30ft_min_word_len = 4back_log = 4096max_allowed_packet = 64Mmax_connections = 65536max_connect_errors = 100join_buffer_size = 1Mread_buffer_size = 1Mread_rnd_buffer_size = 1Msort_buffer_size = 1Mquery_cache_size = 64Mtable_open_cache = 2048thread_cache_size = 256max_heap_table_size = 64Mtmp_table_size = 64Mthread_stack = 192Kconnect_timeout = 600interactive_timeout = 600wait_timeout = 600thread_concurrency = 8local-infile = 0skip-show-databaseskip-name-resolveskip-external-locking#*** MyISAMkey_buffer_size = 512Mbulk_insert_buffer_size = 64Mmyisam_sort_buffer_size = 32Mmyisam_max_sort_file_size = 1Gmyisam_repair_threads = 1myisam_recover#*** INNODBinnodb_buffer_pool_size = 4Ginnodb_additional_mem_pool_size = 32Minnodb_data_file_path = ibdata:32M:autoextendinnodb_read_io_threads = 8innodb_write_io_threads = 8innodb_file_per_table = 1innodb_flush_log_at_trx_commit = 2innodb_lock_wait_timeout = 120innodb_log_buffer_size = 8Minnodb_log_file_size = 256Minnodb_log_files_in_group = 3innodb_max_dirty_pages_pct = 10innodb_thread_concurrency = 16#innodb_force_recovery = 4#*** Replication Slave#read-only#skip-slave-startrelay-log = relay.loglog-slave-updates[mysqldump]quickmax_allowed_packet = 32M[mysql]no-auto-rehash[myisamchk]key_buffer_size = 512Msort_buffer_size = 512Mread_buffer = 8Mwrite_buffer = 8M[mysqlhotcopy]interactive-timeout[mysqld_safe]open-files-limit = 60000
  • 初始化MariaDB

1 2 useradd  -s /bin/false  -M mysql/App/mariadb/scripts/mysql_install_db  --basedir=/App/mariadb  --datadir=/App/mariadb/data  --user=mysql
  • 启动MariaDB

1 /etc/init.d/mariadb  start
  • 登录MariaDB创建数据库并授权

1 mysql -uroot -p
1 2 3 4 5 CREATE  DATABASE  `gitlabhq_production`;GRANT  SELECTINSERTUPDATEDELETECREATECREATE  TEMPORARY  TABLES, DROPINDEXALTER, LOCK TABLES ON  `gitlabhq_production`.* TO  'git'@'127.0.0.1'  IDENTIFIED BY  'g1T#453eri';GRANT  SELECTINSERTUPDATEDELETECREATECREATE  TEMPORARY  TABLES, DROPINDEXALTER, LOCK TABLES ON  `gitlabhq_production`.* TO  'git'@'localhost'  IDENTIFIED BY  'g1T#453eri';FLUSH PRIVILEGES;QUIT;

十、安装GitLab

1 useradd  --system -s /bin/bash  --comment 'GitLab'  -m -d /home/git  git
  • 修改git家目录权限否则运行报权限错误

1 chmod  755 /home/git
  • 切换至git用户

1 2 su  - gitgit clone https://gitlab.com/larryli/gitlab.git -b 8-0-zh gitlab
  • 配置GitLab

1 2 cd  gitlab/cp  config/gitlab.yml.example config/gitlab.yml
  • 修改 gitlab.yml 配置将行host: localhost 修改为本机IP地址或者域名如为域名确保域名映射本机地址需修改/etc/hosts文件。

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

  • 新建卫星目录拷贝示例文件

1 2 3 4 5 6 7 8 9 mkdir  -p /home/git/gitlab-satellitescp  config/secrets.yml.example config/secrets.ymlchmod  0600 config/secrets.ymlchmod  -R u+rwX,go-w log/chmod  0750 /home/git/gitlab/public/uploadscp  config/unicorn.rb.example config/unicorn.rbcp  config/initializers/rack_attack.rb.example config/initializers/rack_attack.rbgit config --global core.autocrlf inputcp  config/resque.yml.example config/resque.yml
  • 修改Redis相关配置 config/resque.yml 文件 production: unix:/var/run/redis/redis.sock 为 production: redis://127.0.0.1:6379

  • 数据库配置

1 cp  config/database.yml.mysql config/database.yml
  • 修改 config/database.yml 前段 PRODUCTION 部分内容 password: “secure password” 修改为password: “PASSWORD”

1 chmod  o-rwx config/database.yml

 

  • 修改 Gemfile 首行内容 source “https://rubygems.org”  修改为 source “https://ruby.taobao.org”

1 bundle install  --deployment --without development test  postgres aws kerberos

十一、安装GitLab Shell

1 bundle exec  rake gitlab:shell:install[v2.6.6] REDIS_URL=redis://127.0.0.1:6379 RAILS_ENV=production

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

1 2 3 4 5 cd  /home/gitgit clone https://gitlab.com/gitlab-org/gitlab-git-http-server.gitcd  gitlab-git-http-servergit checkout 0.3.0make

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

1 bundle exec  rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD=newpassword

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

1 2 exitcp  /home/git/gitlab/lib/support/init.d/gitlab  /etc/init.d/

十五、root权限配置Logrotate

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

十六、检查应用状态

1 2 3 su  - gitcd  gitlab/bundle exec  rake gitlab:env:info RAILS_ENV=production

十七、编译静态文件

1 bundle exec  rake assets:precompile RAILS_ENV=production

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 exitcd  /App/src/wget http://nginx.org/download/nginx-1.8.0.tar.gz tar  zxf nginx-1.8.0.tar.gzcd  nginx-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  && make  installuseradd  -s /bin/false  nginx
  • 修改Nginx配置 /App/nginx/conf/nginx.conf

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 user  nginx nginx;worker_processes  auto;   error_log  logs/error.log error;   pid        logs/nginx.pid;worker_rlimit_nofile    65536;   events{    use epoll;    accept_mutex off;    worker_connections  65536;}   http{    include       mime.types;    default_type  text/html;       charset UTF-8;    server_names_hash_bucket_size  128;    client_header_buffer_size      4k;    large_client_header_buffers  4 32k;    client_max_body_size            20m;       open_file_cache max=65536  inactive=60s;    open_file_cache_valid      80s;    open_file_cache_min_uses   1;       log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '                      '$status $body_bytes_sent "$http_referer" '                      '"$http_user_agent" "$http_x_forwarded_for"';       access_log  logs/access.log  main;       sendfile    on;    server_tokens off;       keepalive_timeout  60;       gzip  on;    gzip_min_length 1k;    gzip_buffers  4  64k;    gzip_http_version  1.1;    gzip_comp_level 2;    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;       upstream gitlab     {        server unix:/home/git/gitlab/tmp/sockets/gitlab.socket fail_timeout=0;    }       upstream gitlab-git-http-server     {        server unix:/home/git/gitlab/tmp/sockets/gitlab-git-http-server.socket fail_timeout=0;    }       server {        listen      80;        server_name _;        root        /home/git/gitlab/public;           location /        {            try_files $uri $uri/index.html $uri.html @gitlab;        }           location /uploads/        {            proxy_read_timeout      300;            proxy_connect_timeout   300;            proxy_redirect          off;            proxy_set_header    Host                $http_host;            proxy_set_header    X-Real-IP           $remote_addr;            proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;            proxy_set_header    X-Forwarded-Proto   $scheme;            proxy_set_header    X-Frame-Options     SAMEORIGIN;            proxy_pass http://gitlab;        }           location @gitlab        {            proxy_read_timeout      300;            proxy_connect_timeout   300;            proxy_redirect          off;            proxy_set_header    Host                $http_host;            proxy_set_header    X-Real-IP           $remote_addr;            proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;            proxy_set_header    X-Forwarded-Proto   $scheme;            proxy_set_header    X-Frame-Options     SAMEORIGIN;            proxy_pass http://gitlab;        }           location ~ [-\/\w\.]+\.git\/        {            proxy_read_timeout      300;            proxy_connect_timeout   300;            proxy_redirect          off;            proxy_buffering off;            proxy_set_header    Host                $http_host;            proxy_set_header    X-Real-IP           $remote_addr;            proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;            proxy_set_header    X-Forwarded-Proto   $scheme;            proxy_pass http://gitlab-git-http-server;        }           location ~ ^/(assets)/        {            root /home/git/gitlab/public;            gzip_static on;            expires max;            add_header Cache-Control public;        }           error_page 502 /502.html;    }}

十九、SMTP相关配置

  • 复制smtp示例配置

1 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: falseopenssl_verify_mode: ‘peer’ 删除或添加 # 注释其余按照自己的邮箱正常配置即可。

二十、启动GitLab实例

1 /etc/init.d/gitlab  start

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

二十二、输入账号密码登录

文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/223935.html<

(0)
运维的头像运维
上一篇2025-04-16 04:55
下一篇 2025-04-16 04:56

相关推荐

  • 个人主题怎么制作?

    制作个人主题是一个将个人风格、兴趣或专业领域转化为视觉化或结构化内容的过程,无论是用于个人博客、作品集、社交媒体账号还是品牌形象,核心都是围绕“个人特色”展开,以下从定位、内容规划、视觉设计、技术实现四个维度,详细拆解制作个人主题的完整流程,明确主题定位:找到个人特色的核心主题定位是所有工作的起点,需要先回答……

    2025-11-20
    0
  • 社群营销管理关键是什么?

    社群营销的核心在于通过建立有温度、有价值、有归属感的社群,实现用户留存、转化和品牌传播,其管理需贯穿“目标定位-内容运营-用户互动-数据驱动-风险控制”全流程,以下从五个维度展开详细说明:明确社群定位与目标社群管理的首要任务是精准定位,需明确社群的核心价值(如行业交流、产品使用指导、兴趣分享等)、目标用户画像……

    2025-11-20
    0
  • 香港公司网站备案需要什么材料?

    香港公司进行网站备案是一个涉及多部门协调、流程相对严谨的过程,尤其需兼顾中国内地与香港两地的监管要求,由于香港公司注册地与中国内地不同,其网站若主要服务内地用户或使用内地服务器,需根据服务器位置、网站内容性质等,选择对应的备案路径(如工信部ICP备案或公安备案),以下从备案主体资格、流程步骤、材料准备、注意事项……

    2025-11-20
    0
  • 如何企业上云推广

    企业上云已成为数字化转型的核心战略,但推广过程中需结合行业特性、企业痛点与市场需求,构建系统性、多维度的推广体系,以下从市场定位、策略设计、执行落地及效果优化四个维度,详细拆解企业上云推广的实践路径,精准定位:明确目标企业与核心价值企业上云并非“一刀切”的方案,需先锁定目标客户群体,提炼差异化价值主张,客户分层……

    2025-11-20
    0
  • PS设计搜索框的实用技巧有哪些?

    在PS中设计一个美观且功能性的搜索框需要结合创意构思、视觉设计和用户体验考量,以下从设计思路、制作步骤、细节优化及交互预览等方面详细说明,帮助打造符合需求的搜索框,设计前的规划明确使用场景:根据网站或APP的整体风格确定搜索框的调性,例如极简风适合细线条和纯色,科技感适合渐变和发光效果,电商类则可能需要突出搜索……

    2025-11-20
    0

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注