CentOS源码安装GitLab汉化版第2版

软件版本:

  • CentOS 7.2
  • Git 2.12.0
  • Ruby 2.3.3
  • Node.js 6.10.1
  • Redis 3.2.8
  • MariaDB 10.1.20
  • GitLab 8.8.5汉化版
  • GitLab Shell 2.7.2
  • Nginx 1.10.3
  • Go 1.8
  • GitLab-Workhorse 0.7.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 版本:

    git --version
  • 如果 git 版本小于1.7.10则先卸载:
    rpm -e --nodeps git
  • 下载最新 git 源码包并编译安装:
    cd /App/src/
    wget https://www.kernel.org/pub/software/scm/git/git-2.12.0.tar.xz
    tar Jxf git-2.12.0.tar.xz
    cd git-2.12.0
    ./configure --prefix=/App/git
    make && make install
    echo ‘export PATH=/App/git/bin:$PATH‘ >> /etc/profile
    . /etc/profile
    ln -s /App/git/bin/git /bin/
    ln -s /App/git/bin/git-receive-pack /bin/
    ln -s /App/git/bin/git-upload-pack /bin/

三、安装 Ruby

cd /App/src/
wget https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.3.tar.gz
tar zxf ruby-2.3.3.tar.gz
cd ruby-2.3.3
./configure --prefix=/App/ruby --disable-install-rdoc
make && make install
ln -s /App/ruby/bin/ruby /bin/
echo ‘export PATH=/App/ruby/bin:$PATH‘ >> /etc/profile
. /etc/profile
  • 修改 RubyGems 镜像提高下载速度:

    gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
    gem install bundler --no-ri --no-rdoc

四、安装 Node.js

cd /App/src/
wget https://nodejs.org/dist/v6.10.1/node-v6.10.1-linux-x64.tar.xz
tar Jxf node-v6.10.1-linux-x64.tar.xz
mv node-v6.10.1-linux-x64 /App/node
echo ‘export PATH=/App/node/bin:$PATH‘ >> /etc/profile
. /etc/profile

五、安装 Go

cd /App/src/
wget http://www.golangtc.com/static/go/1.8/go1.8.linux-amd64.tar.gz
tar zxf go1.8.linux-amd64.tar.gz
mv go /App/
  • /etc/profile 添加环境变量配置:

    export GOROOT=/App/go
    export GOPATH=/root/code/go
    export PATH=$GOROOT/bin:$GOPATH/bin:$PATH

六、安装 Redis

cd /App/src/
wget http://download.redis.io/releases/redis-3.2.8.tar.gz
tar zxf redis-3.2.8.tar.gz
cd redis-3.2.8
make PREFIX=/App/redis install
echo ‘export PATH=/App/redis/bin:$PATH‘ >> /etc/profile
. /etc/profile
  • 添加Redis配置 /App/redis/redis.conf

    daemonize yes
    pidfile /App/redis/redis.pid
    port 0
    unixsocket /tmp/redis.sock
    unixsocketperm 777
    tcp-backlog 60000
    timeout 0
    tcp-keepalive 60
    loglevel warning
    logfile "/App/redis/redis.log"
    syslog-enabled no
    databases 16
    save 900 1
    save 300 10
    save 60 10000
    stop-writes-on-bgsave-error yes
    rdbcompression yes
    rdbchecksum yes
    dbfilename dump.rdb
    dir /App/redis
    slave-serve-stale-data yes
    repl-diskless-sync yes
    repl-diskless-sync-delay 5
    repl-ping-slave-period 10
    repl-timeout 60
    repl-disable-tcp-nodelay no
    slave-priority 100
    maxclients 60000
    maxmemory-policy noeviction
    appendonly no
    appendfilename "appendonly.aof"
    appendfsync everysec
    no-appendfsync-on-rewrite no
    auto-aof-rewrite-percentage 100
    auto-aof-rewrite-min-size 64mb
    aof-load-truncated yes
    lua-time-limit 5000
    slowlog-log-slower-than 10000
    slowlog-max-len 128
    latency-monitor-threshold 0
    hash-max-ziplist-entries 512
    hash-max-ziplist-value 64
    list-max-ziplist-entries 512
    list-max-ziplist-value 64
    set-max-intset-entries 512
    zset-max-ziplist-entries 128
    zset-max-ziplist-value 64
    hll-sparse-max-bytes 3000
    activerehashing yes
    client-output-buffer-limit normal 0 0 0
    client-output-buffer-limit slave 256mb 64mb 60
    client-output-buffer-limit pubsub 32mb 8mb 60
    hz 10
    aof-rewrite-incremental-fsync yes
  • 启动 Redis:
    /App/redis/bin/redis-server /App/redis/redis.conf

七、安装 MariaDB

cd /App/src/
wget https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-10.1.20/source/mariadb-10.1.20.tar.gz
tar zxf mariadb-10.1.20.tar.gz
cd mariadb-10.1.20

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 && make install
cp /App/mariadb/support-files/mysql.server /etc/init.d/mariadb
chmod u+x /etc/init.d/mariadb

