设为首页 收藏本站
查看: 745|回复: 0

[经验分享] centos 6下安装gitlab,使用apache作为webserver

[复制链接]

尚未签到

发表于 2015-10-15 09:02:48 | 显示全部楼层 |阅读模式
时间 2014-08-12 01:41:47            dzone.com: unix-linux                   相似文章(0)原文                 http://hungred.com/how-to/installing-gitlab-centos-6-apache-server-cpanel-dns-server/Please take note these instruction is installed on top of cPanel DNS only server, therefore all services for both gitlab and cpanel DNS Only will still works side by side.
Instroduction to GitLab
    Before get start with the installation process , let me give a short description about   gitlab    . Gitlab is open source software to collaborate on code. It can be considered as an open source self hosted. Evengitlab is very similar to github adoption will be straightforward, but it also allows us to completely control the environment.So,   Who directly benefits from / will use this improvement?(target audiences) and the answer will be -> Developers, Doc team.   There are few advantage   why Gitlab

  • hosted on our own servers
  • better git viewer
  • integrated dreditor (comment on line level)
  • inline editing of all files
  • linking issues
  • pull requests
  • protected branches
  • private repos possible
  Read this for more information regrading Gitlab
  For the Installation process we believe you know some of the centos Command
  If not familiar Read Some tutorial or      Refer this link
  The GitLab installation consists of setting up the following components:

  • Install the base operating system (CentOS 6.5 Minimal) and Packages / Dependencies
  • Ruby
  • System Users
  • GitLab shell(GitLab Shell is an application that allows you to execute git commands and provide ssh access to git repositories. It is not a unix shell nor a replacement for Bash or Zsh.)
  • Database(Mysql)
  • Gitlab
  • Web Server(apache)
  For fresh installation of the linux centos refer to the below link..
  Refer this
  1.Installing the operating system
  The process start with the installation of the clean CentOS 6.5 “minimal” and it    can be accomplished by downloading the appropriate installation iso file. Just boot the system of the iso file and install the system.
  Important !
  Note that during the installation you use the “Configure Network” option (it’s a button in the same screen where you specify the hostname) to enable the “Connect automatically” option for the network interface and hand (usually eth0).
  If you forget this option the network will NOT start at boot.
  Updating and installing basic software and services
  Installing EPEL repository
  EPEL is a volunteer-based community effort from the Fedora project to create a repository of high-quality add-on packages
  Download the GPG key for EPEL repository from fedoraproject and install it on your system:
wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 https://www.fedoraproject.org/static/0608B895.txtrpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
  Verify that the key got installed successfully:
rpm -qa gpg*gpg-pubkey-0608b895-4bd22942
  install the epel-release-6-8.noarch package,to be enable EPEL repository on your system:
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
  
  PUIAS Computational repository
  
  The PUIAS Computational repository is a part of PUIAS/Springdale Linux, a custom Red Hat:registered: distribution maintained by Princeton University and the Institute for Advanced Study. We take advantage of the PUIAS Computational repository to obtain agit v1.8.x package since the base CentOS repositories only provide v1.7.1 which is not compatible with GitLab. Although the PUIAS offers an RPM to install the repo, it requires the other PUIAS repos as a dependency, so you’ll have to add it manually. Otherwiseyou can install git from source (instructions below).
  Download PUIAS repo:
wget -O /etc/yum.repos.d/PUIAS_6_computational.repo https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/install/centos/PUIAS_6_computational.repo
  Next download and install the gpg key:
wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-puiashttp://springdale.math.ias.edu/data/puias/6/x86_64/os/RPM-GPG-KEY-puiasrpm--import /etc/pki/rpm-gpg/RPM-GPG-KEY-puias
  Verify that the key got installed successfully:
rpm -qa gpg*gpg-pubkey-41a40948-4ce19266
  Verify that the EPEL and PUIAS Computational repositories are enabled as shown below:
yum repolistrepo id repo name statusPUIAS_6_computational PUIAS computational Base6 - x86_642,018base CentOS-6 - Base4,802epel Extra Packagesfor Enterprise Linux 6 - x86_647,879extras CentOS-6 - Extras12updates CentOS-6 - Updates814repolist:15,525
  If you can’t see them listed, use the folowing command (from yum-utils package) to enable them:
yum-config-manager --enable epel --enable PUIAS_6_computational
  Now install tools that required for gitlab
yum -y updateyum -y groupinstall'Development Tools'yum -y install readline readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel openssl-develcurl-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
  
  RHEL Notes->If some packages (eg. gdbm-devel, libffi-devel and libicu-devel) are NOT installed, add the rhel6 optional packages repo to your server to get those packages:
  
