Spring Security的會話管理">Spring Security的會話管理
998
2025-04-04
環(huán)境
[root@iZ2851te7e5Z ~]# lsb_release -a LSB Version: :core-4.1-amd64:core-4.1-noarch Distributor ID: CentOS Description: CentOS Linux release 7.1.1503 (Core) Release: 7.1.1503 Codename: Core
1
2
3
4
5
6
7
8
服務(wù)器安裝了
PHP7
Nginx,占用80端口
Mysql
安裝
安裝采用官網(wǎng)提供的安裝方法.
進入頁面 https://about.gitlab.com/downloads/
選擇 CentOS 7
硬件要求
GitLab對硬件的要求不是很高,很顯然,越好的硬件,越能支撐起更多的項目的和用戶.
系統(tǒng)要求
支持的類UNIX系統(tǒng)
Ubuntu
Debian
CentOS
Red Hat Enterprise Linux (please use the CentOS packages and instructions)
Scientific Linux (please use the CentOS packages and instructions)
Oracle Linux (please use the CentOS packages and instructions)
不支持的類UNIX系統(tǒng)
OS X
Arch Linux
Fedora
Gentoo
FreeBSD
不是類UNIX的系統(tǒng)
比如Windows,并不支持.
安裝和配置必要的依賴關(guān)系
如果你安裝postfix發(fā)送郵件,請選擇“網(wǎng)站設(shè)置”中。而不是使用后綴也可以使用sendmail配置自定義SMTP服務(wù)器配置為SMTP服務(wù)器。
sudo yum install curl policycoreutils openssh-server openssh-clients sudo systemctl enable sshd sudo systemctl start sshd sudo yum install postfix sudo systemctl enable postfix sudo systemctl start postfix sudo firewall-cmd --permanent --add-service=http sudo systemctl reload firewalld
1
2
3
4
5
6
7
8
postfix 服務(wù)啟動失敗
/usr/sbin/postconf: fatal: parameter inet_interfaces: no local interface found for ::1
1
修改配置文件 vi /etc/postfix/main.cf
修改的部分為
inet_interfaces = 127.0.0.1 #只能接受內(nèi)部郵件,其它郵件不接受 inet_protocols = all
1
2
3
啟動服務(wù) sudo systemctl start postfix,成功.
安裝firewalld
yum install firewalld
systemctl unmask firewalld
添加GitLab安裝包到服務(wù)器
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
添加國內(nèi)的鏡像源
執(zhí)行上面的命令,會一直 time out ,所以我們要換成國內(nèi)的源.
以下操作針對CentOS 7 ,其他的請戳 https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/
vim /etc/yum.repos.d/gitlab-ce.repo
[gitlab-ce] name=gitlab-ce baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7 repo_gpgcheck=0 gpgcheck=0 enabled=1 gpgkey=https://packages.gitlab.com/gpg.key
1
2
3
4
5
6
7
注意,如果對應(yīng)配置文件下有文件gitlab_gitlab-ce.repo,重命名一下,不然會默認加載這個導(dǎo)致上面的文件不起作用.
查看目前的yum進程,并殺死
ps -a PID TTY TIME CMD 18781 pts/0 00:00:00 sudo 18783 pts/0 00:00:00 bash 18796 pts/0 00:00:00 yum 18855 pts/0 00:00:00 sudo 18856 pts/0 00:00:00 yum 18871 pts/0 00:00:00 ps kill -9 18796 kill -9 18856
1
2
3
4
5
6
7
8
9
10
11
12
sudo yum makecache sudo yum install gitlab-ce
1
2
上面執(zhí)行完了,是這樣的展示結(jié)果
sudo gitlab-ctl reconfigure gitlab: GitLab should be reachable at http://iZ2851te7e5Z gitlab: Otherwise configure GitLab for your system by editing /etc/gitlab/gitlab.rb file gitlab: And running reconfigure again. gitlab: gitlab: For a comprehensive list of configuration options please see the Omnibus GitLab readme gitlab: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md gitlab: It looks like GitLab has not been configured yet; skipping the upgrade script. 驗證中 : gitlab-ce-8.7.6-ce.0.el7.x86_64 1/1 已安裝: gitlab-ce.x86_64 0:8.7.6-ce.0.el7 完畢!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
配置和開始使用GitLab
sudo gitlab-ctl reconfigure
接下來會自動配置文件權(quán)限,安裝數(shù)據(jù)庫….
提示!安裝的時間會很長!!!
根據(jù)我們服務(wù)器監(jiān)控記錄,配置過程花了5個小時!
修改配置文件 /etc/gitlab/gitlab.rb
目前的狀態(tài)是完成了安裝包的安裝,但是還沒有啟用配置文件,所以依賴還都沒有裝。
所以非常不建議直接運行sudo gitlab-ctl reconfigure,
不能再踩一次坑!QAQ
基本我們要調(diào)的東西都在/etc/gitlab/gitlab.rb里面,所以這個文件一定要仔細看好。
修改連接數(shù)據(jù)庫為Mysql
因為我們本機已經(jīng)用了LNMP做了環(huán)境,所以可以直接采用Mysql作為我們的數(shù)據(jù)庫,而不用postgresql,減少服務(wù)器的負擔(dān)。
企業(yè)版才支持使用mysql
QAQ
# Disable the built-in Postgres postgresql['enable'] = false # Fill in the values for database.yml gitlab_rails['db_adapter'] = 'mysql2' gitlab_rails['db_encoding'] = 'utf8' gitlab_rails['db_host'] = '127.0.0.1' gitlab_rails['db_port'] = '3306' gitlab_rails['db_username'] = 'USERNAME' gitlab_rails['db_password'] = 'PASSWORD'
1
2
3
4
5
6
7
8
9
10
采用本機自帶的nginx
################ # GitLab Nginx # ################ ## see: https://gitlab.com/gitlab-org/omnibus-gitlab/tree/master/doc/settings/nginx.md nginx['enable'] = false nginx['client_max_body_size'] = '250m' nginx['redirect_http_to_https'] = false #nginx['redirect_http_to_https_port'] = 80 # nginx['ssl_client_certificate'] = "/etc/gitlab/ssl/ca.crt" # Most root CA's are included by default # nginx['ssl_certificate'] = "/etc/gitlab/ssl/#{node['fqdn']}.crt" # nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/#{node['fqdn']}.key" # nginx['ssl_ciphers'] = "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256" # nginx['ssl_prefer_server_ciphers'] = "on" # nginx['ssl_protocols'] = "TLSv1 TLSv1.1 TLSv1.2" # recommended by https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html & https://cipherli.st/ # nginx['ssl_session_cache'] = "builtin:1000 shared:SSL:10m" # recommended in http://nginx.org/en/docs/http/ngx_http_ssl_module.html # nginx['ssl_session_timeout'] = "5m" # default according to http://nginx.org/en/docs/http/ngx_http_ssl_module.html # nginx['ssl_dhparam'] = nil # Path to dhparams.pem, eg. /etc/gitlab/ssl/dhparams.pem nginx['listen_addresses'] = ["0.0.0.0", "[::]"] nginx['listen_port'] = 80 # 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 # nginx['listen_https'] = nil # override only if your reverse proxy internally communicates over HTTP: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/nginx.md#supporting-proxied-ssl # nginx['custom_gitlab_server_config'] = "location ^~ /foo-namespace/bar-project/raw/ {\n deny all;\n}\n" # nginx['custom_nginx_config'] = "include /etc/nginx/conf.d/example.conf;" # nginx['proxy_read_timeout'] = 300 # nginx['proxy_connect_timeout'] = 300 # nginx['proxy_set_headers'] = { # "Host" => "$http_host", # "X-Real-IP" => "$remote_addr", # "X-Forwarded-For" => "$proxy_add_x_forwarded_for", # "X-Forwarded-Proto" => "https", # "X-Forwarded-Ssl" => "on" # } # nginx['proxy_cache_path'] = 'proxy_cache keys_zone=gitlab:10m max_size=1g levels=1:2' # nginx['proxy_cache'] = 'gitlab' # nginx['http2_enabled'] = true # nginx['real_ip_trusted_addresses'] = [] # nginx['real_ip_header'] = # nginx['real_ip_recursive'] = nil nginx['custom_nginx_config'] = "include /etc/nginx/conf.d/*.conf;" # If you need to add custom settings into the NGINX config, for example to include existing server blocks, you can use the following setting. ## Advanced settings nginx['dir'] = "/usr/local/nginx" nginx['log_directory'] = "/usr/local/nginx" nginx['worker_processes'] = 4 nginx['worker_connections'] = 10240 nginx['log_format'] = '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"' # nginx['sendfile'] = 'on' # nginx['tcp_nopush'] = 'on' # nginx['tcp_nodelay'] = 'on' nginx['gzip'] = "on" nginx['gzip_http_version'] = "1.0" nginx['gzip_comp_level'] = "2" # nginx['gzip_proxied'] = "any" nginx['gzip_types'] = [ "text/plain", "text/css", "application/x-javascript", "text/xml", "application/xml", "application/xml+rss", "text/javascript", "application/json" ] nginx['keepalive_timeout'] = 65 nginx['cache_max_size'] = '5000m'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
創(chuàng)建vhost下的配置文件,指向GitLab文件夾
upstream gitlab-workhorse { server unix://var/opt/gitlab/gitlab-workhorse/socket fail_timeout=0; } server { listen *:80; server_name git.example.com; server_tokens off; root /opt/gitlab/embedded/service/gitlab-rails/public; client_max_body_size 250m; access_log /var/log/gitlab/nginx/gitlab_access.log; error_log /var/log/gitlab/nginx/gitlab_error.log; # Ensure Passenger uses the bundled Ruby version passenger_ruby /opt/gitlab/embedded/bin/ruby; # Correct the $PATH variable to included packaged executables passenger_env_var PATH "/opt/gitlab/bin:/opt/gitlab/embedded/bin:/usr/local/bin:/usr/bin:/bin"; # Make sure Passenger runs as the correct user and group to # prevent permission issues passenger_user git; passenger_group git; # Enable Passenger & keep at least one instance running at all times passenger_enabled on; passenger_min_instances 1; location ~ ^/[\w\.-]+/[\w\.-]+/(info/refs|git-upload-pack|git-receive-pack)$ { # 'Error' 418 is a hack to re-use the @gitlab-workhorse block error_page 418 = @gitlab-workhorse; return 418; } location ~ ^/[\w\.-]+/[\w\.-]+/repository/archive { # 'Error' 418 is a hack to re-use the @gitlab-workhorse block error_page 418 = @gitlab-workhorse; return 418; } location ~ ^/api/v3/projects/.*/repository/archive { # 'Error' 418 is a hack to re-use the @gitlab-workhorse block error_page 418 = @gitlab-workhorse; return 418; } # Build artifacts should be submitted to this location location ~ ^/[\w\.-]+/[\w\.-]+/builds/download { client_max_body_size 0; # 'Error' 418 is a hack to re-use the @gitlab-workhorse block error_page 418 = @gitlab-workhorse; return 418; } # Build artifacts should be submitted to this location location ~ /ci/api/v1/builds/[0-9]+/artifacts { client_max_body_size 0; # 'Error' 418 is a hack to re-use the @gitlab-workhorse block error_page 418 = @gitlab-workhorse; return 418; } location @gitlab-workhorse { ## https://github.com/gitlabhq/gitlabhq/issues/694 ## Some requests take more than 30 seconds. proxy_read_timeout 3600; proxy_connect_timeout 300; proxy_redirect off; # Do not buffer Git HTTP responses proxy_buffering off; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://gitlab-workhorse; ## The following settings only work with NGINX 1.7.11 or newer # ## Pass chunked request bodies to gitlab-workhorse as-is # proxy_request_buffering off; # proxy_http_version 1.1; } ## Enable gzip compression as per rails guide: ## http://guides.rubyonrails.org/asset_pipeline.html#gzip-compression ## WARNING: If you are using relative urls remove the block below ## See config/application.rb under "Relative url support" for the list of ## other files that need to be changed for relative url support location ~ ^/(assets)/ { root /opt/gitlab/embedded/service/gitlab-rails/public; gzip_static on; # to serve pre-gzipped version expires max; add_header Cache-Control public; } error_page 502 /502.html; }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
使用
查看狀態(tài)
上面的命令是通過gitlab-ctl安裝的,那么通過gitlab-ctl命令一樣也能做別事情~
gitlab-ctl
I don't know that command. /opt/gitlab/embedded/bin/omnibus-ctl: command (subcommand) deploy-page Put up the deploy page remove-accounts Delete *all* users and groups used by this package upgrade Run migrations after a package upgrade General Commands: cleanse Delete *all* gitlab data, and start from scratch. help Print this help message. reconfigure Reconfigure the application. show-config Show the configuration that would be generated by reconfigure. uninstall Kill all processes and uninstall the process supervisor (data will be preserved). Service Management Commands: graceful-kill Attempt a graceful stop, then SIGKILL the entire process group. hup Send the services a HUP. int Send the services an INT. kill Send the services a KILL. once Start the services if they are down. Do not restart them if they stop. restart Stop the services if they are running, then start them again. service-list List all the services (enabled services appear with a *.) start Start services if they are down, and restart them if they stop. status Show the status of all the services. stop Stop the services, and do not restart them. tail Watch the service logs of all enabled services. term Send the services a TERM.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
這樣就知道了我們的服務(wù)怎么使用了~
status 查看狀態(tài)
# gitlab-ctl status run: gitlab-workhorse: (pid 19751) 23124s; run: log: (pid 19750) 23124s run: logrotate: (pid 31160) 1078s; run: log: (pid 19765) 23091s run: nginx: (pid 32621) 0s; run: log: (pid 19755) 23119s run: postgresql: (pid 19584) 23964s; run: log: (pid 19583) 23964s run: redis: (pid 19501) 23975s; run: log: (pid 19500) 23975s run: sidekiq: (pid 19831) 22616s; run: log: (pid 19738) 23128s run: unicorn: (pid 19707) 23134s; run: log: (pid 19706) 23134s
1
2
3
4
5
6
7
8
tail 查看日志
這個命令查看我們的gitlab在運行過程中有沒有問題.
gitlab-ctl tail
后記
GitLab對服務(wù)器的要求比較高,文檔上說4核8G,我的1核512M的小服務(wù)器在安裝多次后卡死多次。我決定暫時先放放。。。以后再做這個。。。
QAQ
參考資料
https://about.gitlab.com/gitlab-com/
http://www.chhua.com/web-note4929
https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/
https://about.gitlab.com/downloads/
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/database.md#database-settings
CentOS Git GitHub
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實的內(nèi)容,請聯(lián)系我們jiasou666@gmail.com 處理,核實后本網(wǎng)站將在24小時內(nèi)刪除侵權(quán)內(nèi)容。
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實的內(nèi)容,請聯(lián)系我們jiasou666@gmail.com 處理,核實后本網(wǎng)站將在24小時內(nèi)刪除侵權(quán)內(nèi)容。