echo ‘export PATH=/App/mariadb/bin:$PATH‘ >> /etc/profile
. /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 = 1G
    innodb_additional_mem_pool_size = 32M
    innodb_data_file_path = ibdata:32M:autoextend
    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
    #*** Replication Slave
    #read-only
    #skip-slave-start
    relay-log = relay.log
    log-slave-updates
  • 初始化 MariaDB:
    useradd -s /bin/false -M mysql
    /App/mariadb/scripts/mysql_install_db --basedir=/App/mariadb --datadir=/App/mariadb/data --user=mysql
  • 启动 MariaDB:
    /etc/init.d/mariadb start
  • 执行命令 mysql -uroot 登录 MariaDB 创建数据库并授权:
    CREATE DATABASE `gitlabhq_production` DEFAULT CHARSET utf8;
    GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, CREATE TEMPORARY TABLES, DROP, INDEX, ALTER, LOCK TABLES ON `gitlabhq_production`.* TO ‘git‘@‘127.0.0.1‘ IDENTIFIED BY ‘数据库连接密码‘;
    GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, CREATE TEMPORARY TABLES, DROP, INDEX, ALTER, LOCK TABLES ON `gitlabhq_production`.* TO ‘git‘@‘localhost‘ IDENTIFIED BY ‘数据库连接密码‘;
    FLUSH PRIVILEGES;
    QUIT;

八、安装 GitLab

useradd --system -s /bin/bash --comment ‘GitLab‘ -m -d /home/git git
  • 修改 git 家目录权限,否则访问 gitlab.socket 报权限错误:

    chmod 755 /home/git
  • 切换至 git 用户 clone 代码:
    su - git
    git clone https://gitlab.com/larryli/gitlab.git -b 8-8-zh gitlab
  • 拷贝 GitLab 配置:
    cd gitlab/
    cp config/gitlab.yml.example config/gitlab.yml
  • 修改 gitlab.yml 配置,将行 host: localhost 修改为本机IP地址或者域名,如为域名,确保域名已做解析。
  • 拷贝示例配置,修改权限:
    cp config/secrets.yml.example config/secrets.yml
    chmod 0600 config/secrets.yml
    chmod -R u+rwX,go-w log/
    chmod -R u+rwX tmp/
    chmod -R u+rwX tmp/pids/
    chmod -R u+rwX tmp/sockets/
    mkdir public/uploads/
    chmod 0700 public/uploads
    chmod -R u+rwX builds/
    chmod -R u+rwX shared/artifacts/
    mkdir -p shared/pages/
    chmod -R ug+rwX shared/pages/
    cp config/unicorn.rb.example config/unicorn.rb
    cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
    git config --global core.autocrlf input
    git config --global gc.auto 0
    git config --global repack.writeBitmaps true
    cp config/resque.yml.example config/resque.yml
  • 修改 Redis 相关配置 config/resque.yml 内容 production: unix:/var/run/redis/redis.sockproduction: unix:/tmp/redis.sock
  • 拷贝数据库相关配置:
    cp config/database.yml.mysql config/database.yml
  • 修改 config/database.yml 前段 PRODUCTION 部分内容, password: "secure password" 修改为 password: "数据库连接密码"
    chmod o-rwx config/database.yml
  • 安装 Gems:
    bundle config mirror.https://rubygems.org https://gems.ruby-china.org
    bundle install --deployment --without development test postgres aws kerberos
  • 安装 GitLab Shell:
    bundle exec rake gitlab:shell:install REDIS_URL=unix:/tmp/redis.sock RAILS_ENV=production SKIP_STORAGE_VALIDATION=true
  • 安装 GitLab-Workhorse:
    cd /home/git
    git clone https://gitlab.com/gitlab-org/gitlab-workhorse.git
    cd gitlab-workhorse
    git checkout v0.7.1
    make
  • 初始化数据库并激活高级功能:
    cd /home/git/gitlab
    bundle exec rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD=root密码

    GITLAB_ROOT_PASSWORD 值为 GitLab 管理员 root 密码。

  • 切换为 root 用户后拷贝服务脚本:
    exit
    cp /home/git/gitlab/lib/support/init.d/gitlab /etc/init.d/
  • 配置 Logrotate:
    cp /home/git/gitlab/lib/support/logrotate/gitlab /etc/logrotate.d/
  • 检查应用状态:
    su - git
    cd gitlab/
    bundle exec rake gitlab:env:info RAILS_ENV=production
  • 编译静态文件:
    bundle exec rake assets:precompile RAILS_ENV=production

九、安装 Nginx

  • 切换至 root 用户安装:

    exit
    cd /App/src/
    wget http://nginx.org/download/nginx-1.10.3.tar.gz
    tar zxf nginx-1.10.3.tar.gz
    cd nginx-1.10.3
    ./configure --prefix=/App/nginx --with-http_stub_status_module --with-http_gzip_static_module --with-http_ssl_module
    make && make install
    useradd -s /bin/false nginx
  • 修改 Nginx 配置 /App/nginx/conf/nginx.conf
    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-workhorse
    {
        server unix:/home/git/gitlab/tmp/sockets/gitlab-workhorse.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-workhorse;
        }
    
        location ~ ^/(assets)/
        {
            root /home/git/gitlab/public;
            gzip_static on;
            expires max;
            add_header Cache-Control public;
        }
    
        error_page 502 /502.html;
    }
    }

