合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
| Gitlab配置 | | | --- | --- | ``` 1、安装ssh sudo yum install -y curl policycoreutils-pythonopenssh-server 2、将SSH服务设置成开机自启动,安装命令: sudo systemctl enable sshd 3、启动SSH服务,安装命令: sudo systemctl start sshd 4、安装防火墙 yum install firewalld systemd -y 5、开启防火墙 systemctl start firewalld.service 6、添加http服务到firewalld,pemmanent表示永久生效,若不加--permanent系统下次启动后就会失效 sudo firewall-cmd --permanent --add-service=http 成功返回success 7、重启防火墙 systemctl restart firewalld.service 8、安装Postfix以发送通知邮件 sudo yum install postfix 9、将postfix服务设置成开机自启动 sudo systemctl enable postfix 10、启动postfix sudo systemctl start postfix 在安装Postfix期间,可能会出现配置屏幕。选择“Internet Site”并按enter键。使用您的服务器的外部DNS以“mail name”并按enter。如果出现额外的屏幕,继续按enter键接受默认值 11、添加GitLab仓库,并安装到服务器上(安装最新版) curl -sS http://packages.gitlab.cc/install/gitlab-ce/script.rpm.sh | sudo bash sudo yum install gitlab-ce 12、修改配置,vim /etc/gitlab/gitlab.rb external_url 'http://git.example.com'改成自己的地址 external_url 'http://192.168.160.129' 13、让配置生效 sudo gitlab-ctl reconfigure 14、启动服务 sudo gitlab-ctl restart 15、浏览器访问http://192.168.160.129 ``` | 相关操作 | | | --- | --- | | gitlab-ctl start | 启动服务 | | gitlab-ctl status | 查看状态 | | gitlab-ctl stop | 停掉服务 | | gitlab-ctl restart | 重启服务 | | gitlab-ctl reconfigure | 让配置生效 | | head -1 /opt/gitlab/version-manifest.txt | 查看gitlab版本 | | cat /opt/gitlab/embedded/service/gitlab-rails/VERSION | 查看gitlab版本 | | cat /etc/redhat-release | 查看系统版本 | | GitLab卸载 | | | --- | --- | ``` 1、停止gitlab sudo gitlab-ctl stop 2、卸载gitlab sudo rpm -e gitlab-ce 3、查看gitlab进程,杀掉第一个守护进程 ps -ef|grep gitlab 找到runsv gitlab-monitor的进程ID kill -9 PID 再次查看gitlab进程是否存在 4、删除gitlab文件 find / -name gitlab|xargs rm -rf 删除所有包含gitlab的文件及目录 删除gitlab-ctl uninstall时自动在root下备份的配置文件 ``` | GitLab汉化 | | | --- | --- | 百度自己找 ``` 报错: 1、502错误 原因;8080端口被占用 解决方法 1、kill 8080端口的进程,不过好像不起作用 2、vim /etc/gitlab/gitlab.rb配置文件 external_url 'http://47.104.x.x:8100' unicorn['port'] = 8101(加上unicorn默认端口) 3、把这两个端口加入到防火墙中 firewall-cmd --permanent --zone=public --add-port=8100/tcp firewall-cmd --permanent --zone=public --add-port=8101/tcp (一般是关闭防火墙的) 3、修改保存之后 gitlab-ctl reconfigure gitlab-ctl stop gitlab-ctl start 2、汉化执行sudo patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < ./11.11-0-diff报错 一直按回车跳过 ``` | Gitlab网页无法登录原因 | | | --- | --- | ``` 原因:由于配置的IP端口未加入到防火墙中 解决方法: 1、查看端口是否开启 netstat -anp | grep 8100 2、把端口加入到防火墙中 sudo firewall-cmd --zone=public --add-port=8100/tcp --permanent #把端口加入到防火墙中 sudo firewall-cmd --reload #重启防火墙 ``` | Gitlab使用域名访问 | 80端口被占用 | | --- | --- | ``` 原理:当80端口被nginx或者apache占用,使用服务器的代理模式,通过跳转指向到gitlab配置的url 1、找到nginx或者apache的配置文件(当前为nginx) cd /www/server/panel/vhost/nginx 2、添加文件,并写入内容,保存 vim gitlab.wordlet.cn.conf server { listen 80; server_name gitlab.wordlet.cn; #error_page 404 /404.html; # Deny access to PHP files in specific directory #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; } #代理跳转 location / { proxy_pass http://127.0.0.1:10000; } access_log /www/wwwlogs/gitlab.wordlet.cn.log; error_log /www/wwwlogs/gitlab.wordlet.cn.error.log; } 3、把端口加入到防火墙,重启nginx服务器 firewall-cmd --permanent --zone=public --add-port=10000/tcp 4、修改gitlab配置,vim /etc/gitlab/gitlab.rb external_url 'http://127.0.0.1:10000' 5、让配置生效 sudo gitlab-ctl reconfigure 6、重新启动服务 sudo gitlab-ctl restart 7、浏览器访问 http://gitlab.wordlet.cn ``` | GitLba 自动同步到web站点目录 | 方法一 | | --- | --- | ``` 1、找到要同步的仓库 cd /var/opt/gitlab/git-data/repositories/XXX/erp.git/hooks 2、新建post-receive文件 touch post-receive 3、打开post-receive,写入下面代码并保存 GIT_WORK_TREE=/www/xxx #项目目录地址 BRANCH=develop while read oldrev newrev ref do if [[ $ref =~ .*/${BRANCH}$ ]]; then echo "$BRANCH ref received. Deploying $BRANCH branch to testserver..." git --work-tree=${GIT_WORK_TREE} checkout ${BRANCH} -f else echo "Ref $ref successfully received. Doing nothing: only the $BRANCH branch may be deployed on this server." fi done 4、这个方法其实是有问题的。目录/var/opt/gitlab/git-data/repositories/root/xxx.git/hooks/是一个连接指向/opt/gitlab/embedded/service/gitlab-shell/hooks/ 5、目录/var/opt/gitlab/git-data/repositories/root/xxx.git/下新建 custom_hooks目录 把post-receive放在该目录下 ``` | GitLba 自动同步到web站点目录 | 方法二 | | --- | --- | | 待处理问题 | | | --- | --- | 1、通过webhook.php为同步到站点 2、如果站点目录已做修改,如果同步到代码仓库