前言
Gi tea是一个开源的git版本控制系统,是gogs的一个分支,是gogs的社区维护版本,它的起源是社区和作者之间的事,感兴趣的可以去查一查,只是说gitea起源于gogs,是在它的基础上编写扩充而来,有一个活跃的社区,相比起gogs单人维护,gitea更新多,提交代码量也多,还继承了gogs轻量的优点。
安装
wget -O gitea https://dl.gitea.io/gitea/1.7.0-rc2/gitea-1.7.0-rc2-linux-amd64
chmod +x gitea
./gitea web
反向代理
提前解析好域名,我是使用的宝塔,傻瓜式,打上证书,在配置文件里面添加
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
然后修改关于图片和css,js的规则,否则页面会不正常
#需要设置图片反向代理
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
proxy_pass http://127.0.0.1:3000;
error_log off;
access_log off;
}
#同理如上
location ~ .*\.(js|css)$ {
proxy_pass http://127.0.0.1:3000;
}
然后浏览器访问你的https://域名 进行安装即可。
用户名运行,就是你执行./gitea web
命令时登陆的用户,不一样就会报错,SSH服务域名和Gitea基本URL就是你克隆或是上传代码用的路径,这就是前面为啥需要先反向代理解析域名,当然你默认也行,localhost,后续在/www/wwwroot/test.denry.cn/custom/conf/app.ini
配置文件修改即可,为了省事,还是配置好一步到位。
安装完成之后
优化程序运行
每次运行,都要执行./gitea web
很不方便,所以把它注册成系统启动服务。因为我用的是debian系统,centos系存放在/usr/lib/systemd/system/
vim /lib/systemd/system/gitea.service
写入
[Unit]
Description=gitea
[Service]
User=root
ExecStart=www/wwwroot/test.denry.cn/gitea web
Restart=on-abort
[Install]
WantedBy=multi-user.target
然后重启systemctl
,systemctl daemon-reload
,加入开机自启动systemctl enable gitea
使用systemctl status gitea
查看效果
配置本地git链接
因为我是用的marjaro,配置起来比win简单。
配置密匙
ssh-keygen -t rsa -C "835185778@qq.com"
一路回车即可,然后去用户主目录找到.ssh文件夹,里面有id_rsa和id_rsa.pub两个文件,这两个就是SSH Key的秘钥对,id_rsa是私钥,不能泄露,id_rsa.pub是公钥,可以公开。复制id_rsa.pub的内容,去设置->SSH/GPG密匙里面增加密匙,粘贴入密匙内容。
链接
ssh -T git@test.denry.cn
验证是否成功链接
设置邮箱和用户名
git config --global user.email "835185778@qq.com"
git config --global user.name "denry"
本地建立仓库设置
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://test.denry.cn/denry/oooooo.git
git push -u origin master
然后去仓库查看代码即可。