CentOS 7上安装GitLab 8-6中文版教程

1、关闭SELinux

[root@DS-VM-Node83 ~]# sed -i 's/^SELINUX=.*/#&/;s/^SELINUXTYPE=.*/#&/;/SELINUX=.*/a SELINUX=disabled' /etc/sysconfig/selinux
[root@DS-VM-Node83 ~]# setenforce 0
setenforce: SELinux is disabled
[root@DS-VM-Node83 ~]#

2、安装EPEL源

[root@DS-VM-Node83 ~]# yum install epel-release -y
[root@DS-VM-Node83 ~]# rpm --import http://mirrors.dwhd.org/EPEL/RPM-GPG-KEY-EPEL-7

3、安装RPMforge源

[root@DS-VM-Node83 ~]# yum install http://mirrors.dwhd.org/RepoForgeRPM/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm -y
[root@DS-VM-Node83 ~]# rpm --import http://mirrors.dwhd.org/RepoForge/RPM-GPG-KEY.dag.txt

4、安装bash-completion包(TAB补齐增强包)

[root@DS-VM-Node83 ~]# yum -y install bash-completion

5、安装PUIAS源和导入对应key

[root@DS-VM-Node83 ~]# wget -qO- https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/install/centos/PUIAS_6_computational.repo > /etc/yum.repos.d/PUIAS_6_computational.repo
[root@DS-VM-Node83 ~]# rpm --import http://springdale.math.ias.edu/data/puias/6/x86_64/os/RPM-GPG-KEY-puias
[root@DS-VM-Node83 ~]#

6、检测KEY和更新源缓存

[root@DS-VM-Node83 ~]# rpm -qa gpg*|grep 352c64e5
gpg-pubkey-352c64e5-52ae6884
[root@DS-VM-Node83 ~]# rpm -qa gpg*|grep 41a40948
gpg-pubkey-41a40948-4ce19266
[root@DS-VM-Node83 ~]# yum clean all && yum makecache

7、安装Development Tools开发组包和一下必要的包文件

[root@DS-VM-Node83 ~]# yum -y groupinstall 'Development Tools'
[root@DS-VM-Node83 ~]# yum -y install readline readline-devel ncurses-devel gdbm-devel \
glibc-devel tcl-devel openssl-devel curl-devel expat-devel db4-devel byacc sqlite-devel \
libyaml libyaml-devel libffi libffi-devel libxml2 libxml2-devel libxslt libxslt-devel libicu \
libicu-devel system-config-firewall-tui sudo crontabs logwatch logrotate perl-Time-HiRes \
libcom_err-devel.i686 libcom_err-devel.x86_64 nodejs python-docutils postfix ntp

8、安装vim且设置为默认编辑器

[root@DS-VM-Node83 ~]# yum -y install vim-enhanced
[root@DS-VM-Node83 ~]# update-alternatives --set editor /usr/bin/vim.basic
[root@DS-VM-Node83 ~]# ln -sv /usr/bin/vim /usr/bin/editor
[root@DS-VM-Node83 ~]#

9、设置时间同步

[root@DS-VM-Node83 ~]# rm -rf /etc/localtime
You are going to execute "/bin/rm -rf /etc/localtime",please confirm (yes or no):yes
[root@DS-VM-Node83 ~]# ln -sv /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
"/etc/localtime" -> "/usr/share/zoneinfo/Asia/Shanghai"
[root@DS-VM-Node83 ~]# ntpdate pool.ntp.org
 6 Apr 09:14:53 ntpdate[11275]: adjust time server 212.26.18.41 offset -0.105925 sec
[root@DS-VM-Node83 ~]# echo '*/20 * * * * /usr/sbin/ntpdate pool.ntp.org > /dev/null 2>&1' >>/var/spool/cron/root
[root@DS-VM-Node83 ~]# date -R
Wed, 06 Apr 2016 09:15:14 +0800
[root@DS-VM-Node83 ~]#

10、编译高版本Git (Git version >= 2.7.3)

[root@DS-VM-Node83 ~]# yum -y install zlib-devel perl-CPAN gettext curl-devel expat-devel gettext-devel openssl-devel
[root@DS-VM-Node83 ~]# yum -y remove git
[root@DS-VM-Node83 /tmp/git]# URL='https://www.kernel.org/pub/software/scm/git/' && wget -c `curl -s $URL|awk --posix -F'"' '$2~/git-([0-9]+.){3}tar.xz/{a=$2}END{print "'"$URL"'"a}'`
[root@DS-VM-Node83 /tmp/git]# tar xf git-*.tar.xz
[root@DS-VM-Node83 /tmp/git]# cd git-*
[root@DS-VM-Node83 /tmp/git/git-2.8.1]# ./configure --prefix=/usr/local
[root@DS-VM-Node83 /tmp/git/git-2.8.1]# make -j $(awk '/processor/{i++}END{print i}' /proc/cpuinfo) && make install && cd ../..
[root@DS-VM-Node83 /tmp]# echo "PATH=/usr/local/bin:\$PATH" > /etc/profile.d/git.sh
[root@DS-VM-Node83 /tmp]# . /etc/profile.d/git.sh
[root@DS-VM-Node83 /tmp]# which git
/usr/local/bin/git
[root@DS-VM-Node83 /tmp]# git version
git version 2.8.1
[root@DS-VM-Node83 /tmp]#

11、编译安装高版本ruby ( Ruby version >= 2.1.0)

[root@DS-VM-Node83 /tmp]# yum -y remove ruby
[root@DS-VM-Node83 /tmp/ruby]# URL1='http://mirrors.dwhd.org/Ruby/ruby/' && URL2=`curl -s $URL1|awk -PF'"' '{if ($2~/^[0-9]+\.[0-9]+/)a=$2}END{print "'$URL1'"a}'` && wget -c `curl -s $URL2|awk -PF'"' '{if ($2~/^ruby.*xz$/)a=$2}END{print "'$URL2'"a}'`
[root@DS-VM-Node83 /tmp/ruby]# tar xf ruby-*
[root@DS-VM-Node83 /tmp/ruby]# cd ruby-*
[root@DS-VM-Node83 /tmp/ruby/ruby-2.3.0]# ./configure --prefix=/usr/local --disable-install-rdoc
[root@DS-VM-Node83 /tmp/ruby/ruby-2.3.0]# make -j $(awk '/processor/{i++}END{print i}' /proc/cpuinfo) && make install && cd ../..
[root@DS-VM-Node83 /tmp]# ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
[root@DS-VM-Node83 /tmp]#

12、安装bundler

[root@DS-VM-Node83 /tmp]# gem install bundler --no-doc
[root@DS-VM-Node83 /tmp]# bundler -v
Bundler version 1.11.2
[root@DS-VM-Node83 /tmp]#

13、安装go (gitlab 8.0 以后的版本需要go语言的支持)

[root@DS-VM-Node83 /tmp]# mkdir /tmp/go && cd /tmp/go
[root@DS-VM-Node83 /tmp/go]# URL='https://storage.googleapis.com/golang/' && wget -c `curl -s $URL|xmllint --format - |awk -PF'[><]' '{if ($3~/linux/ && $3!~/(beta|rc)[0-9]+|armv6l|386/)a=$3}END{print "'$URL'"a}'`
[root@DS-VM-Node83 /tmp/go]# tar xf go*.linux-amd64.tar.gz -C /usr/local/
[root@DS-VM-Node83 /tmp/go]# echo "PATH=/usr/local/go/bin:\$PATH" >/etc/profile.d/go.sh
[root@DS-VM-Node83 /tmp/go]# . /etc/profile.d/go.sh
[root@DS-VM-Node83 /tmp/go]# go version
go version go1.6 linux/amd64
[root@DS-VM-Node83 /tmp/go]# cd ..

14、添加git系统用户

[root@DS-VM-Node83 /tmp]# mkdir -p /data/
[root@DS-VM-Node83 /tmp]# adduser -r -s /bin/bash -c 'GitLab' -m -d /data/git/ git

15、安装MariaDB

