上面说了gogs的基本配置,下面就说说centos8下面如何配置成systemd服务
在/etc/systemd/system/gogs.service
文件内容参考如下。
[Unit]
Description=Gogs
After=syslog.target
After=network.target
After=mariadb.service mysqld.service postgresql.service memcached.service redis.service
[Service]
# Modify these two values and uncomment them if you have
# repos with lots of files and get an HTTP error 500 because
# of that
###
#LimitMEMLOCK=infinity
#LimitNOFILE=65535
Type=simple
User=git
Group=git
WorkingDirectory=/home/git/gogs #此处要注意是gogs的安装根目录
ExecStart=/home/git/gogs/gogs web
Restart=always
Environment=USER=git HOME=/home/git
# Some distributions may not support these hardening directives. If you cannot start the service due
# to an unknown option, comment out the ones not supported by your version of systemd.
ProtectSystem=full
PrivateDevices=yes
PrivateTmp=yes
NoNewPrivileges=true
[Install]
WantedBy=multi-user.target
配置完毕就可以执行 systemctl start gogs
如果有修改就会提示 systemctl deamon-reload 执行这个命令就好了
下面说说如何给gogs一个域名可以提供域名访问,这样也比较方便点
server {
server_name gogs.test.com;
listen 80;
#ssl on;
location /{
proxy_pass http://127.0.0.1:3000/; #注意要和gogs web定义的端口一致,默认是3000
proxy_redirect default;
}
}
在nginx 中添加一个这样的服务器定义段落,或者单独一个文件让nginx能引用到
就可以了,大家可以参考这个试试哈