yum-config-manager --enable rhel-6-server-optional-rpms
  Note:      During this installation some files will need to be edited manually. If you are familiar with vim set it as default editor with the commands below. If you are not familiar with vim please skip this and keep using the default editor.   
  optional
# Install vim and setasdefault editoryum -y install vim-enhancedupdate-alternatives --set editor /usr/bin/vim.basic#For reStructuredText markuplanguage support, install required package:yum -y install python-docutils
  You have to config redis start on boot :
chkconfig redis onservice redis start
  Next, need to install    Mail server
# The recommended one is postfixyum -y install postfix
  if you are using exim as mail agent, try to add this command to exim configuration at /etc/exim.conf
extract_addresses_remove_arguments =false
  which will allow exim to sent email.
  
  Install Git from Source
# ---> Install the pre-requisite files for Git compilation:yum install zlib-devel perl-CPAN gettext curl-devel expat-devel gettext-devel openssl-devel## ---> Download andextract it:mkdir /tmp/git && cd /tmp/gitcurl --progress https://www.kernel.org/pub/software/scm/git/git-2.0.0.tar.gz | tar xzcd git-2.0.0/./configuremakemake prefix=/usr/localinstall#Make sure Git is in your $PATH:which git
  Reboot your system to make sure the installation take effect.      Note:      When editing     config/gitlab.yml      ,     change the git bin_path to /usr/local/bin/git
  2.Install Ruby
  Remove completely the old Ruby      1.8 packageif present. GitLab only supports the Ruby 2.0+ release series:
#remove rubyyum remove ruby#Remove any other Ruby build if it is<b>still present</b>:which rubycd<your-ruby-source-path>makeuninstall
  Time to install ruby and Gem
mkdir /tmp/ruby && cd /tmp/rubycurl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz | tar xzcd ruby-2.1.2./configure--disable-install-rdocmakemake prefix=/usr/local install#Install the Bundler Gemgem install bundler--no-doc
  After the installation is complete is recommended to reboot the system to make sure the $path/installation take effect
  After reboot :
which ruby #-># /usr/local/bin/rubyruby -v# -> ruby 2.0.0p481 (2014-02-24 revision 45167) [x86_64-linux]#make sure the ruby version is 2&#43; ..the gitlabonly support ruby version above 2.0&#43;
  
  3.System Users
  Create a    git    user for Gitlab:  
adduser --system --shell /bin/bash --comment 'GitLab' --create-home --home-dir /home/git/ git
  
  Important : Important: In order to include /usr/local/bin to git user’s PATH, one way is to edit the sudoers file. As root run:
  
# type an enter :visudo#search for the line and and append <b>/usr/local/bin</b> like so:Defaults secure_path =/sbin:/bin:/usr/sbin:/usr/bin#likethis ----->Defaults secure_path =/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
  save and exit
  4.Database
  Install mysql and enable the mysqld service to start on boot:    Make sure you install Mysql version 5.5.14 (optional)
mysql --version
#install the mysqlyum install -y mysql-server mysql-devel#make sure mysql servicestarton bootchkconfig mysqldon#start itservice mysqldstart#secure you mysql installationmysql_secure_installation
  Login to MySQL (type the database root password) , like below
mysql -u root -p#Create auserfor GitLab or any name you like(REMEMBER THE NAME) (change $YOUR_PASSWORD_HEREin the command belowto areal password you #pick):CREATEUSER'git'@'localhost' IDENTIFIEDBY'$YOUR_PASSWORD_HERE';
  Ensure you can use the InnoDB engine which is necessary to support long indexes..
# If this fails, check your MySQL config files (e.g./etc/mysql/*.cnf, /etc/mysql/conf.d/*) #for the setting &quot;innodb = off&quot;SET storage_engine=INNODB;
  Create the GitLab production database:
CREATE DATABASE IFNOTEXISTS `gitlabhq_production`DEFAULT CHARACTER SET `utf8`COLLATE`utf8_unicode_ci`;
  Grant the GitLab user necessary permissions on the table:
# VERY IMPORTANT :Make sure the db name and the user name is correct !!GRANTSELECT,LOCK TABLES, INSERT, UPDATE, DELETE,CREATE,DROP, INDEX, ALTER ON `gitlabhq_production`.*TO'git'@'localhost';#Quit the database session:\q
  Now test the connection with the newly created database with new user
sudo -u git -H mysql -u git -p -D gitlabhq_production#if all ok#exit\q
  5.Gitlab
# We'll install GitLab into home directory of the user &quot;git&quot;#git user u was created before this in(step 6)#ifu missed means go back and done the thing before you continue herecd /home/git
  Clone the Source