[root@DS-VM-Node83 /tmp]# wget http://mirrors.dwhd.org/SQL/MariaDB/mariadb-10.1.13/bintar-linux-x86_64/mariadb-10.1.13-linux-x86_64.tar.gz
[root@DS-VM-Node83 /tmp]# tar xf mariadb-10.1.13-linux-x86_64.tar.gz -C /usr/local/
[root@DS-VM-Node83 /tmp]# ln -sv /usr/local/mariadb-10.1.13-linux-x86_64 /usr/local/mariadb
"/usr/local/mariadb" -> "/usr/local/mariadb-10.1.13-linux-x86_64"
[root@DS-VM-Node83 /tmp]# cd /usr/local/mariadb
[root@DS-VM-Node83 /usr/local/mariadb]# Username="mysql"
[root@DS-VM-Node83 /usr/local/mariadb]# for i in `seq 1000 1500`;do [ -z "$(awk -F: '{print$3,$4}' /etc/passwd | grep "$i")" -a -z "$(awk -F: '{print$3}' /etc/group | grep "$i")" ] && UGID=$i && break;done && groupadd -g $UGID $Username && useradd -M -u $UGID -g $UGID -s /sbin/nologin $Username
[root@DS-VM-Node83 /usr/local/mariadb]# chown -R mysql.mysql /data/mariadb
[root@DS-VM-Node83 /usr/local/mariadb]# ls -l /data/
总用量 0
drwx------ 2 git   git   59 4月   6 16:16 git
drwxr-xr-x 2 mysql mysql  6 4月   6 16:14 mariadb
[root@DS-VM-Node83 /usr/local/mariadb]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@DS-VM-Node83 /usr/local/mariadb]# sed -i "s@^basedir=.*@basedir=/usr/local/mariadb@" /etc/init.d/mysqld
[root@DS-VM-Node83 /usr/local/mariadb]# sed -i "s@^datadir=.*@datadir=/data/mariadb@" /etc/init.d/mysqld
[root@DS-VM-Node83 /usr/local/mariadb]# chmod +x /etc/rc.d/init.d/mysqld
[root@DS-VM-Node83 /usr/local/mariadb]# cat /etc/my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8
 
[mysql]
default-character-set=utf8
 
[mysqld]
port = 3306
socket = /tmp/mysql.sock
character-set-server=utf8
 
basedir = /usr/local/mariadb
datadir = /data/mariadb
pid-file = /data/mariadb/mysql.pid
user = mysql
bind-address = 0.0.0.0
server-id = 1
 
skip-name-resolve
#skip-networking
back_log = 300
 
max_connections = 1000
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 128
max_allowed_packet = 4M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M
 
read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 4M
 
thread_cache_size = 8
 
query_cache_type = 1
query_cache_size = 8M
query_cache_limit = 2M
 
ft_min_word_len = 4
 
log_bin = mysql-bin
binlog_format = mixed
expire_logs_days = 30
 
log_error = /data/mariadb/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /data/mariadb/mysql-slow.log
 
performance_schema = 0
 
#lower_case_table_names = 1
 
skip-external-locking
 
default_storage_engine = InnoDB
#default-storage-engine = MyISAM
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 64M
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
 
bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
 
interactive_timeout = 28800
wait_timeout = 28800
 
[mysqldump]
quick
max_allowed_packet = 16M
 
