Centos6.5 安装gitlab 并使用自带的nginx
Centos6.5 安装gitlab 并使用自带的nginx
1.安装依赖
yum -y install policycoreutils openssh-server openssh-clients postfix policycoreutils-python
2.设置postfix开机启动
chkconfig postfix on && service postfix start
3.下载安装包
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6/gitlab-ce-11.4.4-ce.0.el6.x86_64.rpm
放入/opt中
4.安装
rpm -i gitlab-ce-11.4.4-ce.0.el6.x86_64.rpm
It looks like GitLab has not been configured yet; skipping the upgrade script.
*. *.
*** ***
***** *****
.****** *******
******** ********
,,,,,,,,,***********,,,,,,,,,
,,,,,,,,,,,*********,,,,,,,,,,,
.,,,,,,,,,,,*******,,,,,,,,,,,,
,,,,,,,,,*****,,,,,,,,,.
,,,,,,,****,,,,,,
.,,,***,,,,
,*,.
_______ __ __ __
/ ____(_) /_/ / ____ _/ /_
/ / __/ / __/ / / __ `/ __ \
/ /_/ / / /_/ /___/ /_/ / /_/ /
\____/_/\__/_____/\__,_/_.___/
Thank you for installing GitLab!
5.修改配置
vim /etc/gitlab/gitlab.rb
关闭自带的nginx
配置地址
external_url 'http://xxx.xxx.xxx.xxx'
禁用自带nginx
nginx['enable'] = false
6.nginx 增加虚拟主机配置
# gitlab socket 文件地址
upstream gitlab {
server unix:/var/opt/gitlab/gitlab-workhorse/socket;
}
server {
listen *:80;
server_name gitlab.demo.com; # 请修改为你的域名
server_tokens off; # don't show the version number, a security best practice
root /opt/gitlab/embedded/service/gitlab-rails/public;
# Increase this if you want to upload large attachments
# Or if you want to accept large git objects over http
client_max_body_size 250m;
# individual nginx logs for this gitlab vhost
access_log /var/log/gitlab/gitlab_access.log;
error_log /var/log/gitlab/gitlab_error.log;
location / {
# serve static files from defined root folder;.
# @gitlab is a named location for the upstream fallback, see below
try_files $uri $uri/index.html $uri.html @gitlab;
}
# if a file, which is not found in the root folder is requested,
# then the proxy pass the request to the upsteam (gitlab unicorn)
location @gitlab {
# If you use https make sure you disable gzip compression
# to be safe against BREACH attack
proxy_read_timeout 300; # Some requests take more than 30 seconds.
proxy_connect_timeout 300; # Some requests take more than 30 seconds.
proxy_redirect off;
proxy_set_header X-Forwarded-Proto $scheme;
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-Frame-Options SAMEORIGIN;
proxy_pass http://gitlab;
}
# Enable gzip compression as per rails guide: http://guides.rubyonrails.org/asset_pipeline.html#gzip-compression
# WARNING: If you are using relative urls do 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;
}
7.重启是配置生效。
### 重启gitlab使配置生效 ###
gitlab-ctl econfigure
### 重启nginx使配置生效 ###
service nginx restart
查看状态
gitlab-ctl status
其他指令
gitlab-ctl start
gitlab-ctl stop
gitlab-ctl restart
gitlab-ctl help
# ps -ef |grep nginx
root 1905 1 0 14:48 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
www 1906 1905 0 14:48 ? 00:00:00 nginx: worker process
www 1907 1905 0 14:48 ? 00:00:00 nginx: worker process
root 13734 2883 0 15:13 pts/0 00:00:00 grep nginx
# ps -ef |grep unicorn
root 1018 1008 0 14:48 ? 00:00:00 runsv unicorn
root 1044 1018 0 14:48 ? 00:00:00 svlogd -tt /var/log/gitlab/unicorn
git 13360 1018 0 15:12 ? 00:00:00 /bin/bash /opt/gitlab/embedded/bin/gitlab-unicorn-wrapper
git 13381 1 29 15:12 ? 00:00:17 unicorn master -D -E production -c /var/opt/gitlab/gitlab-rails/etc/unicorn.rb /opt/gitlab/embedded/service/gitlab-rails/config.ru
git 13461 13381 0 15:12 ? 00:00:00 unicorn worker[0] -D -E production -c /var/opt/gitlab/gitlab-rails/etc/unicorn.rb /opt/gitlab/embedded/service/gitlab-rails/config.ru
git 13464 13381 0 15:12 ? 00:00:00 unicorn worker[1] -D -E production -c /var/opt/gitlab/gitlab-rails/etc/unicorn.rb /opt/gitlab/embedded/service/gitlab-rails/config.ru
git 13467 13381 0 15:12 ? 00:00:00 unicorn worker[2] -D -E production -c /var/opt/gitlab/gitlab-rails/etc/unicorn.rb /opt/gitlab/embedded/service/gitlab-rails/config.ru
root 13753 2883 0 15:13 pts/0 00:00:00 grep unicorn
停止gitlab
gitlab-ctl stop
gitlab-ctl reconfigure
gitlab-ctl restart
修改unicorn,给nginx用户权限。
unicorn['port'] = 1024
web_server['external_users'] = ['www','root']
sudo chmod -R o+x /var/opt/gitlab/gitlab-rails
sudo chmod -R o+x /var/opt/gitlab/gitlab-workhorse
sudo usermod -aG git www
sudo usermod -aG gitlab-www www
查看错误日志
tail -n 10 /var/log/gitlab/gitlab_error.log
MLGB的502!
我甚至把服务器都重启了!稀里糊涂就可以了,操!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
2017-11-06 如何让Java写的程序,脱离Eclipse在别人的电脑上运行?
2016-11-06 疯狂java讲义之数据类型与运算符
2013-11-06 解决SQL server不支持utf8,php却用utf8的矛盾问题