日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

CentOS7 安装 Gitlab

發布時間:2025/3/20 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CentOS7 安装 Gitlab 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

GitLab,是一個利用 Ruby on Rails 開發的開源應用程序,實現一個自托管的Git項目倉庫,可通過Web界面進行訪問公開的或者私人項目。

它擁有與Github類似的功能,能夠瀏覽源代碼,管理缺陷和注釋。可以管理團隊對倉庫的訪問,它非常易于瀏覽提交過的版本并提供一個文件歷史庫。團隊成員可以利用內置的簡單聊天程序(Wall)進行交流。它還提供一個代碼片段收集功能可以輕松實現代碼復用,便于日后有需要的時候進行查找。

開源項目地址:https://github.com/gitlabhq/gitlabhq

安裝步驟

1、提供一些必須包,提供epel,關閉防火墻和selinux等操作;

2、gitlab依賴的python功能比較多,需要升級python到2.7.X;

3、安裝redis的內存數據庫;

4、安裝MySQL的關系型數據庫;

5、為gitlab提供ruby的環境支持;

6、提供gitlab-shell來管理git倉庫;

7、安裝gitlab系統;

8、安裝nginx的web服務,做反向代理。


一、安裝擴展源和依賴包

#安裝擴展源 rpm?-ivh?epel-release-7-5.noarch.rpm???#修改/etc/yum.repo.d/epel.repo ----------------------------------------------------------------- #增加puias源 vim?/etc/yum.repos.d/PUIAS_6_computational.repo?#增加以下內容 [PUIAS_6_computational] name=PUIAS?computational?Base?$releasever?-?$basearch mirrorlist=http://puias.math.ias.edu/data/puias/computational/$releasever/$basearch/mirrorlist #baseurl=http://puias.math.ias.edu/data/puias/computational/$releasever/$basearch gpgcheck=1 gpgkey= ------------------------------------------------------------------? wget?-O?/etc/pki/rpm-gpg/RPM-GPG-KEY-puias?http://springdale.math.ias.edu/data/puias/6/x86_64/os/RPM-GPG-KEY-puias? rpm?--import?/etc/pki/rpm-gpg/RPM-GPG-KEY-puias #驗證是否成功 rpm?-qa?gpg*

查看倉庫源

yum?repolist 已加載插件:fastestmirror Loading?mirror?speeds?from?cached?hostfile*?PUIAS_6_computational:?www.puias.princeton.edu*?epel:?ftp.sjtu.edu.cn 倉庫標識??????????????????????????????倉庫名稱??????????????????????????????????????????????????????狀態 PUIAS_6_computational?????????????????PUIAS?computational?Base?6?-?x86_64???????????????????????????2,638 base??????????????????????????????????CentOS-6?-?Base?-?163.com?????????????????????????????????????6,518 *epel?????????????????????????????????Extra?Packages?for?Enterprise?Linux?6?-?x86_64????????????????11,148 extras????????????????????????????????CentOS-6?-?Extras?-?163.com???????????????????????????????????36 updates???????????????????????????????CentOS-6?-?Updates?-?163.com??????????????????????????????????727 repolist:?21,067

如果此列表中沒有epel和PUIAS_6_computational,請執行以下命令

yum-config-manager?--enable?epel?--enable?PUIAS_6_computational


二、安裝依賴包

yum?-y?update yum?-y?groupinstall?'Development?Tools‘ 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?redis?sudo?wget?crontabs?logwatch?logrotate?perl-Time-HiRes?git?cmake?libcom_err-devel?libcom_err-devel


三、安裝Git?

yum?-y?remove?git? yum?-y?install?zlib-devel?perl-CPAN?gettext?curl-devel?expat-devel?gettext-devel?openssl-devel mkdir?/tmp/git?&&?cd?/tmp/git wget?https://www.kernel.org/pub/software/scm/git/git-2.6.2.tar.xz tar??Jxf??git-2.6.0.tar.gz cd???git-2.6.0 ./configure??--prefix=/usr/local make?&&?make?install

驗證Git

git?--version


四、安裝Ruby

yum?-y?remove?ruby? cd?/tmp/git wget?https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.3.tar.gz tar?zxvf??ruby-2.2.3.tar.gz cd?ruby-2.2.3./configure?--prefix=/usr/local/ruby?--disable-install-rdocmake?&&?make?install echo?'export?PATH=/usr/local/ruby/bin:$PATH'?>>?/etc/profile source?/etc/profile

驗證Ruby

ruby?-v ruby?2.2.3p173?(2015-08-18?revision?51636)?[x86_64-linux]

修改RubyGames鏡像為淘寶,提高下載速度

