下载二进制文件: https://dl.gogs.io

    1. wget https://dl.gogs.io/0.11.66/gogs_0.11.66_linux_amd64.zip

    解压

    1. unzip gogs_0.11.66_linux_amd64.zip

    创建数据库

    1. mysql -uroot -p
    2. create database gogs;

    启动(指定端口)

    1. ./gogs/gogs web -port=30033

    访问页面安装和配置

    配置系统服务

    1. cp ./gogs/scripts/systemd/gogs.service /etc/systemd/system/
    2. sudo vim /etc/systemd/system/gogs.service

    编辑如下:

    1. [Unit]
    2. Description=Gogs
    3. After=syslog.target
    4. After=network.target
    5. After=mysqld.service # 此处删除其它非依赖应用
    6. [Service]
    7. # Modify these two values and uncomment them if you have
    8. # repos with lots of files and get an HTTP error 500 because
    9. # of that
    10. ###
    11. #LimitMEMLOCK=infinity
    12. #LimitNOFILE=65535
    13. Type=simple
    14. User=root # 更改为自己的启动用户
    15. Group=root # 更改为自己的启动用户组
    16. WorkingDirectory=/root/gogs # 更改为自己的工作目录
    17. ExecStart=/root/gogs/gogs web # 更改为自己的启动文件位置
    18. Restart=always
    19. Environment=USER=root HOME=/root # 更改为自己的启动用户和位置
    20. # Some distributions may not support these hardening directives. If you cannot start the service due
    21. # to an unknown option, comment out the ones not supported by your version of systemd.
    22. # 这部分配置都删掉
    23. [Install]
    24. WantedBy=multi-user.target