Ubuntu 安装Git Server Gogs,配置commit邮件通知 原创
Ubuntu 安装Git Server Gogs,配置commit邮件通知
文章目录
项目源码地址:https://github.com/gogits/gogs
安装参考文档:https://gogs.io/docs/installation
https://gogs.io/docs/installation/install_from_binary.html
1. 安装mysql和git
sudo apt-get install git mysql-server mysql-client libmysqlclient-dev
过程中输入mysql账户root的密码,要记下
如果没有提示输入密码,密码默认没有
sudo netstat -tap | grep mysql
通过上述命令检查之后,如果看到有mysql 的socket处于 listen 状态则表示安装成功。
2. 创建Gogit需要的数据库
mysql -u root -p
然后执行scripts/mysql.sql中的sql语句
3. 下载最新的release版本
- 新建git用户,并登陆,以下操作在git账户下
- 最新版本地址:https://dl.gogs.io/
- 解压后,cd 到解压目录,然后执行./gogs web
- 此时命令行退出,服务会停止,解决办法:
apt install tmux
,在tmux中执行./gogs web - 也可以配置自启动服务,可以参考 gogs/scripts
4. 配置数据库
打开浏览器,输入http://localhost:3000 或者 http://服务器IP:3000
按照提示配置,然后点安装,成功后跳转到登录
如需要修改mysql root的密码的可以参见
how-to-reset-the-root-password-in-mysql-8-0-11
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'newpasswd';
以上配置信息保存在以下文件中 ./gogs/custom/conf/app.ini
5. 提交代码后,用multimail发送邮件通知
- 需要在gogs server加以下配置
git config --global multimailhook.from "code.server@chenjim.com"
git config --global multimailhook.mailer "smtp"
git config --global multimailhook.mailingList "me@chenjim.com,zhang.san@chenjim.com,"
git config --global multimailhook.commitEmailFormat "html"
git config --global multimailhook.smtpServerTimeout 15
git config --global multimailhook.smtpServer "smtp.exmail.qq.com:465"
git config --global multimailhook.smtpUser "code.server@chenjim.com"
git config --global multimailhook.smtpPass "Code123456"
git config --global multimailhook.smtpEncryption "ssl"
- 需要加以下配置
/home/git/git-multimail/git-multimail/post-receive.example
,下载git-multimail
- 使以上修改立即生效,修改如下
本文来自博客园,作者:清霜辰,转载请注明原文链接:https://www.cnblogs.com/cnjim/p/18443506
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了