美文网首页
Gitea部署

Gitea部署

作者: 钾肥尔德 | 来源:发表于2020-02-23 20:14 被阅读0次

    下载地址

    https://dl.gitea.io/
    最新版本https://dl.gitea.io/gitea/master/gitea-master-linux-amd64

    安装

    ➜  ~ mkdir -p /opt/gitea/{bin,cfg,ssl}
    ➜  ~ mv gitea-master-linux-amd64 /opt/gitea/bin/gitea
    ➜  ~ chmod +x /opt/gitea/bin/gitea
    ➜  ~ ln -s /opt/gitea/bin/gitea /usr/bin/gitea
    ➜  ~ gitea --version
    Gitea version 1.12.0+dev-359-g0bba3f9cf built with GNU Make 4.1, go1.13.8 : bindata, sqlite, sqlite_unlock_notify
    

    环境准备

    • Git

    ➜  ~ git --version
    git version 2.25.1
    
    • 创建运行Gitea的user (ex. git)

    groupadd git
    adduser \
       --system \
       --shell /bin/bash \
       --comment 'Git Version Control' \
       -g git \
       --home-dir /home/git \
       git
    
    • 创建必须的目录结构

    mkdir -p /var/lib/gitea/{custom,data,log}
    chown -R git:git /var/lib/gitea/
    chmod -R 750 /var/lib/gitea/
    mkdir /etc/gitea
    chown root:git /etc/gitea
    chmod 770 /etc/gitea
    

    NOTE: /etc/gitea is temporary set with write rights for user git so that Web installer could write configuration file. After installation is done, it is recommended to set rights to read-only using:

    chmod 750 /etc/gitea
    chmod 640 /etc/gitea/app.ini
    

    If you don’t want the web installer to be able to write the config file at all, it is also possible to make the config file read-only for the gitea user (owner/group root:root, mode 0660), and set INSTALL_LOCK = true. In that case all database configuration details must be set beforehand in the config file, as well as the SECRET_KEY and INTERNAL_TOKEN values.

    • Run as service

    /etc/systemd/system/gitea.service

    [Unit]
    Description=Gitea (Git with a cup of tea)
    After=syslog.target
    After=network.target
    ###
    # Don't forget to add the database service requirements
    ###
    #
    #Requires=mysql.service
    #Requires=mariadb.service
    #Requires=postgresql.service
    #Requires=memcached.service
    #Requires=redis.service
    #
    ###
    # If using socket activation for main http/s
    ###
    #
    #After=gitea.main.socket
    #Requires=gitea.main.socket
    #
    ###
    # (You can also provide gitea an http fallback and/or ssh socket too)
    #
    # An example of /etc/systemd/system/gitea.main.socket
    ###
    ##
    ## [Unit]
    ## Description=Gitea Web Socket
    ## PartOf=gitea.service
    ##
    ## [Socket]
    ## Service=gitea.service
    ## ListenStream=<some_port>
    ## NoDelay=true
    ##
    ## [Install]
    ## WantedBy=sockets.target
    ##
    ###
    
    [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
    RestartSec=2s
    Type=simple
    User=git
    Group=git
    WorkingDirectory=/var/lib/gitea/
    # If using Unix socket: tells systemd to create the /run/gitea folder, which will contain the gitea.sock file
    # (manually creating /run/gitea doesn't work, because it would not persist across reboots)
    #RuntimeDirectory=gitea
    ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
    Restart=always
    Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea
    # If you want to bind Gitea to a port below 1024, uncomment
    # the two values below, or use socket activation to pass Gitea its ports as above
    ###
    #CapabilityBoundingSet=CAP_NET_BIND_SERVICE
    #AmbientCapabilities=CAP_NET_BIND_SERVICE
    ###
    
    [Install]
    WantedBy=multi-user.target
    
    systemctl enable gitea
    systemctl start gitea
    
    • Running from command-line/terminal

    GITEA_WORK_DIR=/var/lib/gitea/ /usr/local/bin/gitea web -c /etc/gitea/app.ini
    

    相关文章

      网友评论

          本文标题:Gitea部署

          本文链接:https://www.haomeiwen.com/subject/vqkjqhtx.html