zoukankan      html  css  js  c++  java
  • centos7.2安装gogs

    一、安装git
    # yum –y install git
     
    #创建用户,如果创建过git又删除,则再创建时,需要指定用户组useradd git -g git
    # useradd git
    # passwd git
     
    # 授权(gogs的目录,gogs仓库的目录)
    # chown -R git:git [gogs的目录]
    # chown -R git:git [gogs仓库的目录]
     
    如果提示系统运行用户: git -> root,则在安装页面中,将运行用户由git改为root
     
    # 注意:以下红色不要执行,因为gogs指定git用户运行的话,要求git必须能登录
    # 禁用git用户shell登录
    # vi /etc/passwd
    #找到git用户对应的行,将/usr/bin/bash 改为 /usr/bin/git-shell
     
    二、安装gogs
     
    # 上传gogs压缩包到/opt
    # 解压后,进入gogs目录下,执行./gogs web
    # 浏览器中访问ip:3000,首次访问会有安装向导(只能安装一次,如果想重装,可以删除掉目录再重新解压,所以仓库最好单独指定),管理员不能用admin
    # 安装完成后,会自动跳转到配置的域名/user/login页面,默认域名为localhost
     
    配置文件路径
    Custom config '/opt/gogs/custom/conf/app.ini' not found, ignore this if you're running first time
     
    #防火墙开放3000端口
     
    如果遇到问题:
    数据库设置不正确:Error 1071: Specified key was too long; max key length is 767 bytes
     
    ElasicSearch关联的mysql表,插入数据时会有以下提示
    ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
     
    原因分析:
    MySQL的varchar主键只支持不超过767个字节,需要将mysql的字符编码设置为utf8mb4
    输入以下命令打开编辑界面
    1. sudo vi /etc/mysql/my.cnf
    在[mysqld]下加入以下配置:
    1. innodb_file_format=barracuda
    2. innodb_file_per_table=true
    3. innodb_large_prefix=true
    4. character-set-server=utf8mb4
    5. collation-server=utf8mb4_unicode_ci
    6. max_allowed_packet=500M
    保存完重启后就能插入了。
    注意:以上设置在重启mysql后,还需要修改表的row_format
     
    altertable <table_name> row_format=dynamic; altertable <table_name> row_format=compressed;
    使用命令修改配置,有些配置无法用命令修改
    show variables like 'innodb_large%';
    set global innodb_large_prefix=1;
     
     
    # 备份(仓库和关联的数据库
    # ./gogs backup
    #恢复,--from="备份文件名称(默认备份路径为gogs根目录)"
    # ./gogs restore --from="backup_name"
     
    设置开机启动
    将gogs/scripts/systemd/gogs.service拷贝到/usr/lib/systemd/system,然后使用命令设置开机启动,如果启动不成功,则需要修改gogs.service中的WorkingDirectory ExecStart 和 HOME 后面的路径。
    # cp /opt/gogs/scripts/systemd/gogs.service /lib/systemd/system
    # systemctl enable gogs.service
    # systemctl start gogs.service
    # systemctl status gogs.service
     
    以上方案重启失败,查询官方GIT,发现有新的脚本,使用新的配置文件,重启时可以实现开机启动,断电后开机则不行,查看系统日志(/var/log/messages),发现gogs在MYSQL之前启动,修改gogs.service,添加mysql依赖After=mysql.service
     
     
    gogs.service内容:
    [Unit]
    Description=Gogs
    After=syslog.target
    After=network.target
    After=mariadb.service mysql.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=root
    Group=root
    WorkingDirectory=/opt/gogs
    ExecStart=/opt/gogs/gogs web
    Restart=always
    Environment=USER=root HOME=/opt/gogs
    # Hardening
    ProtectSystem=full
    PrivateDevices=yes
    PrivateTmp=yes
     
    [Install]
    WantedBy=multi-user.target
     
     
    三、文档
     
     
    修改
    alter table access row_format=compressed;
    alter table access_token row_format=compressed;
    alter table action row_format=compressed;
    alter table attachment row_format=compressed;
    alter table collaboration row_format=compressed;
    alter table comment row_format=compressed;
    alter table deploy_key row_format=compressed;
    alter table follow row_format=compressed;
    alter table issue row_format=compressed;
    alter table issue_label row_format=compressed;
    alter table issue_user row_format=compressed;
    alter table label row_format=compressed;
    alter table login_source row_format=compressed;
    alter table milestone row_format=compressed;
    alter table mirror row_format=compressed;
    alter table public_key row_format=compressed;
    alter table pull_request row_format=compressed;
    -- alter table 'release' row_format=compressed;
    alter table repository row_format=compressed;
    alter table star row_format=compressed;
    alter table two_factor row_format=compressed;
    alter table two_factor_recovery_code row_format=compressed;
    alter table upload row_format=compressed;
    alter table user row_format=compressed;
    alter table watch row_format=compressed;
    alter table protect_branch row_format=compressed;
    alter table webhook row_format=compressed;
    alter table hook_task row_format=compressed;
    alter table protect_branch_whitelist row_format=compressed;
  • 相关阅读:
    算法初探
    OIer数学相关
    算法初探
    MySQL事务
    MySQL多表查询
    数据库的设计
    winform选择文件夹
    获取上次打开目录
    C#拆分中文和数字字符串
    uCharts如何设置双Y轴,左侧一个右侧一个,数据源与对应的Y轴绑定
  • 原文地址:https://www.cnblogs.com/weijs/p/8432726.html
Copyright © 2011-2022 走看看