Linux搭建git gogs

1.依赖 git,mysql(已安装)

2.进入mysq 创建gogs数据库(5.6版本的数据库可能会有索引长度报错,建议使用5.7mysql)

SET GLOBAL storage_engine = innodb;

CREATE DATABASE gogs CHARACTER SET utf8 COLLATE utf8_bin;

GRANT ALL PRIVILEGES ON gogs.* TO ‘root’@‘localhost’ IDENTIFIED BY 'YourPassword';

FLUSH PRIVILEGES;

QUIT;

3.创建git用户        

useradd git

passwd git

4.进入git用户目录下生产ssh密钥

ssh-keygen-t rsa

5.下载安装包并解压

wget https://dl.gogs.io/0.11.34/linux_amd64.tar.gz

tar -xzf linux_amd64.tar.gz -C /

6.移动到对应目录

mv /gogs /home/git/gogs

7.设置后台运行

nohup gogs/gogs web > /dev/null 2>&1 &

7.设置开机自启

cd /lib/systemd/system

vim gogs.service

[Unit] Description=Gogs

After=syslog.target

After=network.target

After=mysqld.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

ExecStart=/home/git/gogs/gogs web

Restart=always Environment=USER=git

HOME=/home/git [Install] WantedBy=multi-user.target

8.启用服务(开机自启还有问题)

systemctl enable gogs.service

systemctl start gogs

systemctl status gogs

---------------------------------

/home/git/gogs/start.sh 

https://gogs.io/docs/advanced/configuration_cheat_sheet          配置文件手册

猜你喜欢

转载自blog.csdn.net/New_CJ/article/details/83898080