centos7.2安裝gogs

1、安裝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
 
2、安裝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
輸入如下命令打開編輯界面
[plain] view plain copy
  1. sudo vi /etc/mysql/my.cnf
在[mysqld]下加入如下配置:
[plain] view plain copy
  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
 
alter table <table_name> row_format=dynamic; alter table <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
 
 
3、文檔
論壇地址: https://discuss.gogs.io
 
 
修改
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;
相關文章
相關標籤/搜索