# Clone GitLab repositorysudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b7-1-stable gitlab#Note: Youcan change7-1-stable to master if you want the bleeding edge version, but do so with caution!
  !Important
  Now time to configure Gitlab(Important steps & make sure u done it correctly)
cd /home/git/gitlab# Copy the example GitLab config####sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml#<strong>Important</strong># Make suretochange &quot;localhost&quot; to the fully-qualifieddomain name of your# host serving GitLabwhere necessary## If you wantto use https make sure that youset `https` to `true`. See #using-httpsfor all necessary details.## If you installed Gitfrom source, change the git bin_pathto /usr/local/bin/gitsudo -u git -H editor config/gitlab.yml# Make sure GitLab canwriteto the log/ and tmp/ directorieschown -R git {log,tmp}chmod -R u&#43;rwX {log,tmp}#Create directory for satellitessudo -u git -H mkdir /home/git/gitlab-satelliteschmod u&#43;rwx,g&#43;rx,o-rwx /home/git/gitlab-satellites# Make sure GitLab canwriteto the tmp/pids/ and tmp/sockets/ directorieschmod -R u&#43;rwX tmp/{pids,sockets}# Make sure GitLab canwriteto the public/uploads/ directorychmod -R u&#43;rwXpublic/uploads# Copy the example Unicorn configsudo -u git -H cp config/unicorn.rb.example config/unicorn.rb# Enable cluster mode if you expectto have a highload instance# Ex. change amountof workersto 3 for 2GB RAM serversudo -u git -H editor config/unicorn.rb# Copy the example Rack attack configsudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb# Configure Gitglobal settings for gituser, useful when editing via web# Edituser.email accordingto whatis set in config/gitlab.ymlsudo -u git -H git config --globaluser.name&quot;GitLab&quot;sudo -u git -H git config --globaluser.email&quot;gitlab@localhost&quot;sudo -u git -H git config --global core.autocrlfinput
  Important Note:    Make sure to edit both gitlab.yml and unicorn.rb to match your setup.
  Configure GitLab DB settings
# MySQL only:sudo -u git cp config/database.yml.mysql config/database.yml# MySQL remoteonly:#Update username/passwordin config/database.yml.# Youonly needto adapt the production settings (first part).# If you followed the database guidethen pleasedo as follows:# Change 'secure password' with the value you have given to $password# You can keep thedouble quotes around the passwordsudo -u git -H editor config/database.yml# MySQL:# Make config/database.yml readableto gitonlysudo -u git -H chmod o-rwx config/database.yml
  Install Gems
  Note:      As of      bundler 1.5.2      , you can invoke bundle install -jN (where N the number of your processor cores) and enjoy the parallel gems installation with measurable difference in completion time (~60% faster).Check the number of your cores with nproc. For more information check this      post      . First make sure you have bundler >= 1.5.2 (run bundle -v).   
  The installation Process
cd /home/git/gitlab# For MySQL (note, the option says &quot;without ... postgres&quot;)sudo -u git -H bundle install --deployment --without development test postgres aws
以上这一步,我在安装的时候,会出现安装某些包失败的情况,这时候可以找到包所在的地址,手动编译下包,看看是不是缺少什么库。
  Install GitLab shell
  GitLab Shell is an ssh access and repository management software developed specially for GitLab.
# Go to the Gitlab installation folder:cd /home/git/gitlab# Run the installation task for gitlab-shell (replace`REDIS_URL` if needed):sudo -u git -H bundleexec rake gitlab:shell:install[v1.9.6] REDIS_URL=redis://localhost:6379 RAILS_ENV=production#Bydefault, the gitlab-shell configis generatedfrom your main gitlab config.## Note:Whenusing GitLab with HTTPS please change the following:# - Provide pathsto the certificates under `ca_file`and `ca_path options.# - The `gitlab_url` option must point to the https endpoint of GitLab.# - In case you are using self signed certificate set `self_signed_cert`to `true`.# See #using-https for all necessary details.## You can review (and modify) it as follows:sudo -u git -H editor /home/git/gitlab-shell/config.yml# Ensure the correct SELinux contexts are set#Read http://wiki.centos.org/HowTos/Network/SecuringSSHrestorecon -Rv /home/git/.ssh
  Initialize Database and Activate Advanced Features
sudo -u git -H bundleexec rake gitlab:setup RAILS_ENV=production#Type yestocreate the database.When done you see Administrator account created
  Install Init Script
  Download the init script (will be /etc/init.d/gitlab):
