前言
最近由于项目须要,多人协做,实在不想用svn了,以前也一直在github.com,可是仍是想搭建私有的git。为何呢,git私有仓库太贵了,7美圆一个月,还只能增长一位成员。越到后面越贵,因此决定本身来搭建。感谢老板给了1台阿里ECS,单独来作git。我一个小前端,本身搭建gitlab坑仍是蛮多的。
正文
1、配置
先来看下载地址https://bitnami.com/stack/gitlab,为何选择bitnami的呢,由于它把一些gitlab须要的组件一块儿打包了。由于我是装的GitLab8.9.6,因此对应是下面这些组件。
组件:
- GitLab 8.9.6
- Apache 2.4.23
- ImageMagick 6.7.5
- PostgreSQL 9.5.3
- Git 2.7.4
- Ruby 2.1.9
- Rails 4.2.5.1
- RubyGems 1.8.12
咱们看下对服务器的要求(这里要求内存2G,大哥们看清楚,一开始想省钱,没注意,结果死活装不上去,最后换成2核4G的ECS)
- Intel x86 or compatible processor
- Minimum of 2048 MB RAM
- Minimum of 150 MB hard drive space
- TCP/IP protocol support
- Compatible operantig systems:
- An x86 Linux operating system.
2、安装
#若是你是ubuntu那种有界面的,就下一步就行了。
#若是是centos这种没有界面的,进到下载好的根目录,执行下面的。这是给对应的权限,在运行前必定要执行一下。
chmod 755 bitnami-gitlab-8.9.6-0-linux.run
#我用的 chmod -x bitnami-gitlab-8.9.6-0-linux.run
#而后开始
./bitnami-gitlab-8.9.6-0-linux-x64-installer.run
#一、前面几个选择Y,而后及时选择安装路径“Select a folder [/opt/gitlab-8.9.6-0]”,回车就自动装这个里面了。
#二、接着填写建立管理者的邮件地址,管理者的登陆名,管理者2次密码。
#三、Domain [127.0.0.1]: 选择对外的域名或则IP,我填的是域名,挺好用的。
#四、而后设置Configure SMTP Settings,对应的发邮件配置,蛮重要的,牵扯到你是管理员第一次须要改密码,以及其余用户找回密码。我选择的是腾讯企业邮箱。这里注意,你填写邮件的帐号密码,是用来发邮件的,密码是明文写在配置文件里的,最好悠着点。
#安装完成后,必定要来手动邮箱配置,这是一个大坑,由于它安装过程结束,并无修改gitlab.yml这个文件。腾讯企业邮箱配置修改。
vi /opt/gitlab-8.9.6-0/apps/gitlab/htdocs/config/environments/production.rb
config.action_mailer.smtp_settings = {
:address => "smtp.exmail.qq.com",
:port => "25",
:domain => "smtp.qq.com",
:authentication => :plain,
:user_name => "你发邮件的帐号",
:password => "你发邮件的密码",
:enable_starttls_auto => true
}
#反正我是用了25端口,465这个端口我没成功,有点坑爹。
vi /opt/gitlab-8.9.6-0/apps/gitlab/htdocs/config/gitlab.yml
## Email settings
# Uncomment and set to false if you need to disable email sending from GitLab (default: true)
# email_enabled: true
# Email address used in the "From" field in mails sent by GitLab
email_from: 你发邮件的帐号
email_display_name: GitLab
email_reply_to: noreply@example.com
#这2个文件的“你发邮件的帐号”必定要同样。很是重要。
3、启动
#跑到/opt/gitlab-8.9.6-0 目录下。
./ctlscript.sh (start|stop|restart)
#单独控制其余,能够开启、中止、重启。
./ctlscript.sh (start|stop|restart) postgres
./ctlscript.sh (start|stop|restart) redis
./ctlscript.sh (start|stop|restart) apache
./ctlscript.sh (start|stop|restart) sidekiq
#start - start the service(s)
#stop - stop the service(s)
#restart - restart or start the service(s)前端
#若是没什么问题,你就能够去你刚才配置的域名处访问了(注意:我访问服务器上的配置的与域名访问不了,会要求你购买域名,直接经过ip地址访问便可:http://serverip 因为默认绑定的是80端口,因此这边端口号不用写),注意你的服务器是否关闭防火墙,linux
vi /etc/sysconfig/iptables 打开80防火墙配置git
service iptables restart 重启防火墙
。我用的是CentOS 7.2,默认安装firewall做为防火墙,关闭防火墙命令。和CentOS 6的命令不同哟,也是一个坑。
systemctl stop firewalld.service #中止firewallgithub
4、卸载
/opt/gitlab-8.9.6-0/uninstallredis