?vim?/home/git/gitlab/Gemfilesource?"??#替換為淘寶

安裝bundler

gem?install?bundler?--no-doc


五、創建系統用戶

adduser?--system?--shell?/bin/bash?--comment?'GitLab'?--create-home?--home-dir?/home/git/?git


六、修改sudo文件,讓git用戶使用sudo

visudo Defaults????secure_path?=?/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin??#替換為這個 #在root????ALL=(ALL)???????ALL下增加一行git?????ALL=(ALL)???????ALL


七、安裝MySQL

#卸載CentOS7自帶的MaraiaDB? rpm?-qa?|?grep?maraiadb? yum?-y??remove?maraiadb? #安裝依賴包 yum?-y?install?make?gcc-c++?cmake?bison-devel??ncurses-devel #下載MySQL cd?/tmp/git wget?wget? tar?zxvf??mysql-5.6.20.tar.gz cd?/mysql-5.6.20 #編譯MySQL cmake?\ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql?\ -DMYSQL_DATADIR=/usr/local/mysql/data?\ -DSYSCONFDIR=/etc?\ -DWITH_MYISAM_STORAGE_ENGINE=1?\ -DWITH_INNOBASE_STORAGE_ENGINE=1?\ -DWITH_MEMORY_STORAGE_ENGINE=1?\ -DWITH_READLINE=1?\ -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock?\ -DMYSQL_TCP_PORT=3306?\ -DENABLED_LOCAL_INFILE=1?\ -DWITH_PARTITION_STORAGE_ENGINE=1?\ -DEXTRA_CHARSETS=all?\ -DDEFAULT_CHARSET=utf8?\ -DDEFAULT_COLLATION=utf8_general_ci #安裝 make?&&?make?install? #配置MySQL用戶 groupadd?mysql useradd?-g?mysql?mysql #修改/usr/local/mysql? chown?-R?mysql:mysql?/usr/local/mysql #初始化MySQL cd?/usr/local/mysql #執行初始化腳本 scripts/mysql_install_db?--basedir=/usr/local/mysql?--datadir=/usr/local/mysql/data?--user=mysql #添加服務,設置開機啟動 cp?support-files/mysql.server?/etc/init.d/mysql chkconfig?mysql?on service?mysql?start??--啟動MySQL #配置變量 vim?/etc/profilePATH=/usr/local/mysql/bin:$PATHexport?PATH source??/etc/profile

創建數據庫、數據庫用戶和并授權

mysql?-u?root?-p mysql>?CREATE?USER?'git'@'localhost'?IDENTIFIED?BY?'123.com'; mysql>?CREATE?DATABASE?IF?NOT?EXISTS?`gitlabhq_production`?DEFAULT?CHARACTER?SET?`utf8`?COLLATE?`utf8_unicode_ci`; mysql>?GRANT?SELECT,?LOCK?TABLES,?INSERT,?UPDATE,?DELETE,?CREATE,?DROP,?INDEX,?ALTER?ON?`gitlabhq_production`.*?TO?'git'@'localhost';

測試能否成功登陸

mysql?-ugit?-p123.com?-D?gitlabhq_production


八、配置Redis

chkconfig?redis?oncp?/etc/redis.conf?/etc/redis.conf.orig#修改監聽端口 sed?'s/^port?.*/port?0/'?/etc/redis.conf.orig?|tee?/etc/redis.conf#增加內容 echo?'unixsocket?/var/run/redis/redis.sock'?|tee?-a?/etc/redis.confecho?-e?'unixsocketperm?0770'?|tee?-a?/etc/redis.conf

創建目錄改權限

mkdir?/var/run/redischown?redis:redis?/var/run/redischmod?755?/var/run/redis

啟動服務

service?redis?restart

添加git到redis組

usermod?-aG?redis?git


九、安裝GitLab

su?git#下載源碼 sudo?-u?git?-H?git?clone?https://gitlab.com/gitlab-org/gitlab-ce.git?-b?7-4-stable?gitlab

修改配置

cd?gitLab/sudo?-u?git?-H?cp?config/gitlab.yml.example?config/gitlab.ymlsudo?-u?git?-H?vim?config/gitlab.yml gitlab:##?Web?server?settings?(note:?host?is?the?FQDN,?do?not?include?http://)host:?localhostport:?80https:?false

修改目錄權限

chown?-R?git?log/ chown?-R?git?tmp/ chmod?-R?u+rwX?log/ chmod?-R?u+rwX?tmp/ chmod?-R?u+rwX?tmp/pids/ chmod?-R?u+rwX?tmp/sockets/ chmod?-R?u+rwX??public/uploads

創建目錄