#download the filewget -O /etc/init.d/gitlab https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/init/sysvinit/centos/gitlab-unicorn#giveexecutepermissionchmod &#43;x /etc/init.d/gitlabchkconfig --add gitlab#Make GitLabstarton boot:chkconfig gitlabon#Set up logrotatecp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
  Check Application Status
#Check if GitLab and its environment are configured correctly:sudo -u git -H bundleexec rake gitlab:env:info RAILS_ENV=production#Compile assetssudo-u git -H bundleexec rake assets:precompile RAILS_ENV=production#Start your GitLab instanceservice gitlabstart
  6. Configure the web server(Apache)
  We will configure apache with module mod_proxy which is loaded by default when installing apache and mod_ssl which will provide ssl support:
yum -y install httpd mod_sslchkconfig httpd onwget -O /etc/httpd/conf.d/gitlab.conf https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/web-server/apache/gitlab-ssl.confmv /etc/httpd/conf.d/ssl.conf{,.bak}mkdir/var/log/httpd/logs/
  Open /etc/httpd/conf.d/gitlab.conf with your editor and replace git.example.org with your FQDN. Also make sure the path to your certificates is valid.
  Add LoadModule ssl_module /etc/httpd/modules/mod_ssl.so in /etc/httpd/conf/httpd.conf.
  In    /etc/httpd/conf/httpd.conf       Change the DocumentRoot to /home/git/gitlab/public/
  AND
  in Directory –> /home/git/gitlab/public
  Finally, start apache:
service httpd start
  Please take note that, the above configuration is a http setup rather than a ssl setup. the configuration file for ssl is a little buggy but can be found on https://github.com/gitlabhq/gitlab-recipes/tree/master/web-server/apache
  Done!
  Double-check Application Status    To make sure you didn’t miss anything run a more thorough check with:
cd /home/git/gitlabsudo -u git -H bundleexec rake gitlab:check RAILS_ENV=production
  Initial Login
  Visit YOUR_SERVER:8080 in your web browser for your first GitLab login. The setup has created an admin account for you. You can use it to log in:
root5iveL!fe
  Important Note: Please go over to your profile page and immediately change the password, so nobody can access your GitLab by using this login information later on.
  Potential Errors
  In case the when start the httpd(apache service),it may throw exception (SSL ERROR) or anything regarding Self-Signed Certificates(ssl) – > it because you may miss the or not generate the Self-Signed Certificates. Here the solution for that
#make sure you installed the mod_ssl yum install mod_ssl#Next, we need tocreate a new directorywhere we will store the server key and certificatemkdir /etc/httpd/ssl#When we request a new certificate, we can specify how long the certificate should remain #validby changing the365 to the number of days we prefer.As it stands this certificate #will expire after oneyear.openssl req -x509 -nodes -days365 -newkey rsa:2048 -keyout /etc/httpd/ssl/apache.key -out /etc/httpd/ssl/apache.crt
  With this command, we will be both creating the self-signed SSL certificate and the server key that protects it, and placing both of them into the new directory.
  This command will prompt terminal to display a lists of fields that need to be filled in.
  The most important line is “Common Name”. Enter your official domain name here or, if you don’t have one yet, your site’s IP address.
You are about to be asked to enter information that will be incorporatedinto your certificate request.What you are about to enter is what is called aDistinguishedName or a DN.There are quite a few fields but you can leave some blankFor some fields there will be a default value,If you enter'.', the fieldwill be left blank.-----CountryName (2 letter code) [AU]:USStateorProvince Name (full name) [Some-State]:NewYorkLocalityName (eg, city) []:NYCOrganizationName (eg, company) [InternetWidgitsPty Ltd]:AwesomeIncOrganizationalUnitName (eg, section) []:Dept ofMerrimentCommonName (e.g. server FQDNor YOUR name) []:example.comEmailAddress []:webmaster@awesomeinc.com
  Now open and edit the file    /etc/httpd/conf.d/gitlab.conf
  Under section
  Uncomment the DocumentRoot and ServerName line and replace example.com with your DNS approved domain name or server IP address (it should be the same as the common name on the certificate):
ServerName example.com:443
  Find the following three lines, and make sure that they match the extensions below:
SSLEngine onSSLCertificateFile /etc/httpd/ssl/apache.crtSSLCertificateKeyFile /etc/httpd/ssl/apache.key
  Now just Restart Apache –>    service httpd restart and run
  Very Important    **CHECK LIST**  

        in /home/git/gitlab/config/unicorn.rb change the listen to “YOUR_SERVER_IP_ADDR:8080″

        change to ur ipaddr and server name in /etc/httpd/conf.d/gitlab.conf

  
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-126936-1-1.html 上篇帖子: centos上如何yum安装git? 下篇帖子: CentOS6.2下搭建git
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表