Introduction to gitlab

Installation of gitlab:

Password for first login:


Enter: root/5iveL!fe Login!

——————————————————————————————————————————————————————

 

One-click installation
------------------------------------


1. Install configuration dependencies

yum install curl openssh-server openssh-clients postfix cronie wget lokkit -y

service postfix start Mail service activation


lokkit -s http -s ssh #Configure iptables to open http and ssh ports


iptables -L View iptables rules

ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22

ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80
------------------------------ ----------------------------------------------
Download the RPM package:

wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6/gitlab-ce-8.9.9-ce.0.el6.x86_64.rpm Tsinghua University Open Source Software Mirror Site


rpm -ivh gitlab-ce-8.9.9-ce.0.el6.x86_64.rpm


Start GitLab

gitlab-ctl reconfigure
---------------------------------------------- --------------------------------
Another way: (official documentation)

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash

yum install gitlab-ee

gitlab-ctl reconfigure
-------------------------------------------------------------------------------
http://ip

root/5iveL!fe

Reboot:

gitlab-ctl restart


-----------------------------------------------------

502 error

caused by insufficient memory


dd if=/dev/zero of=/var/swap bs=1024 count=2048000


mkswap / var / swap


swapon /var/swap activates virtual memory


vim /etc/fstab

/var/swap swap swap defaults 0 0

mount -a


------------------------------------------------------------

Modify the port:


vim /etc/gitlab/gitlab.rb

## Advanced settings
unicorn['listen'] = '127.0.0.1'
# unicorn['port'] = 8080
unicorn['port'] = 8082


# nginx['ssl_dhparam'] = nil # Path to dhparams.pem, eg. /etc/gitlab/ssl/dhparams.pem
nginx['listen_addresses'] = ['*']
nginx['listen_port'] = 82 # override only if you use a reverse proxy: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/nginx.md#setting-the-nginx-listen-port

vim /var/opt/gitlab/gitlab-rails/etc/unicorn.rb

listen "127.0.0.1:8082", :tcp_nopush => true
listen "/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket", :backlog => 1024

vim /var/opt/gitlab/nginx/conf/gitlab-http.conf


