4.1 KiB
Gitea
官网
用途
低配置要求的Gitlab替代。
文件说明
docker-compose.yml:服务配置;
安装说明
-
解析域名到你的服务器;
-
安装docker-compose,参考: CENTOS安装Docker Compose;
-
完成NginxAndLetsencrypt的部署(或acme,参看acme项目的实例研究1);
参见相关说明。(包含把sample.conf改名为gitea.conf或其他名字)
-
在/srv下,复制gitea目录。cd进gitea
-
在/srv/gitea下,chmod +x ./grant-permissions.sh
-
执行该sh脚本。注意,可以通过tail -2 /etc/passwd和tail -2 /etc/group 查看新注册用户的uid和gid。如和docker-compose.yml中的不符合则应修改yml文件。
-
执行docker ps来查看当前的docker实例,找到其中的nginx实例:
...... 84e4e7a719e8 nginx:latest "/bin/sh -c 'while :…" 17 months ago Up 5 weeks 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp nginx_nginx_1
-
执行 docker inspect nginx_nginx_1来确定nginx所在网络名称:
"Networks": { "nginx_firstnet": { -
执行 docker network inspect nginx_firstnet 来确定一些网络信息:
"IPAM": { "Driver": "default", "Options": null, "Config": [ { "Subnet": "172.20.0.0/16" } ] }, ...... "Containers": { "84e4e7a719e8a904255ebcb522ce73ff8d0f2340a42d12969cead432ecdf4b77": { "Name": "nginx_nginx_1", "EndpointID": "f7a35255526ed39931e018ad27c2bcc448840f77f4de9666baa4416c396c03a7", "MacAddress": "02:42:ac:14:00:02", "IPv4Address": "172.20.0.2/16", "IPv6Address": "" }, "e390b8cbe5075efed7fb834acd74fe7ae84cc685249362b4802abb1e626fc909": { "Name": "frps_server_1", "EndpointID": "04f759a5e894e9286720946763b123f805c76d869697113e83f53e516ed75c4b", "MacAddress": "02:42:ac:14:00:03", "IPv4Address": "172.20.0.3/16", "IPv6Address": "" } },可以看到,现有的网段和网络中已有实例的IP。我们可以据此规划gitea实例的IP。
-
根据上述两点网络相关的信息修改gitea的docker-compose文件中的对应部分,并指定固定IP。
-
将需要nginx代理的应用设置的固定IP填入之前的gitea.conf。
-
重启nginx的docker容器。
问题发现:重启失败。查看nginx的日志
-
首先是错误:unknown directive "server"
[root@ngork logs]# tail -20 error.log 2021/10/29 14:01:25 [emerg] 7#7: unknown directive "?server" in /etc/nginx/conf.d/gitwoyue.conf:1
在开发环境(windows),编码保存为简体中文936解决。原为utf-8。其实,这很奇怪,与一般的认知是相反的。
-
然后是open() "/etc/letsencrypt/options-ssl-nginx.conf" failed (2: No such file or directory) in /etc/nginx/conf.d/gitwoyue.conf:22
注释掉即可。
-
-
启动gitea的docker-compose
docker-compose up -d -
访问网站。初始化
例如,git.woyue.org。
这里,注意参考用到的compose文件,确认用户名是否需要修改(默认git)
另外,需要创建一个空的数据库。默认名是gitea。
使用说明
-
配置文件在:/srv/gitea/gitea/gitea/conf下的app.ini
-
邮件smtp服务器要带端口号(通常是25)
-
注意对于大项目的首次push,有可能上传请求体大小超出Nginx限制。注意相关配置。参考:https://blog.csdn.net/yedajiang44/article/details/99294216
测试环境
-
CentOS Linux release 7.3.1611 (Core)