[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M
[root@DS-VM-Node83 /usr/local/mariadb]# /usr/local/mariadb/scripts/mysql_install_db --user=mysql --datadir=/data/mariadb
Installing MariaDB/MySQL system tables in '/data/mariadb' ...
2016-04-06 16:22:35 140361217341312 [Note] /usr/local/mariadb/bin/mysqld (mysqld 10.1.13-MariaDB) starting as process 11169 ...
OK
Filling help tables...
2016-04-06 16:22:47 139961125017472 [Note] /usr/local/mariadb/bin/mysqld (mysqld 10.1.13-MariaDB) starting as process 11199 ...
OK
Creating OpenGIS required SP-s...
2016-04-06 16:22:50 139730244343680 [Note] /usr/local/mariadb/bin/mysqld (mysqld 10.1.13-MariaDB) starting as process 11259 ...
OK
 
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
 
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:
 
'/usr/local/mariadb/bin/mysqladmin' -u root password 'new-password'
'/usr/local/mariadb/bin/mysqladmin' -u root -h 10.0.1.83 password 'new-password'
 
Alternatively you can run:
'/usr/local/mariadb/bin/mysql_secure_installation'
 
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
 
See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.
 
You can start the MariaDB daemon with:
cd '/usr/local/mariadb' ; /usr/local/mariadb/bin/mysqld_safe --datadir='/data/mariadb'
 
You can test the MariaDB daemon with mysql-test-run.pl
cd '/usr/local/mariadb/mysql-test' ; perl mysql-test-run.pl
 
Please report any problems at http://mariadb.org/jira
 
The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Support MariaDB development by buying support/new features from MariaDB
Corporation Ab. You can contact us about this at sales@mariadb.com.
Alternatively consider joining our community based development effort:
http://mariadb.com/kb/en/contributing-to-the-mariadb-project/
 
[root@DS-VM-Node83 /usr/local/mariadb]# service mysqld start
Reloading systemd:                                         [  确定  ]
Starting mysqld (via systemctl):                           [  确定  ]
[root@DS-VM-Node83 /usr/local/mariadb]# chkconfig mysqld on
[root@DS-VM-Node83 /usr/local/mariadb]# chkconfig |grep mysql
mysqld          0:关    1:关    2:开    3:开    4:开    5:开    6:关
[root@DS-VM-Node83 /usr/local/mariadb]# echo "export PATH=/usr/local/mariadb/bin:\$PATH" > /etc/profile.d/mariadb.sh
[root@DS-VM-Node83 /usr/local/mariadb]# . /etc/profile.d/mariadb.sh
[root@DS-VM-Node83 /usr/local/mariadb]# which mysql
/usr/local/mariadb/bin/mysql
[root@DS-VM-Node83 /usr/local/mariadb]# usermod -a -G git mysql

16、配置数据库

[root@DS-VM-Node83 /usr/local/mariadb]# mysql -uroot
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 10.1.13-MariaDB MariaDB Server
 
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
MariaDB [(none)]> USE mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
 
Database changed
MariaDB [mysql]> UPDATE user SET password=PASSWORD('lookback') WHERE USER='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0
 
MariaDB [mysql]> DELETE FROM user WHERE User='';
Query OK, 2 rows affected (0.00 sec)
 
MariaDB [mysql]> DROP DATABASE test;
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [mysql]> CREATE USER 'git'@'localhost' IDENTIFIED BY 'lookback';
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [mysql]> SET storage_engine=INNODB;
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [mysql]> CREATE DATABASE IF NOT EXISTS gitlabhq_production DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
Query OK, 1 row affected (0.00 sec)
 
MariaDB [mysql]> GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON gitlabhq_production.* TO 'git'@'localhost';
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [mysql]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [mysql]> SELECT USER,PASSWORD,HOST FROM user;
+------+-------------------------------------------+--------------------------+
| USER | PASSWORD                                  | HOST                     |
+------+-------------------------------------------+--------------------------+
| root | *153CCFAEAA83407D8DBDBFAA3D17B1A95553E60C | localhost                |
| root | *153CCFAEAA83407D8DBDBFAA3D17B1A95553E60C | ds-vm-node83.cluster.com |
| root | *153CCFAEAA83407D8DBDBFAA3D17B1A95553E60C | 127.0.0.1                |
| root | *153CCFAEAA83407D8DBDBFAA3D17B1A95553E60C | ::1                      |
| git  | *153CCFAEAA83407D8DBDBFAA3D17B1A95553E60C | localhost                |
+------+-------------------------------------------+--------------------------+
5 rows in set (0.00 sec)
 
MariaDB [mysql]> SHOW DATABASES;
+---------------------+
| Database            |
+---------------------+
| gitlabhq_production |
| information_schema  |
| mysql               |
| performance_schema  |
+---------------------+
4 rows in set (0.00 sec)
 
MariaDB [mysql]> \q
Bye

17、编译安装redis(Redis version >= 2.8.0)

[root@DS-VM-Node83 /usr/local/mariadb]# mkdir /tmp/redis && cd /tmp/redis
[root@DS-VM-Node83 /tmp/redis]# wget -c `curl -s http://redis.io/download | awk -F"'" '/[0-9].[0-9].*.tar.gz/{print $4;exit}'`
[root@DS-VM-Node83 /tmp/redis]# tar xf redis-*.tar.gz
[root@DS-VM-Node83 /tmp/redis]# cd redis-*
[root@DS-VM-Node83 /tmp/redis/redis-3.0.7]# make
[root@DS-VM-Node83 /tmp/redis/redis-3.0.7]# mkdir -p /usr/local/redis/{bin,etc,var}
[root@DS-VM-Node83 /tmp/redis/redis-3.0.7]# cp -af src/{redis-benchmark,redis-check-aof,redis-check-dump,redis-cli,redis-sentinel,redis-server} /usr/local/redis/bin/
[root@DS-VM-Node83 /tmp/redis/redis-3.0.7]# cp -a redis.conf /usr/local/redis/etc/
[root@DS-VM-Node83 /tmp/redis/redis-3.0.7]# echo "export PATH=/usr/local/redis/bin:\$PATH" > /etc/profile.d/redis.sh
[root@DS-VM-Node83 /tmp/redis/redis-3.0.7]# . /etc/profile.d/redis.sh
[root@DS-VM-Node83 /tmp/redis/redis-3.0.7]# sed -i 's@pidfile.*@pidfile /var/run/redis.pid@' /usr/local/redis/etc/redis.conf
[root@DS-VM-Node83 /tmp/redis/redis-3.0.7]# sed -i "s@logfile.*@logfile /usr/local/redis/var/redis.log@" /usr/local/redis/etc/redis.conf
[root@DS-VM-Node83 /tmp/redis/redis-3.0.7]# sed -i "s@^dir.*@dir /usr/local/redis/var@" /usr/local/redis/etc/redis.conf
[root@DS-VM-Node83 /tmp/redis/redis-3.0.7]# sed -i 's@daemonize no@daemonize yes@' /usr/local/redis/etc/redis.conf
[root@DS-VM-Node83 /tmp/redis/redis-3.0.7]# [ -z "`grep ^maxmemory /usr/local/redis/etc/redis.conf`" ] && sed -i 's@maxmemory <bytes>@maxmemory <bytes>\nmaxmemory 360000000@' /usr/local/redis/etc/redis.conf
[root@DS-VM-Node83 /tmp/redis/redis-3.0.7]# mkdir -p /var/run/redis && chown -R git /var/run/redis/
[root@DS-VM-Node83 /tmp/redis/redis-3.0.7]# sed -ri 's/^(port).*/\1 0/' /usr/local/redis/etc/redis.conf
[root@DS-VM-Node83 /tmp/redis/redis-3.0.7]# echo 'unixsocket /var/run/redis/redis.sock' >> /usr/local/redis/etc/redis.conf
[root@DS-VM-Node83 /tmp/redis/redis-3.0.7]# echo 'unixsocketperm 0770' >> /usr/local/redis/etc/redis.conf
[root@DS-VM-Node83 /tmp/redis/redis-3.0.7]# wget -q http://www.dwhd.org/script/Redis-server-init-CentOS -O /etc/init.d/redis-server
[root@DS-VM-Node83 /tmp/redis/redis-3.0.7]# sed -i "/touch $lockfile/a \    chown git $(awk '/^unixsocket /{print $2}' /usr/local/redis/etc/redis.conf)" /etc/init.d/redis-server
[root@DS-VM-Node83 /tmp/redis/redis-3.0.7]# chmod +x /etc/init.d/redis-server
[root@DS-VM-Node83 /tmp/redis/redis-3.0.7]# chkconfig redis-server on
[root@DS-VM-Node83 /tmp/redis/redis-3.0.7]# service redis-server start
Starting redis-server (via systemctl):                     [  确定  ]
[root@DS-VM-Node83 /tmp/redis/redis-3.0.7]# ls -l /var/run/redis
总用量 0
srwxrwx--- 1 git root 0 4月   6 16:37 redis.sock
[root@DS-VM-Node83 /tmp/redis/redis-3.0.7]# redis-cli -s /var/run/redis/redis.sock <<< "info" | grep 'redis.version' && cd ../..
redis_version:3.0.7
[root@DS-VM-Node83 /tmp]#

18、编译安装Nginx

[root@DS-VM-Node83 /tmp/nginx]# wget http://mirrors.dwhd.org/Nginx/nginx-1.9.14.tar.gz
[root@DS-VM-Node83 /tmp/nginx]# tar xf nginx-1.9.14.tar.gz
[root@DS-VM-Node83 /tmp/nginx]# cd nginx-1.9.14/
[root@DS-VM-Node83 /tmp/nginx/nginx-1.9.14]# adduser -r -s /sbin/nologin -c 'Web Server' -M www
[root@DS-VM-Node83 /tmp/nginx/nginx-1.9.14]# yum -y install pcre-devel pcre
[root@DS-VM-Node83 /tmp/nginx/nginx-1.9.14]# ./configure --prefix=/usr/local/nginx/ \
--user=www --group=www \
--error-log-path=/tmp/nginx/error.log \
--http-log-path=/tmp/nginx/access.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--with-pcre \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_v2_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--http-client-body-temp-path=/usr/local/nginx/client/ \
--http-proxy-temp-path=/usr/local/nginx/proxy/ \
--http-fastcgi-temp-path=/usr/local/nginx/fcgi/ \
--http-uwsgi-temp-path=/usr/local/nginx/uwsgi \
--http-scgi-temp-path=/usr/local/nginx/scgi
[root@DS-VM-Node83 /tmp/nginx/nginx-1.9.14]# make -j $(awk '/processor/{i++}END{print i}' /proc/cpuinfo) && make install && cd ../..
[root@DS-VM-Node83 /tmp]# echo "export PATH=/usr/local/nginx/sbin:\$PATH" > /etc/profile.d/nginx.sh
[root@DS-VM-Node83 /tmp]# . /etc/profile.d/nginx.sh
[root@DS-VM-Node83 /tmp]# wget -q http://www.dwhd.org/script/Nginx-init-CentOS -O /etc/rc.d/init.d/nginx
[root@DS-VM-Node83 /tmp]# chmod +x /etc/rc.d/init.d/nginx
[root@DS-VM-Node83 /tmp]# chkconfig nginx on
[root@DS-VM-Node83 /tmp]# nginxCONF=/usr/local/nginx/conf/nginx.conf
[root@DS-VM-Node83 /tmp]# sed -i "$(awk '{a=NR}END{print a}' $nginxCONF)s@^@    include vhost/*.conf;\n&@" $nginxCONF
[root@DS-VM-Node83 /tmp]# mkdir -p /usr/local/nginx/conf/vhost/
[root@DS-VM-Node83 /tmp]# mkdir -p /var/log/nginx/
[root@DS-VM-Node83 /tmp]# wget -q https://gitlab.com/gitlab-org/gitlab-ce/raw/master/lib/support/nginx/gitlab -O /usr/local/nginx/conf/vhost/git.dwhd.org.conf
[root@DS-VM-Node83 /tmp]# usermod -a -G git www
[root@DS-VM-Node83 /tmp]# sed -i 's/server.*gitlab-workhorse.socket.*/#&/' /usr/local/nginx/conf/vhost/git.dwhd.org.conf
[root@DS-VM-Node83 /tmp]# sed -i '/upstream/a \ \ server 127.0.0.1:8080 fail_timeout=0;' /usr/local/nginx/conf/vhost/git.dwhd.org.conf
[root@DS-VM-Node83 /tmp]# sed -i 's/YOUR_SERVER_FQDN/你的域名/' /usr/local/nginx/conf/vhost/git.dwhd.org.conf

19、修改sudo配置

[root@DS-VM-Node83 /tmp]# chmod u+w /etc/sudoers
[root@DS-VM-Node83 /tmp]# sed -ri 's@^(Defaults\s+secure_path\s+=).*@\1 /usr/local/go/bin:/usr/local/mariadb/bin:/usr/local/nginx/sbin:/usr/local/redis/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin@' /etc/sudoers
[root@DS-VM-Node83 /tmp]# chmod ugo-w /etc/sudoers
[root@DS-VM-Node83 /tmp]#

20、 检测各种环境安装情况

[root@DS-VM-Node83 /tmp]# mysql -V
mysql  Ver 15.1 Distrib 10.1.13-MariaDB, for Linux (x86_64) using readline 5.1
[root@DS-VM-Node83 /tmp]# nginx -v
nginx version: nginx/1.9.14
[root@DS-VM-Node83 /tmp]# ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
[root@DS-VM-Node83 /tmp]# go version
go version go1.6 linux/amd64
[root@DS-VM-Node83 /tmp]# bundle -v
Bundler version 1.11.2
[root@DS-VM-Node83 /tmp]# git --version
git version 2.8.1
[root@DS-VM-Node83 /tmp]#
Linux之CentOS 7上安装GitLab 8-6中文版

二、安装GitLab

1、克隆GitLab 8.6中文版分支

[root@DS-VM-Node83 /tmp]# cd /data/git/
[root@DS-VM-Node83 /data/git]# sudo -u git -H git clone https://gitlab.com/larryli/gitlab.git -b 8-6-zh gitlab
正克隆到 'gitlab'...
remote: Counting objects: 214761, done.
remote: Compressing objects: 100% (45405/45405), done.
remote: Total 214761 (delta 166493), reused 214623 (delta 166408)
接收对象中: 100% (214761/214761), 111.36 MiB | 266.00 KiB/s, 完成.
处理 delta 中: 100% (166493/166493), 完成.
检查连接... 完成。
[root@DS-VM-Node83 /data/git]# cd gitlab/
[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git -H git branch -va |head -1

2、复制GitLab配置文件config/gitlab.yml

[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml

3、修改gitlab配置文件

[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git -H sed -i 's@/home/git@/data/git@' config/gitlab.yml
[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git -H sed -ri "s/^(\s+email_from:).*/\1 GitLab@dwhd.org/" config/gitlab.yml
[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git -H sed -ri "s/^(\s+host:).*/\1 git.dwhd.org/" config/gitlab.yml
[root@DS-VM-Node83 /data/git/gitlab]# sed -ri "s@(bin_path: ).*@\1$(which git)@" config/gitlab.yml
[root@DS-VM-Node83 /data/git/gitlab]# sed -ri "s/(time_zone: ).*/\1'Beijing'/" config/gitlab.yml

###下面是我的配置文件参考
[root@DS-VM-Node83 /data/git/gitlab]# grep -Ev '^(\s+)?(#|$)' config/gitlab.yml
production: &base
  gitlab:
    host: git.dwhd.org
    port: 80 # Set to 443 if using HTTPS, see installation.md#using-https for additional HTTPS configuration details
    https: false # Set to true if using HTTPS, see installation.md#using-https for additional HTTPS configuration details
    email_from: GitLab@dwhd.org
    email_display_name: GitLab
    email_reply_to: noreply@example.com
    default_projects_features:
      issues: true
      merge_requests: true
      wiki: true
      snippets: false
      builds: true
  incoming_email:
    enabled: false
    address: "gitlab-incoming+%{key}@gmail.com"
    user: "gitlab-incoming@gmail.com"
    password: "[REDACTED]"
    host: git.dwhd.org
    port: 993
    ssl: true
    start_tls: false
    mailbox: "inbox"
  artifacts:
    enabled: true
  lfs:
    enabled: true
  gravatar:
    enabled: true                 # Use user avatar image from Gravatar.com (default: true)
  cron_jobs:
    stuck_ci_builds_worker:
      cron: "0 0 * * *"
  gitlab_ci:
  ldap:
    enabled: false
    servers:
      main: # 'main' is the GitLab 'provider ID' of this LDAP server
        label: 'LDAP'
        host: git.dwhd.org
        port: 389
        uid: 'sAMAccountName'
        method: 'plain' # "tls" or "ssl" or "plain"
        bind_dn: '_the_full_dn_of_the_user_you_will_bind_with'
        password: '_the_password_of_the_bind_user'
        timeout: 10
        active_directory: true
        allow_username_or_email_login: false
        block_auto_created_users: false
        base: ''
        user_filter: ''
        attributes:
          username: ['uid', 'userid', 'sAMAccountName']
          email:    ['mail', 'email', 'userPrincipalName']
          name:       'cn'
          first_name: 'givenName'
          last_name:  'sn'
  omniauth:
    enabled: false
    allow_single_sign_on: ["saml"]
    block_auto_created_users: true
    auto_link_ldap_user: false
    auto_link_saml_user: false
    providers:
  shared:
  satellites:
    path: /data/git/gitlab-satellites/
  backup:
    path: "tmp/backups"   # Relative paths are relative to Rails.root (default: tmp/backups/)
  gitlab_shell:
    path: /data/git/gitlab-shell/
    repos_path: /data/git/repositories/
    hooks_path: /data/git/gitlab-shell/hooks/
    upload_pack: true
    receive_pack: true
  git:
    bin_path: /usr/local/bin/git
    max_size: 20971520 # 20.megabytes
    timeout: 10
  extra:
  rack_attack:
    git_basic_auth:
development:
  <<: *base
test:
  <<: *base
  gravatar:
    enabled: true
  lfs:
    enabled: false
  gitlab:
    host: git.dwhd.org
    port: 80
  satellites:
    path: tmp/tests/gitlab-satellites/
  backup:
    path: tmp/tests/backups
  gitlab_shell:
    path: tmp/tests/gitlab-shell/
    repos_path: tmp/tests/repositories/
    hooks_path: tmp/tests/gitlab-shell/hooks/
  issues_tracker:
    redmine:
      title: "Redmine"
      project_url: "http://redmine/projects/:issues_tracker_id"
      issues_url: "http://redmine/:project_id/:issues_tracker_id/:id"
      new_issue_url: "http://redmine/projects/:issues_tracker_id/issues/new"
  ldap:
    enabled: false
    servers:
      main:
        label: ldap
        host: git.dwhd.org
        port: 3890
        uid: 'uid'
        method: 'plain' # "tls" or "ssl" or "plain"
        base: 'dc=example,dc=com'
        user_filter: ''
        group_base: 'ou=groups,dc=example,dc=com'
        admin_group: ''
staging:
  <<: *base
[root@DS-VM-Node83 /data/git/gitlab]#

4、给目录log/和tmp/ git用户有写权限

[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git mkdir /data/git/gitlab/public/uploads
[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git chown -R git {log,tmp}/ public/uploads
[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git chmod -R u+rwX {log,tmp}/ public/uploads
[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git chmod -R ug+rwX,o-rwx /data/git/repositories/
[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git chmod -R ug-s /data/git/repositories/
[root@DS-VM-Node83 /data/git/gitlab]# find /data/git/repositories/ -type d -print0 | sudo xargs -0 chmod g+s
[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git ls -ld {log,tmp}/ public/uploads
drwxr-xr-x 2 git git 4096 4月   6 18:52 log/
drwxr-xr-x 2 git git    6 4月   8 00:50 public/uploads
drwxr-xr-x 6 git git   58 4月   6 18:52 tmp/
[root@DS-VM-Node83 /data/git/gitlab]#

5、创建satellites目录并设置权限

[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git mkdir /data/git/gitlab-satellites
[root@DS-VM-Node83 /data/git/gitlab]# chmod u+rwx,g=rx,o-rwx /data/git/gitlab-satellites

6、给tmp/pids、tmp/sockets以及public/uploads/目录 git用户有写权限

[root@DS-VM-Node83 /data/git/gitlab]# chmod -R u+rwX tmp/{pids,sockets}
[root@DS-VM-Node83 /data/git/gitlab]# ls -ld tmp/{pids,sockets}
drwxr-xr-x 2 git git 21 4月   6 17:56 tmp/pids
drwxr-xr-x 2 git git 21 4月   6 17:56 tmp/sockets
[root@DS-VM-Node83 /data/git/gitlab]#

7、从模版拷贝出Unicorn配置文件

[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git -H sed -i 's@/home/git@/data/git@' config/unicorn.rb

8、如果你负载比较大请启用集群模式

[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git -H sed -ri "s/^(worker_processes ).*/\1 $(nproc)/" config/unicorn.rb
[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git -H sed -ri "s/^(timeout ).*/\1 300/" config/unicorn.rb

9、从模版拷贝出Rack attack配置文件

[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb

10、为git用户做全局配置

[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git -H git config --global user.name "GitLab"
[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git -H git config --global user.email "gitlab@dwhd.org"
[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git -H git config --global core.autocrlf input
[root@DS-VM-Node83 /data/git/gitlab]#

11、配置redis的连接

[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git -H cp config/resque.yml.example config/resque.yml
[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git -H sed -ri "s@^(development:).*@\1 unix:/var/run/redis/redis.sock@" config/resque.yml

12、配置Gitlab 数据库设置

[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git cp config/database.yml.mysql config/database.yml
[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git -H editor config/database.yml
[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git -H chmod o-rwx config/database.yml
Linux之CentOS 7上安装GitLab 8-6中文版

13、安装Gems

[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git -H bundle install --deployment --without development test postgres aws
##如果是国内服务器安装请修改为淘宝的ruby源
##[root@DS-VM-Node83 /data/git/gitlab]# sed -ri 's@^(source ).*@\1"https://ruby.taobao.org"@' Gemfile

[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git -H bundle install --deployment --without development test postgres aws
Fetching gem metadata from https://rubygems.org/........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Installing rake 10.5.0
Installing CFPropertyList 2.3.2
Installing RedCloth 4.2.9 with native extensions
Installing ace-rails-ap 2.0.1
Installing i18n 0.7.0
Using json 1.8.3
Installing minitest 5.7.0
Installing thread_safe 0.3.5
Installing builder 3.2.2
Installing erubis 2.7.0
Installing mini_portile2 2.0.0
Installing rack 1.6.4
Installing mime-types 1.25.1
Installing arel 6.0.3
Installing activerecord-deprecated_finders 1.0.4
Installing thor 0.19.1
Installing addressable 2.3.8
Installing akismet 2.0.0
Installing allocations 1.0.4 with native extensions
Installing multipart-post 2.0.0
Installing multi_json 1.11.2
Installing jwt 1.5.2
Installing multi_xml 0.5.5
Installing asciidoctor 1.5.3
Installing encryptor 1.3.0
Installing attr_required 1.0.0
Installing execjs 2.6.0
Installing ice_nine 0.11.1
Installing babosa 1.0.2
Installing bcrypt 3.1.10 with native extensions
Installing sass 3.4.20
Installing browser 1.0.1
Installing cal-heatmap-rails 3.5.1
Installing cause 0.1
Installing charlock_holmes 0.7.3 with native extensions
Installing chunky_png 1.3.5
Installing coffee-script-source 1.10.0
Installing colorize 0.7.7
Installing concurrent-ruby 1.0.0
Installing connection_pool 2.2.0
Installing safe_yaml 1.0.4
Installing creole 0.5.0
Installing orm_adapter 0.5.0
Installing rotp 2.1.1
Installing diff-lcs 1.2.5
Installing diffy 3.0.7
Using bundler 1.11.2
Installing email_reply_parser 0.5.8
Installing equalizer 0.0.11
Installing escape_utils 1.1.0 with native extensions
Installing eventmachine 1.0.8 with native extensions
Installing excon 0.45.4
Installing expression_parser 0.9.0
Installing formatador 0.2.5
Installing ipaddress 0.8.2
Installing xml-simple 1.1.5
Installing inflecto 0.0.2
Installing rugged 0.24.0 with native extensions
Installing get_process_mem 0.2.0
Installing github-markup 1.3.3
Installing posix-spawn 0.3.11 with native extensions
Installing gitlab_meta 7.0
Installing net-ldap 0.12.1
Installing hashie 3.4.3
Installing pyu-ruby-sasl 0.0.3.3
Installing rubyntlm 0.5.2
Installing rouge 1.10.1
Installing stringex 2.5.2
Installing request_store 1.2.1
Installing tilt 2.0.2
Installing sexp_processor 4.6.0
Installing mimemagic 0.3.0
Installing htmlentities 4.3.4
Installing http_parser.rb 0.5.3 with native extensions
Installing httpclient 2.7.0.1
Installing jquery-atwho-rails 1.3.2
Installing kgio 2.10.0 with native extensions
Installing systemu 2.6.5
Installing mail_room 0.6.1
Installing method_source 0.8.2
Installing mousetrap-rails 1.4.6
Installing mysql2 0.3.20 with native extensions
Installing nested_form 0.3.2
Installing net-ssh 3.0.1
Installing newrelic_rpm 3.14.1.311
Installing oauth 0.4.7
Installing timfel-krb5-auth 0.8.3 with native extensions
Installing rubypants 0.2.0
Installing rack-cors 0.4.0
Installing raindrops 0.15.0 with native extensions
Installing raphael-rails 2.1.2
Installing redcarpet 3.3.3 with native extensions
Installing redis 3.2.2
Installing rinku 1.7.3 with native extensions
Installing rufus-scheduler 3.1.10
Installing settingslogic 2.0.9
Installing simple_oauth 0.1.9
Installing six 0.2.0
Installing slack-notifier 1.2.1
Installing state_machines 0.4.0
Installing underscore-rails 1.8.3
Installing unf_ext 0.0.7.1 with native extensions
Installing version_sorter 2.0.0 with native extensions
Installing fission 0.5.0
Installing gemojione 2.2.1
Installing rdoc 3.12.2
Installing recaptcha 1.0.2
Installing tzinfo 1.2.2
Installing descendants_tracker 0.0.4
Installing nokogiri 1.6.7.2 with native extensions
Installing rack-test 0.6.3
Installing warden 1.2.4
Installing sprockets 3.3.5
Installing rack-accept 0.4.5
Installing rack-mount 0.8.3
Installing rack-attack 4.3.1
Installing rack-protection 1.5.3
Installing mail 2.6.3
Installing select2-rails 3.5.9.3
Installing css_parser 1.3.7
Installing faraday 0.9.2
Installing httparty 0.13.7
Installing attr_encrypted 1.3.4
Installing autoprefixer-rails 6.2.3
Installing uglifier 2.7.2
Installing influxdb 0.2.3
Installing rqrcode 0.7.0
Installing coffee-script 2.4.1
Installing crack 0.4.3
Installing fog-core 1.35.0
Installing gemnasium-gitlab-service 0.2.6
Installing github-linguist 4.7.5
Installing gollum-rugged_adapter 0.4.2
Installing gitlab-grit 2.7.3
Installing omniauth 1.3.1
Installing haml 4.0.7
Installing ruby_parser 3.7.2
Installing macaddr 1.7.1
Installing org-ruby 0.9.12
Installing unicorn 4.9.0 with native extensions
Installing redis-store 1.1.7
Installing redis-namespace 1.5.2
Installing sidekiq 4.0.1
Installing wikicloth 0.8.1
Installing twitter-stream 0.1.16
Installing unf 0.1.4
Installing gitlab_emoji 0.3.1
Installing activesupport 4.2.5.2
Installing axiom-types 0.1.1
Installing coercible 1.0.0
Installing loofah 2.0.3
Installing sanitize 2.1.0
Installing sinatra 1.4.6
Installing premailer 1.8.6
Installing faraday_middleware 0.10.0
Installing oauth2 1.0.0
Installing sawyer 0.6.0
Installing sentry-raven 0.15.6
Installing flowdock 0.7.1
Installing hipchat 1.5.2
Installing bootstrap-sass 3.3.6
Installing rqrcode-rails3 0.1.7
Installing ruby-fogbugz 0.2.1
Installing fog-json 1.0.2
Installing fog-xml 0.1.2
Installing fog-local 0.2.1
Installing fog-vmfusion 0.1.0
Installing gollum-grit_adapter 1.0.0
Installing gitlab_omniauth-ldap 1.2.1
Installing omniauth-oauth 1.1.0
Installing omniauth-cas3 1.1.3
Installing omniauth-multipassword 0.4.2
Installing omniauth-shibboleth 1.2.1
Installing html2haml 2.0.0
Installing uuid 2.3.8
Installing unicorn-worker-killer 0.4.4
Installing redis-rack 1.5.0
Installing sidekiq-cron 0.4.0
Installing rails-deprecated_sanitizer 1.0.3
Installing globalid 0.3.6
Installing activemodel 4.2.5.2
Installing gitlab_git 10.0.0
Installing grape-entity 0.4.8
Installing html-pipeline 1.11.0
Installing omniauth_crowd 2.2.3
Installing rack-oauth2 1.2.1
Installing redis-activesupport 4.1.5
Installing virtus 1.0.5
Installing rails-html-sanitizer 1.0.3
Installing faraday_middleware-multi_json 0.0.6
Installing tinder 1.10.1
Installing omniauth-oauth2 1.3.1
Installing octokit 3.8.0
Installing gitlab-flowdock-git-hook 1.0.1
Installing fog-aliyun 0.1.0
Installing fog-brightbox 0.10.1
Installing fog-sakuracloud 1.7.5
Installing fog-serverlove 0.1.2
Installing fog-softlayer 1.0.3
Installing fog-storm_on_demand 0.1.1
Installing fog-atmos 0.1.0
Installing fog-aws 0.8.1
Installing fog-dynect 0.0.2
Installing fog-ecloud 0.3.0
Installing fog-google 0.1.0
Installing fog-powerdns 0.1.1
Installing fog-profitbricks 0.0.5
Installing fog-radosgw 0.0.5
Installing fog-riakcs 0.1.0
Installing fog-terremark 0.1.0
Installing fog-voxel 0.1.0
Installing fog-xenserver 0.2.2
Installing gollum-lib 4.1.0
Installing omniauth-bitbucket 0.0.2
Installing omniauth-twitter 1.2.1
Installing omniauth-kerberos 0.3.0
Installing ruby-saml 1.1.2
Installing rails-dom-testing 1.0.7
Installing activejob 4.2.5.2
Installing activerecord 4.2.5.2
Installing carrierwave 0.10.0
Installing state_machines-activemodel 0.3.0
Installing task_list 1.0.2
Installing grape 0.13.0
Installing asana 0.4.0
Installing omniauth-auth0 1.4.1
Installing omniauth-azure-oauth2 0.0.6
Installing omniauth-facebook 3.0.0
Installing omniauth-github 1.1.2
Installing omniauth-gitlab 1.0.1
Installing omniauth-google-oauth2 0.2.10
Installing fog 1.36.0
Installing omniauth-saml 1.5.0
Installing actionview 4.2.5.2
Installing acts-as-taggable-on 3.5.0
Installing after_commit_queue 1.3.0
Installing default_value_for 3.0.1
Installing paranoia 2.1.4
Installing seed-fu 2.3.5
Installing state_machines-activerecord 0.3.0
Installing actionpack 4.2.5.2
Installing actionmailer 4.2.5.2
Installing railties 4.2.5.2
Installing sprockets-rails 2.3.3
Installing gon 6.0.1
Installing kaminari 0.16.3
Installing redis-actionpack 4.0.1
Installing premailer-rails 1.9.0
Installing activerecord-session_store 0.1.2
Installing coffee-rails 4.1.0
Installing d3_rails 3.5.11
Installing responders 2.1.1
Installing doorkeeper 2.2.2
Installing font-awesome-rails 4.5.0.0
Installing haml-rails 0.9.0
Installing jquery-rails 4.0.5
Installing jquery-scrollto-rails 1.4.3
Installing jquery-ui-rails 5.0.5
Installing rails 4.2.5.2
Installing sass-rails 5.0.4
Installing redis-rails 4.0.0
Installing turbolinks 2.5.3
Installing devise 3.5.4
Installing dropzonejs-rails 0.7.2
Installing jquery-turbolinks 2.1.0
Installing devise-async 0.9.0
Installing devise-two-factor 2.0.1
Bundle complete! 173 Gemfile dependencies, 267 gems now installed.
Gems in the groups development, test, postgres and aws were not installed.
Bundled gems are installed into ./vendor/bundle.
Post-install message from browser:
 
#################### WARNING ##############################
#                                                         #
#   Internet Explorer detection has changed on v1.0.0+.   #
#   If this is important for you, please read             #
#   https://github.com/fnando/browser#internet-explorer   #
#                                                         #
###########################################################
 
Post-install message from mousetrap-rails:
 
Remember to run generator to generate sample file and include mousetrap-rails with Rails Asset Pipeline
 
    $ rails generate mousetrap:install
 
Post-install message from rdoc:
Depending on your version of ruby, you may need to install ruby rdoc/ri data:
 
<= 1.8.6 : unsupported
 = 1.8.7 : gem install rdoc-data; rdoc-data --install
 = 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
Post-install message from httparty:
When you HTTParty, you must party hard!
Post-install message from haml:
 
HEADS UP! Haml 4.0 has many improvements, but also has changes that may break
your application:
 
* Support for Ruby 1.8.6 dropped
* Support for Rails 2 dropped
* Sass filter now always outputs <style> tags
* Data attributes are now hyphenated, not underscored
* html2haml utility moved to the html2haml gem
* Textile and Maruku filters moved to the haml-contrib gem
 
For more info see:
 
http://rubydoc.info/github/haml/haml/file/CHANGELOG.md
 
Post-install message from html-pipeline:
-------------------------------------------------
Thank you for installing html-pipeline!
You must bundle Filter gem dependencies.
See html-pipeline README.md for more details.
https://github.com/jch/html-pipeline#dependencies
-------------------------------------------------
Post-install message from acts-as-taggable-on:
When upgrading
 
Re-run the migrations generator
 
    rake acts_as_taggable_on_engine:install:migrations
 
This will create any new migrations and skip existing ones
Version 3.5.0 has a migration for mysql adapter
[root@DS-VM-Node83 /data/git/gitlab]#

14、安装gitlab-shell

[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git -H bundle exec rake gitlab:shell:install[v$(cat GITLAB_SHELL_VERSION)] REDIS_URL=unix:/var/run/redis/redis.sock RAILS_ENV=production
WARNING: This version of GitLab depends on gitlab-shell 2.6.11, but you're running Unknown. Please update gitlab-shell.
Missing `db_key_base` for 'production' environment. The secrets will be generated and stored in `config/secrets.yml`
正克隆到 '/data/git/gitlab-shell'...
remote: Counting objects: 2558, done.
remote: Compressing objects: 100% (895/895), done.
remote: Total 2558 (delta 1607), reused 2501 (delta 1571)
接收对象中: 100% (2558/2558), 360.62 KiB | 221.00 KiB/s, 完成.
处理 delta 中: 100% (1607/1607), 完成.
检查连接... 完成。
HEAD 现在位于 bceed73 Update CHANGELOG for 2.6.11
mkdir -p /data/git/repositories/: OK
mkdir -p /data/git/.ssh: OK
chmod 700 /data/git/.ssh: OK
touch /data/git/.ssh/authorized_keys: OK
chmod 600 /data/git/.ssh/authorized_keys: OK
chmod ug+rwX,o-rwx /data/git/repositories/: OK
[root@DS-VM-Node83 /data/git/gitlab]#

15、配置gitlab-shell

[root@DS-VM-Node83 /data/git/gitlab]# cat /data/git/gitlab-shell/config.yml
---
user: git
gitlab_url: http://git.dwhd.org/
http_settings:
  self_signed_cert: false
repos_path: "/data/git/repositories/"
auth_file: "/data/git/.ssh/authorized_keys"
redis:
  bin: "/usr/local/redis/bin/redis-cli"
  namespace: resque:gitlab
  socket: "/var/run/redis/redis.sock"
log_level: INFO
audit_usernames: false
[root@DS-VM-Node83 /data/git/gitlab]#

16、安装 gitlab-workhorse

[root@DS-VM-Node83 /data/git/gitlab]# cd ..
[root@DS-VM-Node83 /data/git]# sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-workhorse.git 
[root@DS-VM-Node83 /data/git]# cd gitlab-workhorse 
[root@DS-VM-Node83 /data/git]# sudo -u git -H make
17、初始化数据并且激活高级特性
1
[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD=lookback GITLAB_ROOT_EMAIL=admin@dwhd.org
Linux之CentOS 7上安装GitLab 8-6中文版

18、安装启动脚本和设置开机启动

[root@DS-VM-Node83 /data/git/gitlab]# cd /etc/systemd/system/
[root@DS-VM-Node83 /etc/systemd/system]# wget -O gitlab-sidekiq.service https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/init/systemd/gitlab-sidekiq.service
[root@DS-VM-Node83 /etc/systemd/system]# wget -O gitlab-unicorn.service https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/init/systemd/gitlab-unicorn.service
[root@DS-VM-Node83 /etc/systemd/system]# wget -O gitlab-workhorse.service https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/init/systemd/gitlab-workhorse.service
[root@DS-VM-Node83 /etc/systemd/system]# wget -O gitlab-mailroom.service https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/init/systemd/gitlab-mailroom.service
[root@DS-VM-Node83 /etc/systemd/system]# sed -i 's/Requires=redis.service/#&/' /etc/systemd/system/gitlab-*
[root@DS-VM-Node83 /etc/systemd/system]# sed -i 's@/home@/data@g' /etc/systemd/system/gitlab-*
[root@DS-VM-Node83 /etc/systemd/system]# sed -i 's@/usr/bin/bundle@/usr/local/bin/bundle@g' /etc/systemd/system/gitlab-* && cd /data/git/gitlab
[root@DS-VM-Node83 /data/git/gitlab]# systemctl daemon-reload
[root@DS-VM-Node83 /data/git/gitlab]# systemctl start gitlab-sidekiq gitlab-unicorn gitlab-workhorse gitlab-mailroom
[root@DS-VM-Node83 /data/git/gitlab]# systemctl enable gitlab-sidekiq.service gitlab-unicorn.service gitlab-workhorse.service gitlab-mailroom.service

[root@DS-VM-Node83 /data/git/gitlab]# systemctl status gitlab-sidekiq.service gitlab-unicorn.service gitlab-workhorse.service gitlab-mailroom.service
● gitlab-sidekiq.service - GitLab Sidekiq Worker
   Loaded: loaded (/etc/systemd/system/gitlab-sidekiq.service; enabled; vendor preset: disabled)
   Active: active (running) since 五 2016-04-08 02:17:10 CST; 1min 19s ago
  Process: 9394 ExecStop=/usr/local/bin/bundle exec sidekiqctl stop /data/git/gitlab/tmp/pids/sidekiq.pid >> /data/git/gitlab/log/sidekiq.log 2>&1 (code=exited, status=0/SUCCESS)
  Process: 9444 ExecStart=/usr/local/bin/bundle exec sidekiq -d -q archive_repo -q post_receive -q mailers -q system_hook -q incoming_email -q project_web_hook -q gitlab_shell -q common -q default -e production -P tmp/pids/sidekiq.pid -d -L log/sidekiq.log >> log/sidekiq.log 2>&1 (code=exited, status=0/SUCCESS)
 Main PID: 9484 (ruby)
   CGroup: /system.slice/gitlab-sidekiq.service
           └─9484 sidekiq 4.0.1 gitlab [0 of 25 busy]
 
4月 08 02:17:09 DS-VM-Node83.cluster.com systemd[1]: Starting GitLab Sidekiq Worker...
4月 08 02:17:10 DS-VM-Node83.cluster.com systemd[1]: PID file /data/git/gitlab/tmp/pids/sidekiq.pid not readable (yet?) after start.
4月 08 02:17:10 DS-VM-Node83.cluster.com systemd[1]: gitlab-sidekiq.service: Supervising process 9484 which is not our child. We'll most likely not notice when it exits.
4月 08 02:17:10 DS-VM-Node83.cluster.com systemd[1]: Started GitLab Sidekiq Worker.
 
● gitlab-unicorn.service - GitLab Unicorn Server
   Loaded: loaded (/etc/systemd/system/gitlab-unicorn.service; enabled; vendor preset: disabled)
   Active: active (running) since 五 2016-04-08 02:17:09 CST; 1min 20s ago
 Main PID: 9478 (ruby)
   CGroup: /system.slice/gitlab-unicorn.service
           ├─9478 unicorn_rails master -D -c /data/git/gitlab/config/unicorn.rb -E production
           ├─9576 unicorn_rails worker[0] -D -c /data/git/gitlab/config/unicorn.rb -E production
           └─9579 unicorn_rails worker[1] -D -c /data/git/gitlab/config/unicorn.rb -E production
 
4月 08 02:17:09 DS-VM-Node83.cluster.com systemd[1]: Started GitLab Unicorn Server.
4月 08 02:17:09 DS-VM-Node83.cluster.com systemd[1]: Starting GitLab Unicorn Server...
 
● gitlab-workhorse.service - Gitlab Workhorse handles slow HTTP requests for Gitlab.
   Loaded: loaded (/etc/systemd/system/gitlab-workhorse.service; enabled; vendor preset: disabled)
   Active: active (running) since 五 2016-04-08 02:17:10 CST; 1min 20s ago
  Process: 9446 ExecStart=/data/git/gitlab/bin/daemon_with_pidfile /data/git/gitlab/tmp/pids/gitlab-workhorse.pid /data/git/gitlab-workhorse/gitlab-workhorse -listenUmask 0 -listenNetwork unix -listenAddr /data/git/gitlab/tmp/sockets/gitlab-workhorse.socket -authBackend http://127.0.0.1:8080 -authSocket /data/git/gitlab/tmp/sockets/gitlab.socket -documentRoot /data/git/gitlab/public >> /data/git/gitlab/log/gitlab-workhorse.log 2>&1 (code=exited, status=0/SUCCESS)
 Main PID: 9460 (gitlab-workhors)
   CGroup: /system.slice/gitlab-workhorse.service
           └─9460 /data/git/gitlab-workhorse/gitlab-workhorse -listenUmask 0 -listenNetwork unix -listenAddr /data/git/gitlab/tmp/sockets/gitlab-workhorse.socket -authBackend http://127.0....
 
4月 08 02:17:09 DS-VM-Node83.cluster.com systemd[1]: Starting Gitlab Workhorse handles slow HTTP requests for Gitlab....
4月 08 02:17:10 DS-VM-Node83.cluster.com systemd[1]: Started Gitlab Workhorse handles slow HTTP requests for Gitlab..
 
● gitlab-mailroom.service - Gitlab mailroom Worker
   Loaded: loaded (/etc/systemd/system/gitlab-mailroom.service; enabled; vendor preset: disabled)
   Active: active (exited) since 五 2016-04-08 02:17:10 CST; 1min 20s ago
  Process: 9395 ExecStop=/data/git/gitlab/bin/mail_room stop (code=exited, status=0/SUCCESS)
  Process: 9447 ExecStart=/data/git/gitlab/bin/mail_room start (code=exited, status=0/SUCCESS)
 Main PID: 9447 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/gitlab-mailroom.service
           └─9464 ruby /data/git/gitlab/vendor/bundle/ruby/2.3.0/bin/mail_room -q -c /data/git/gitlab/config/mail_room.yml
 
4月 08 02:17:09 DS-VM-Node83.cluster.com systemd[1]: Starting Gitlab mailroom Worker...
4月 08 02:17:10 DS-VM-Node83.cluster.com systemd[1]: Started Gitlab mailroom Worker.
[root@DS-VM-Node83 /data/git/gitlab]#
Linux之CentOS 7上安装GitLab 8-6中文版

19、设置日志滚动
1
2
[root@DS-VM-Node83 /data/git/gitlab]# cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
[root@DS-VM-Node83 /data/git/gitlab]# chmod g+rx /data/git

20、检查应用程序状态

[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
 
System information
System: 
Current User:   git
Using RVM:  no
Ruby Version:   2.3.0p0
Gem Version:    2.5.1
Bundler Version:1.11.2
Rake Version:   10.5.0
Sidekiq Version:4.0.1
 
GitLab information
Version:    8.6.2
Revision:   cc5211c
Directory:  /data/git/gitlab
DB Adapter: mysql2
URL:        http://git.dwhd.org
HTTP Clone URL: http://git.dwhd.org/some-group/some-project.git
SSH Clone URL:  git@git.dwhd.org:some-group/some-project.git
Using LDAP: no
Using Omniauth: no
 
GitLab Shell
Version:    2.6.11
Repositories:   /data/git/repositories/
Hooks:      /data/git/gitlab-shell/hooks/
Git:        /usr/local/bin/git
[root@DS-VM-Node83 /data/git/gitlab]# ../gitlab-shell/bin/check
Check GitLab API access: OK
Check directories and files:
    /data/git/repositories/: OK
    /data/git/.ssh/authorized_keys: OK
Test redis-cli executable: redis-cli 3.0.7
Send ping to redis server: PONG
[root@DS-VM-Node83 /data/git/gitlab]#

[root@DS-VM-Node83 /data/git/gitlab]# sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production 
Checking GitLab Shell ...
 
GitLab Shell version >= 2.6.12 ? ... OK (2.6.12)
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
hooks directories in repos are links: ...
Benyoo / test ... ok
jason / ceshi ... ok
Running /data/git/gitlab-shell/bin/check
Check GitLab API access: OK
Check directories and files:
    /data/git/repositories/: OK
    /data/git/.ssh/authorized_keys: OK
Test redis-cli executable: redis-cli 3.0.6
Send ping to redis server: PONG
gitlab-shell self-check successful
 
Checking GitLab Shell ... Finished
 
Checking Sidekiq ...
 
Running? ... yes
Number of Sidekiq processes ... 1
 
Checking Sidekiq ... Finished
 
Checking Reply by email ...
 
Reply by email is disabled in config/gitlab.yml
 
Checking Reply by email ... Finished
 
Checking LDAP ...
 
LDAP is disabled in config/gitlab.yml
 
Checking LDAP ... Finished
 
Checking GitLab ...
 
Git configured with autocrlf=input? ... yes
Database config exists? ... yes
All migrations up? ... yes
Database contains orphaned GroupMembers? ... no
GitLab config exists? ... yes
GitLab config outdated? ... no
Log directory writable? ... yes
Tmp directory writable? ... yes
Uploads directory setup correctly? ... no
  Try fixing it:
  sudo find /data/git/gitlab/public/uploads -type d -not -path /data/git/gitlab/public/uploads -exec chmod 0700 {} \;
  For more information see:
  doc/install/installation.md in section "GitLab"
  Please fix the error above and rerun the checks.
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 namespace: ...
Benyoo / test ... yes
jason / ceshi ... yes
Redis version >= 2.8.0? ... yes
Ruby version >= 2.1.0 ? ... yes (2.3.0)
Your git bin path is "/usr/local/bin/git"
Git version >= 2.7.3 ? ... yes (2.8.0)
Active users: 3
 
Checking GitLab ... Finished
 
[root@DS-VM-Node83 /data/git/gitlab]#

 

时间: 2024-08-03 23:13:29

CentOS 7上安装GitLab 8-6中文版教程的相关文章

CentOS 6上安装部署Graphite编程接口教程

Graphite 是一个Python写的web应用,采用django框架,Graphite用来进行收集服务器所有的即时状态,用户请求信息,Memcached命中率,RabbitMQ消息服务器的状态,Unix操作系统的负载状态,Graphite服务器大约每分钟需要有4800次更新操作,Graphite采用简单的文本协议和绘图功能可以方便地使用在任何操作系统上 环境介绍: OS: CentOS6.5 x86_64 Minimal 1. 安装EPEL扩展库 # yum install -y epel-

git学习------&amp;gt;在CenterOS系统上安装GitLab并自定义域名访问GitLab管理页面

目前就职的公司一直使用SVN作为版本管理,现在打算尝试从SVN迁移到Git.安排我来预言并搭建好相关的环境以及自己尝试使用Git.今天我就尝试在Center OS系统上安装GitLab,现在在此记录一下整个安装过程. 第一步 查看GitLab的官方网站 GitLab的官方网站关于安装gitlab的介绍页面如下: https://about.gitlab.com/installation/ 选择 CenterOS,切换到如下的页面 按照如上图的步骤,一步一步的来即可安装成功. 第二步 安装GitL

如何在CentOS 7上安装iRedMail集成到Samba4 AD

本系列教程将引导你了解如何在 CentOS 7 安装 iRedMail 以及 Samba4 AD 域控制器,以便域帐户可以通过 Thunderbird 桌面客户端或通过 Roundcube Web 界面发送或接收邮件. 将要安装 iRedMail 的 CentOS 7 服务器需允许通过 25 和 587 端口进行 SMTP 或邮件路由服务,并且还将通过 Dovecot 作为邮件传递代理,提供 POP3 和 IMAP 服务,两者都使用安装过程中签发的自签名证书进行安全保护. 收件人邮箱将与 Rou

如何在CentOS 7上安装Redis服务器

大家好,本文的主题是 Redis,我们将要在 CentOS 7 上安装它.编译源代码,安装二进制文件,创建.安装文件.在安装了它的组件之后,我们还会配置 redis ,就像配置操作系统参数一样,目标就是让 redis 运行的更加可靠和快速. Redis 服务器 Redis 是一个开源的多平台数据存储软件,使用 ANSI C 编写,直接在内存使用数据集,这使得它得以实现非常高的效率.Redis 支持多种编程语言,包括 Lua, C, Java, Python, Perl, PHP 和其他很多语言.

如何在 CentOS 7 上安装 Elastic Stack

Elasticsearch 是基于 Lucene 由 Java 开发的开源搜索引擎.它提供了一个分布式.多租户的全文搜索引擎(LCTT 译注:多租户是指多租户技术,是一种软件架构技术,用来探讨与实现如何在多用户的环境下共用相同的系统或程序组件,并且仍可确保各用户间数据的隔离性.),并带有 HTTP 仪表盘的 Web 界面(Kibana).数据会被 Elasticsearch 查询.检索,并且使用 JSON 文档方案存储.Elasticsearch 是一个可扩展的搜索引擎,可用于搜索所有类型的文本

在CentOS 7上安装phpMyAdmin

原文 在CentOS 7上安装phpMyAdmin phpMyAdmin是一款以PHP为基础,基于Web的MySQL/MariaDB数据库管理工具.虽然已经存在着一些诸如Adminer的轻量级数据库管理工具, 但是phpMyAdmin还是更加广泛应用于网站管理员之中来进行各种MySQL/MariaDB的管理任务.它支持几乎所有MySQL数据库/表的相关操作,比如浏览.创建.复制.删除.重命名.更改,还有MySQL用户/权限管理和数据库导入/导出.以下就是如何在CentOS 6或7上安装phpMy

在CentOS 7上安装并配置Python 3.6环境

拖了很久没有更新,抱歉啦~ 今天受邀写篇如何在 CentOS 7 上配置 Python 3 环境的文章.往常我都选择直接把我早年写的一篇文章源码编译MongoDB丢过去,让他们看其中的源码编译 Python 那一节,不过那节写的其实不太详细,而且最近被很多人催,所以还是单独写一篇好了. 当前最新的 CentOS 7.3 默认安装的是 Python 2 ,并且默认的官方 yum 源中不提供 Python 3 的安装包.有些用户想要升级使用 Python 3 但实际可能有各种各样的问题,导致出错,反

如何在 CentOS 7 上安装 Redis 服务器

如何在 CentOS 7 上安装 Redis 服务器 大家好,本文的主题是 Redis,我们将要在 CentOS 7 上安装它.编译源代码,安装二进制文件,创建.安装文件.在安装了它的组件之后,我们还会配置 redis ,就像配置操作系统参数一样,目标就是让 redis 运行的更加可靠和快速. Redis 服务器 Redis 是一个开源的多平台数据存储软件,使用 ANSI C 编写,直接在内存使用数据集,这使得它得以实现非常高的效率.Redis 支持多种编程语言,包括 Lua, C, Java,

如何在Ubuntu 15.04/CentOS 7上安装Android Studio

随着最近几年智能手机的进步,安卓成为了最大的手机平台之一,在开发安卓应用中所用到的所有工具也都可以免费得到.Android Studio 是基于 IntelliJ IDEA 用于开发安卓应用的集成开发环境(IDE).它是 Google 2014 年发布的免费开源软件,继 Eclipse 之后成为主要的 IDE. 在这篇文章,我们一起来学习如何在 Ubuntu 15.04 和 CentOS 7 上安装 Android Studio. 在 Ubuntu 15.04 上安装 我们可以用两种方式安装 A