Windows server 部署 gogs 服务简记

Windows server 部署 gogs 服务简记

公司需要在自己的服务器上部署一个私有的 git 远程仓库,在权衡了市面上的几款开源 git 仓库服务后,我选择了 gogs,无他,部署简单,资源占用低。花了大概一个半天的时间搭建好了,综合了 gogs 官网的文档及网络上的资料,这里做一个简单的记录,保证可用。

安装 gogs

下载 gogs 压缩包,解压,在解压下的目录,新建 log 文件夹和 conf 文件夹:
在这里插入图片描述
在这里插入图片描述
在里面分别新建空白的 txt 文件和 app.ini 文件备用。
在 app.ini 文件中写入自己的配置:
在这里插入图片描述
其中 RUN_USER 的值由运行命令:

echo %COMPUTERNAME%

获得,显示的是什么,就在它之后加一个$

nssm

下载 nssm,nssm 的作用是将 gogs 注册成 windows 服务,解压,cd 到目录下,运行:

nssm install gogs

会弹出一个弹窗,弹窗中的设置参考 gogs 官方文档:

Use NSSM
Get the nssm.exe needed for your machine (32 or 64 bit; they’re packaged together in Iain’s zip file), and place it in a directory that is in (or will be added to) your %PATH% environment variable.
Open a command line as administrator and do following command to configure Gogs as a service:
C:>nssm install gogs
“NSSM service installer” will appear. Configure it as follows:
Application tab:
* Path: C:\gogs\gogs.exe
* Startup directory: C:\gogs
* Arguments: web
在这里插入图片描述
Details tab:
* Display name: Gogs
* Description: A painless self-hosted Git service.
* Startup type: Automatic (Delayed Start)
Note that we’ve chosen delayed start, so that the service will not impact the early boot time. Gogs will start two minutes after the non-delayed services.
在这里插入图片描述
I/O tab:
* Output (stdout): C:\gogs\log\gogs-nssm.txt
* Error (stderr): C:\gogs\log\gogs-nssm.txt
That will capture all text output that you would normally receive from Gogs on the command line console, and log it to that file instead.
在这里插入图片描述
File rotation tab:
* Check: Rotate files
* Restrict rotation to files bigger than: 1000000 bytes
在这里插入图片描述
Environment tab:
* Environment variables: PATH=%PATH%;C:\gogs;C:\Program Files (x86)\Git\bin
That is a guarantee that both gogs.exe and git.exe will be on the Gogs service’s path variable during runtime.
在这里插入图片描述
Click “Install service”, and you should be confirmed that it succeeded.

成功后,可以在服务中看到 gogs 服务:
在这里插入图片描述

nginx

需要转发请求,我选择使用 nginx。下载安装 nginx,解压,cd 到目录下,输入命令:

start nginx   (输入这一句会看到一个黑窗一闪而过)
tasklist /fi "imagename eq nginx.exe"

可以看到
在这里插入图片描述
接下来修改 nginx 的配置,在 conf 文件夹下的 nginx.conf 文件,在 server 下添加 listen,server_name,以及配置 location 即可。
修改完配置,可以输入命令来查看配置文件中的语法是否有错误:
在这里插入图片描述
没问题的话,重启 nginx:
在这里插入图片描述
同样的,nginx 也可以配置为 windows 的服务。

后记:

在使用的过程中发现传输太大的文件,git 会传不上去,这是问题出在 nginx 那里,它限制了传输的大小,改一下相关配置即可。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要使用Docker部署Gogs,可以按照以下步骤进行操作: 1. 首先,创建一个容器,使用Gogs镜像运行命令:docker run -d --name=gogs -p 10022:22 -p 10080:3000 -v /var/gogs:/data gogs/gogs。这个命令将创建一个名为gogs的容器,并将主机的10022端口映射到容器的22端口,将主机的10080端口映射到容器的3000端口。 2. 确保你已经安装了阿里云Linux CentOS 7,并了解如何使用Docker部署Gogs。可以参考阿里云的文档和官方网站上的教程。 3. 运行上述命令后,Docker将自动下载和运行Gogs镜像,并将容器部署在你的系统上。你可以通过访问http://localhost:10080来访问Gogs的Web界面。 4. 在Gogs的Web界面上,你可以进行用户注册、创建仓库、管理代码等操作。Gogs提供了一个简单、快速搭建自助Git服务的解决方案。 总结:使用Docker部署Gogs是一种快速搭建自助Git服务的方法。只需要运行一个简单的Docker命令,就可以创建一个Gogs容器,并访问Gogs的Web界面进行代码管理。这个方法适用于想要快速搭建Git服务器的用户。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [使用docker搭建gogs](https://blog.csdn.net/m0_67391518/article/details/126553666)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [阿里云Linux CentOS 7 Docker部署使用gogs搭建自己的git服务器](https://download.csdn.net/download/weixin_38678300/12843132)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [docker安装配置gogs](https://blog.csdn.net/wuyongde0922/article/details/125720115)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值