服务器环境搭建
Ubuntu 16.04 64位
更新
sudo apt-get update
安装MySQL数据库
sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install libmysqlclient-dev
设置mysql 远程连接
编辑 mysqld.cnf 文件
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
注释掉bind-address = 127.0.0.1;
保存退出,然后进入mysql服务,执行授权命令(password:你设置的密码):
grant all on *.* to root@'%' identified by 'youPassWord' with grant option;
flush privileges;
然后执行quit命令退出mysql服务,执行如下命令重启mysql:
service mysql restart
安装jdk 1.8
sudo apt-get install openjdk-8-jdk
安装GitLib
sudo apt-get update
sudo apt-get install -y curl openssh-server ca-certificates
sudo apt-get install curl openssh-server ca-certificates postfix
使用清华大学gitlib镜像源(https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/)
首先信任 GitLab 的 GPG 公钥:
选择你的 Debian/Ubuntu 版本,文本框中内容写进 /etc/apt/sources.list.d/gitlab-ce.list
sudo vi /etc/apt/sources.list.d/gitlab-ce.list
写入
deb https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu xenial main
:wq!(保存)
安装 gitlab-ce:
sudo apt-get update
sudo apt-get install gitlab-ce
启动sshd和postfix服务
service sshd start
service postfix start
添加防火墙规则
sudo iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
启动各项服务
sudo gitlab-ctl reconfigure
检查GitLab是否安装好并且已经正确运行
sudo gitlab-ctl status
浏览web页面并设置密码
http://Ip/
修改端口
编辑配置文件 sudo vim /etc/gitlab/gitlab.rb
修改 external_url 'http://gitlab.example.com'
external_url 'http://youIp:端口'
unicorn['port'] = 端口
编辑配置文件 sudo vim /var/opt/gitlab/nginx/conf/gitlab-http.conf
修改listen *:端口;
修改完成后重启服务即可,gitlab-ctl restart
注意:
gitlab-http.conf 文件的端口和 gitlab.rb 的端口 不能一样
gitlib命令:
sudo gitlab-ctl start #启动
sudo gitlab-ctl stop #停止
gitlab-ctl restart #重启
安装Jenkins
安装Jenkins之前需要先安装JDK
卸载
sudo apt-get remove jenkins
sudo apt-get purge jenkins
sudo apt-get purge --auto-remove jenkins
安装
wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins(此步骤阿里云下载较慢建议晚上挂机下载)
修改8080端口
sudo vi /etc/init.d/jenkins
原: check_tcp_port “http” “$HTTP_PORT” “8080” || return 1
新:check_tcp_port “http” “$HTTP_PORT” “8082” || return 1
sudo vi /etc/default/jenkins
将端口8080改成8082
Jenkins 启动 | 停止 | 重启命令
sudo /etc/init.d/jenkins [start|restart| ]
启动 service jenkins start
停止 service jenkins stop
重启 service jenkins restart
查看初始化密码
cat /var/lib/jenkins/secrets/initialAdminPassword
查看进程
运行netstat -ntpl | grep 3306命令行看3306是否打开
netstat -talnp