sudo?-u?git?-H?mkdir?/home/git/gitlab-satellites chmod?u+rwx,g=rx,o-rwx?/home/git/gitlab-satellites

編輯配置文件unicorn.rb

sudo?-u?git?-H?cp?config/unicorn.rb.example?config/unicorn.rb#查看系統核心數 nproc 1#編輯配置 sudo?-u?git?-H?vim?config/unicorn.rb worker_processes?1

拷貝配置文件

sudo?-u?git?-H?cp?config/initializers/rack_attack.rb.example?config/initializers/rack_attack.rb

定義全局用戶和郵箱

sudo?-u?git?-H?git?config?--global?user.name?"GitLab" sudo?-u?git?-H?git?config?--global?user.email?"example@example.com" sudo?-u?git?-H?git?config?--global?core.autocrlf?input

編輯連接redis配置

#拷貝配置 sudo?-u?git?-H?cp?config/resque.yml.example?config/resque.yml#連接redis配置,默認配置,未修改 sudo?-u?git?-H?vim?config/resque.yml


十、配置GitLab數據庫文件

sudo?-u?git?cp?config/database.yml.mysql?config/database.yml#編輯配置文件 sudo?-u?git?-H?vim?config/database.yml production:adapter:?mysql2encoding:?utf8collation:?utf8_general_cireconnect:?falsedatabase:?gitlabhq_productionpool:?10username:?gitpassword:?"gitpwd"host:?localhostsocket:?/var/lib/mysql/mysql.sock?#修改文件權限,只有git用戶可讀 sudo?-u?git?-H?chmod?o-rwx?config/database.yml


十一、安裝gem

cd?/home/git/gitLabsudo?-u?git?-H?bundle?install?--deployment?--without?development?test?postgres?aws


十二、安裝GitLab-shell

sudo?-u?git?-H?bundle?exec?rake?gitlab:shell:install[v2.0.1]?REDIS_URL=unix:/var/run/redis/redis.sock?RAILS_ENV=production #編輯配置 sudo?-u?git?-H?vim?/home/git/gitlab-shell/config.yml --- user:?git gitlab_url:?https://localhost/ http_settings:self_signed_cert:?true repos_path:?"/home/git/repositories/" auth_file:?"/home/git/.ssh/authorized_keys" redis:bin:?"/usr/bin/redis-cli"namespace:?resque:gitlabsocket:?"/var/run/redis/redis.sock" log_level:?INFO audit_usernames:?false


十三、初始化數據庫

sudo?-u?git?-H?bundle?exec?rake?gitlab:setup?RAILS_ENV=production


十四、下載服務腳本

wget?-O?/etc/init.d/gitlab?? chmod?+x?/etc/init.d/gitlabchkconfig?--add?gitlabchkconfig?gitlab?on#設置logrotate cp?lib/support/logrotate/gitlab?/etc/logrotate.d/gitlab#檢測應用狀態 sudo?-u?git?-H?bundle?exec?rake?gitlab:env:info?RAILS_ENV=productionsudo?-u?git?-H?bundle?exec?rake?assets:precompile?RAILS_ENV=production#給bin/web??bin/background_jobs目錄權限 chmod??755??/home/git/gitlab/bin/web?chmod??755??/home/git/gitlab/bin/background_jobs#啟動服務 service?gitlab?start


十五、配置Web服務

#本人使用的nginx yum?-y?install?nginxchkconfig?nginx?onwget?-O?/etc/nginx/conf.d/gitlab.conf?https://gitlab.com/gitlab-org/gitlab-ce/raw/master/lib/support/nginx/gitlab-ssl

添加nginx到git組

usermod?-a?-G?git?nginxchmod?g+rx?/home/git/

修改配置,修改server_name

vim?/etc/nginx/conf.d/gitlab.conf#兩個server_name如果沒有域名,改成自己的IP地址#注釋nginx.conf中的監聽端口,不然后邊啟動nginx,會報錯vim??/etc/nginx/nginx.conflisten???????[::]:80?default_server;???注釋掉

添加SSL

mkdir?/etc/nginx/ssl執行??openssl?req?-newkey?rsa:2048?-x509?-nodes?-days?3560?-out?gitlab.crt?-keyout?gitlab.key??#隨便填就行,最后生成gitlab.crt??gitlab.keycp?gitlab.crt??gitlab.key?/etc/nginx/ssl

啟動nginx 服務

service?nginx?start#訪問登錄 #用戶名:root #密碼:5iveL!fe


轉載于:https://blog.51cto.com/zhaijunming5/1715131

總結

以上是生活随笔為你收集整理的CentOS7 安装 Gitlab的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。