server {
# listen *:80;
listen *:82;


server_name localhost;
server_tokens off;

gitlab-ctl restart restart gitlab


Modify nginx as a proxy:

vim /usr/local/nginx/conf/conf.d/gitlab.conf

server {
listen 80;
server_name gitlab.123.123.cn;

location / {
#rewrite ^(.*) http://127.0.0.1:8082;
proxy_pass http://127.0.0.1:8082;
}
}

Modify gitlab-shell

vim /var/opt/gitlab/gitlab-shell/config.yml

# Url to gitlab instance. Used for api calls. Should end with a slash.
#gitlab_url: "http://127.0.0.1:9090"
gitlab_url: "http://127.0.0.1:82"

gitlab-ctl restart restarts the service

---------------------------------------------------------------------------

Create private key and public key:

ssh-keygen -t rsa -C "[email protected]" Generate private key and public key

git config --global user.name "tom" 设置username

git config --global user.email "alice" set user's email address

Upload public key:

cat id_rsa.pub Copy the public key to the corresponding location on the web page

Create new project:


git clone git@localhost:root/project.git clones a project

cd project/

touch README.md

git add README.md

git commit -m "add README"

git push -u origin master

 ==========================================================================================

 

gitlab backup

 

gitlab backup

1. Must be executed by root user


vim /opt/gitlab-6.6.5-0/apps/gitlab/htdocs/config/gitlab.yml

backup:
path: "/tmp/backups" # Relative paths are relative to Rails.root (default: tmp/backups/) 路径可以自定义
keep_time: 604800 # default: 0 (forever) (in seconds)

cd /opt/gitlab-6.6.5-0/apps/gitlab/htdocs/

/opt/gitlab-6.6.5-0/ruby/bin/bundle exec bin/rake gitlab:backup:create RAILS_ENV=production


ll /tmp/backups

-rw-r--r--. 1 root root 40960 Jun 1 16:10 1496304653_gitlab_backup.tar

success

gitlab data recovery

cd /opt/gitlab-6.6.5-0/apps/gitlab/htdocs/


/opt/gitlab-6.6.5-0/ruby/bin/bundle exec bin/rake gitlab:backup:restore RAILS_ENV=production


If there are multiple backup files, specify which file to restore after RAILS_ENV=production BACKUP=1496304653_gitlab_backup.tar

 

backup script

#!/bin/bash

#if [ `id -u` -ne 0 ];then
# echo "this backup script must be exec as root."
# exit
#fi
#date
PATH="/opt/gitlab-6.6.5-0/apps/gitlabci/gitlabci-runner/bin:/opt/gitlab-6.6.5-0/apps/gitlab/gitlab-shell/bin:/opt/gitlab-6.6.5-0/redis/bin:/opt/gitlab-6.6.5-0/sqlite/bin:/opt/gitlab-6.6.5-0/python/bin:/opt/gitlab-6.6.5-0/perl/bin:/opt/gitlab-6.6.5-0/git/bin:/opt/gitlab-6.6.5-0/ruby/bin:/opt/gitlab-6.6.5-0/mysql/bin:/opt/gitlab-6.6.5-0/apache2/bin:/opt/gitlab-6.6.5-0/common/bin:$PATH"

echo "backup gitlab to local storage begin.. "

cd /opt/gitlab-6.6.5-0/apps/gitlab/htdocs

/opt/gitlab-6.6.5-0/ruby/bin/bundle exec bin/rake gitlab:backup:create RAILS_ENV=production

echo "rsync -avzP --delete /tmp/backups 192.168.1.100:/gitlab/back"
rsync -avzP --delete /tmp/backups 192.168.1.100:/gitlab/back

date
echo "this job is end."

=======================================================================================

git upload files and code

Create private key and public key:

ssh-keygen -t rsa -C "[email protected]" Generate private key and public key

Upload public key:

cat /root/.ssh/id_rsa.pub Copy the public key to the corresponding location on the web page

git config --global user.name "tom" 设置username

git config --global user.email "alice" set user's email address

Create new project:

git clone git@localhost:root/project.git clones a project

cd project/

touch README.md

git add README.md

git commit -m "add README"

git push -u origin master


git init creates a manageable repository

git clone ssh:[email protected]:good/test.git clone online repository

git status to see if there are files to submit

git add -A or git add . add files to the staging area -A and . are all

git status View status

git commit -m "first push" commits files to the repository "" is a comment

git log View log

git remote add origin [[email protected]:good/test.git] Fill in the url address of the project. This can be pushed to the remote master branch by default

git push -u origin master pushes the local repository branch to the meta repository (remote)

git pull origin master to receive data (multi-branch Pull cannot be applied)


git branch View current branch

git checkout -b dev dev is the branch name Create and switch to the branch

git checkout dev switch branch

git branch dev to create a branch

git branch -d dev delete branch

git merge dev merge branch

====================================================================================

A key installation

chmod +x bitnami-gitlab-6.6.5-0-linux-x64-installer.run

./ bitnami-gitlab-6.6.5-0-linux-x64-installer.run


GitLab CI [Y/n] :Y

Is the selection above correct? [Y/n]: Y

Select a folder [/opt/gitlab-6.6.5-0] installation directory (default in /opt/gitlab-6.6.5-0)

Email Address [[email protected]]: [email protected] email address

Login [user]: tom login name

Password: The default is 8 characters or more

Please confirm your password :

Domain [127.0.0.1]: 192.168.1.131 domain name address

Do you want to configure mail support? [y/N]: N Whether to support mail

Default email provider:

[1] GMail Google Mail

[2] Custom

Please choose an option [1] : 2

Configure SMTP Settings

This data is stored in the application configuration files and may be visible to
others. For this reason, it is recommended that you do not use your personal
account credentials.

Username []: zhangxiandong mailbox name

Password : Email password

Re-enter : repeat input

SMTP Host []: [email protected]

SMTP Port []: 25

Secure connection

[1] None
[2] SSL
[3] TLS

Please choose an option [3] : 1

Setup is now ready to begin installing Bitnami Gitlab Stack on your computer.

Do you want to continue? [Y/n]: Y

Please wait while Setup installs Bitnami Gitlab Stack on your computer.

Installing
0% ______________ 50% ______________ 100%
#########################################

----------------------------------------------------------------------------
Setup has finished installing Bitnami Gitlab Stack on your computer.

Info: To access the Bitnami Gitlab Stack, go to
http://192.168.1.131:80 from your browser.
Press [Enter] to continue :

The command to start the service:

cd /opt/gitlab-6.6.5-0/

./ctlscript.sh

It is also possible to restart and shut down individual services

./ctlscript.sh mysql or redis
=========================================== =====================================================
Port modification file for apache mysql and redis

Modify the default port of httpd

vim /opt/gitlab-6.6.5-0/apache2/conf/httpd.conf apache's configuration file

Listen 8080

ServerName localhost:8080

vim /opt/gitlab-6.6.5-0/apache2/conf/bitnami/bitnami.conf

NameVirtualHost *:8080

<VirtualHost _default_:8080>

vim /opt/gitlab-6.6.5-0/apache2/scripts/ctl.sh

echo "$0 $ARG: httpd started at port 8080"

vim /opt/gitlab-6.6.5-0/apache2/conf/extra/httpd-vhosts.conf

<VirtualHost *:8080>

<VirtualHost *:8080>

vim /opt/gitlab-6.6.5-0/apps/gitlabci/conf/httpd-vhosts.conf

<VirtualHost *:8080>

vim /opt/gitlab-6.6.5-0/redis/etc/redis.conf redis configuration file

mysql default port modification
vim /opt/gitlab-6.6.5-0/mysql/my.cnf mysqld configuration file

port=3306

vim /opt/gitlab-6.6.5-0/mysql/scripts/ctl.sh Modify the port of mysql

--port=3306

echo "$0 $ARG: mysql started at port 3306"

vim /opt/gitlab-6.6.5-0/apps/gitlabci/htdocs/config/database.yml

port: 3306 Modify the port number


Modification of the default port of redis

vim /opt/gitlab-6.6.5-0/redis/etc/redis.conf

port 6379

vim /opt/gitlab-6.6.5-0/redis/scripts/ctl.sh

REDIS_PORT=6379

REDIS_PORT=6379

===================================================== =================================
vim /opt/gitlab-6.6.5-0/apps/gitlab/htdocs/ config/gitlab.yml configuration of mail sending


# Email address used in the "From" field in mails sent by GitLab

email_from: [email protected]

# Email address of your support contact (default: same as email_from)

support_email: [email protected]

## GitLab settings

gitlab:
## Web server settings (note: host is the FQDN, do not include http://)

host: 192.168.1.132 Change to domain name for example: pepstack.com

port: 80

https: false

# Uncomment and customize the last line to run in a non-root path
# WARNING: We recommend creating a FQDN to host GitLab in a root path instead of this.
# Note that four settings need to be changed for this to work.
# 1) In your application.rb file: config.relative_url_root = "/gitlab"
# 2) In your gitlab.yml file: relative_url_root: /gitlab
# 3) In your unicorn.rb: ENV['RAILS_RELATIVE_URL_ROOT'] = "/gitlab"
# 4) In ../gitlab-shell/config.yml: gitlab_url: "http://127.0.0.1/gitlab"
# To update the path, run: sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production
#

relative_url_root: /gitlab

===================================================== =================================
vim /opt/gitlab-6.6.5-0/apps/gitlab/htdocs/ config/environments/production.rb configuration for sending emails

cp /opt/gitlab-6.6.5-0/apps/gitlab/htdocs/config/initializers/{smtp_settings.rb.sample,smtp_settings.rb}

vim /opt/gitlab-6.6.5-0/apps/gitlab/htdocs/config/initializers/smtp_settings.rb configuration file for mail


=====================================================================================================

 

vim /opt/gitlab-6.6.5-0/apps/gitlab/conf/httpd-app.conf is used behind nginx

<Directory "/opt/gitlab-7.8.1-0/apps/gitlab/htdocs/public">
Options -MultiViews
AllowOverride All
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.3>
Require all granted
</IfVersion>

SetEnv RAILS_RELATIVE_URL_ROOT "/gitlab"

PassengerEnabled on
PassengerAppRoot "/opt/gitlab-7.8.1-0/apps/gitlab/htdocs/"
<IfModule pagespeed_module>
ModPagespeedDisallow "*"
</IfModule>
PassengerUser git
PassengerGroup git
SetEnv MAGIC "/opt/gitlab-7.8.1-0/ruby/lib/ruby/gems/2.0.0/gems/charlock_holmes-0.6.9.4/ext/charlock_holmes/src/file-5.08/magic/magic.mgc"
SetEnv PATH "/opt/gitlab-7.8.1-0/python/bin:${PATH}"


</Directory>
PassengerPreStart http://127.0.0.1:80/gitlab

the difference lies in:

SetEnv RAILS_RELATIVE_URL_ROOT "/gitlab"
PassengerPreStart http://127.0.0.1:80/gitlab

vim /opt/gitlab-6.6.5-0/apps/gitlab/gitlab-shell/config.yml


gitlab_url: "http://192.168.1.132:80/" changed to http://pepstack.com/ changed to domain name, consistent with the host in gitlab.yml above

vim /opt/gitlab-6.6.5-0/apps/gitlabci/htdocs/config/database.yml defines the password and username of the database

production:
adapter: mysql2
encoding: utf8
reconnect: false
database: bitnami_gitlabci
pool: 5
username: bitnami
password: "1a36ddf4bb"
# host: localhost
socket: /opt/gitlab-6.6.5-0/mysql/tmp/mysql.sock
port: 3306
# socket: /tmp/mysql.sock

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324648631&siteId=291194637