十、SMTP 相关配置

  • 复制smtp示例配置:

    cp /home/git/gitlab/config/initializers/smtp_settings.rb.sample /home/git/gitlab/config/initializers/smtp_settings.rb
  • smtp_settings.rbenable_starttls_auto: true 修改为 enable_starttls_auto: falseopenssl_verify_mode: ‘peer‘ 行前添加 # 注释,其余按照自己的邮箱正常配置即可。

十一、启动 GitLab 实例

/etc/init.d/gitlab start

原文地址:http://blog.51cto.com/dongsong/2091103

时间: 2024-10-11 12:21:53

CentOS源码安装GitLab汉化版第2版的相关文章

CentOS源码安装GitLab汉化版

示例环境: 软件 版本 CentOS 6.5 x86_64 Git 2.6.2 Ruby 2.2.3 Node.js 4.2.1 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.

CentOS 源码安装 zabbix3.4

环境: CentOS: 6.9 IP:192.168.1.92 JDK:1.7.0.45 ngingx: 1.13.6 mysql:  5.7.21-linux-glibc2.5-x86_64 php:    5.6.31 zabbix: 3.4.2 源码包存放路径:/data/tools/ 安装路径:      /usr/local/ 1.关闭防火墙和selinux 1.1. 关闭iptables ]# service iptables stop iptables: Setting chain

CentOS 源码安装MySQL5.7

一.安装方式源码安装,源码包名称mysql-boost-5.7.27.tar.gz,此版本包含boost库,在解压后的boost路径下.安装时,可以-DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/mysql-5.7.27/boost/指定boost路径 二.安装路径基础路径 /usr/local/mysql数据文件路径 /usr/local/mysql/data 三.安装依赖yum -y install autoconf automake libtool c

CentOS源码安装nagios与nagios-plugin

CentOSx64 源码安装nagios与nagios-plugin 官方网址:http://www.nagios.org 一.安装指导: http://nagios.sourceforge.net/docs/3_0/quickstart-fedora.html 二.nagios的配置 1)修改/usr/local/nagios/etc/nagios.cnf 文件修改如下: #cfg_file=/usr/local/nagios/etc/objects/windows.cfg cfg_file=

linux(centos)源码安装git

最近使用一个开源库,部署的的时候需要用git克隆依赖库.刚好系统没安装git.就尝试了源码安装git. 源码下载地址:http://codemonkey.org.uk/projects/git-snapshots/git/ 找了个最新版本的下载,我下载的是:git-latest.tar.xz 这个后缀的文件在我的linux系统不能解压.不想再安装相应的解压工具了.就机智地放在window下用winrar解压了. 上传到linux.修改git源码文件权限:chmod -R 755 git-2015

CentOS源码安装 Tomcat/8.0.24

依个人的习惯,喜欢将源码安装在/usr/local这个目录下面: 第一步:下载源码 wget http://archive.apache.org/dist/tomcat/tomcat-8/v8.0.24/bin/apache-tomcat-8.0.24.tar.gz 第二步:解压源码: tar -zxvf apache-tomcat-8.0.24.tar.gz mv apache-tomcat-8.0.24 /usr/local/tomcat 第三步:启动tomcat cd /usr/local

CentOS源码安装搭建LNMP全过程(包括nginx,mysql,php,svn)

服务器环境为:CentOS6.5 64位 目标:搭建LNMP(Linux + Nginx + MySQL + PHP +SVN),其中svn是用来代替ftp,方便开发中调试同步代码 相关目录:所有软件都安装到/www/目录下,在www目录下新建web文件夹作为网站的根路径,www目录下新建wwwsvn作为svn的仓库地址./www/software用来放nginx,mysql,php的安装包和源码.nginx运行分组和账户www:www 一,安装前的准备 yum -y install ntp m

CentOS源码安装搭建LNMP全过程(包括nginx,mysql,php,svn)【转】

转自:http://blog.csdn.net/yanzi1225627/article/details/49123659 服务器环境为:CentOS6.5 64位 目标:搭建LNMP(Linux + Nginx + MySQL + PHP +SVN),其中svn是用来代替ftp,方便开发中调试同步代码 相关目录:所有软件都安装到/www/目录下,在www目录下新建web文件夹作为网站的根路径,www目录下新建wwwsvn作为svn的仓库地址./www/software用来放nginx,mysq

centos 源码安装php5.5

系统环境: CentOS 6.5 / 7.0 x86_64 Fedora 20 x86_64下载 PHP 源码包 # wget http://cn2.php.net/distributions/php-5.5.15.tar.bz2# tar xf php-5.5.15.tar.bz2 -C /usr/local/src/ 添加 epel 源 # rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noar