# Gogs Basic
Gogs(/gɑgz/
)项目旨在打造一个以最简便的方式搭建简单、稳定和可扩展的自助 Git 服务。使用 Go 语言开发使得 Gogs 能够通过独立的二进制分发,并且支持 Go 语言支持的 所有平台,包括 Linux、macOS、Windows 以及 ARM 平台。
# 安装配置依赖环境
APP_NAME="gogs"
MYSQL_PASSWORD="change_me"
HOSTNAME="example.com"
# setup mysql
yum install mysql-server -y
service mysql-server start
chkconfig mysql-server
mysqladmin -u root password "${MYSQL_PASSWORD}"
mysqladmin -u root --password="${MYSQL_PASSWORD}" password "${MYSQL_PASSWORD}"
mysql -u root -p${MYSQL_PASSWORD} -e "CREATE DATABASE IF NOT EXISTS ${APP_NAME}; use ${APP_NAME}; set global storage_engine=INNODB;"
# install nginx
rpm -Uhv http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
yum install -y nginx
cat > /etc/nginx/conf.d/default.conf <<EOF
server {
listen 80;
server_name ${HOSTNAME};
location / {
proxy_pass http://localhost:6000;
}
}
EOF
service nginx start
chkconfig nginx on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Now, access http://${HOSTNAME}
and finish the installation process. Easy!
# 安装Gogs
There are 6 ways to install Gogs:
- Install from binary (opens new window)
- Install from source (opens new window)
- Install from packages (opens new window)
- Ship with Docker (opens new window)
- Install with Vagrant (opens new window)
- Install with Kubernetes Using Helm Charts (opens new window)
这里为了方便起见, 我使用packages
包进行安装:
sudo wget -O /etc/yum.repos.d/gogs.repo \
https://dl.packager.io/srv/gogs/gogs/master/installer/el/7.repo
sudo yum install gogs
1
2
3
2
3
当然通过Docker
安装也十分简单快捷:
# Pull image from Docker Hub.
$ docker pull gogs/gogs
# Create local directory for volume.
$ mkdir -p /var/gogs
# Use `docker run` for the first time.
$ docker run --name=gogs -p 10022:22 -p 10080:3000 -v /var/gogs:/data gogs/gogs
# Use `docker start` if you have stopped it.
$ docker start gogs
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
# 参考资料
- gogs installation: https://github.com/gogs/gogs#-installation
- 使用 Gogs 搭建自己的 Git 服务器: https://blog.mynook.info/post/host-your-own-git-server-using-gogs/