title: 使用gitea搭建Git服務
date: 2020-05-20 13:14:00
tags: [Git]
categories: [Git]
前情提示
阿里、tx、西數centOS6.4,6系列均可cat /etc/redhat-release
gitea1.12
Git 2.26.2最新穩定版本;
MySQL8社區版:mysql-8.0.20-1.el6.x86_64.rpm-bundle.tar;
廢話說在前面
已從gogs轉移至gitea。爲什麼?這麼說吧,給你個Google pixel手機(原生安卓系統),一個小米手機(基於Android,定製化,更人性)。哪個用的舒服?gitea和其他對比,可以看官網橫向對比。gitea的好可以自己看官網特性,這裏不再贅述。
至於爲什麼換成gitea,當初因爲組織團隊權限推送問題和批量綁定倉庫問題,這兩點gogs是沒有的,另外,兩者個人感覺都活躍,gitea更加頻繁,畢竟是社區化的合作開發。
兩者都有try,自己體驗,嘗試。
更新說明
- 去除普通圖片截圖,保留部分核心截圖;詳細截圖可參考:https://blog.csdn.net/qq_31708763/article/details/104814669
- gitea1.11.5到1.12從80M到120M,看來更新不少。
- 本文僅內部搭建環境使用,本文不再更新,有問題留言,或移步新地址。
軟件準備
軟件下載,官網下載或雲盤下載。步驟略。
將下載好的軟件上傳到服務器。
mkdir -p /server/backup/gs
# scp -P 22000 -r -v /server/backup/gs/* [email protected]:/server/backup/gs
scp -P 22 -r -v /server/backup/gs/* [email protected]:/server/backup/gs
# scp -P 22 -r -v /server/backup/gs/gitea-1.12-linux-amd64 [email protected]:/server/backup/gs
#如果重裝
ssh-keygen -R 59.110.21.159
更新yum(可選)
yum -y update
swap創建(可選)
sudo dd if=/dev/zero of=/swapfile count=2048 bs=1M
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
free -m
history | grep 'swap'
刪除
1. 停止正在使用的swap分區
$ swapoff /root/swap
2. 刪除swap分區文件
$ rm /root/swap
3. 刪除或註釋在/etc/fstab文件中的以下開機自動掛載內容:
$ vim /etc/fstab 在該文件中刪除如下內容
更新內核
gitea必須,否則centos6下報錯:kernel too old。
解決:https://janeyork.blog.csdn.net/article/details/106496370
MySQL安裝
rpm -qa|grep mysql
# 如果有,卸載
yum -y remove mysql mysql-server mysql-libs compat-mysql51
rm -rf /var/lib/mysql
##可能cannot remove ‘/etc/my.cnf’: No such file or directory
rm /etc/my.cnf
rpm -e mysql-community-client-8.0.20-1.el6.x86_64 --nodeps
rpm -e mysql-community-libs-8.0.20-1.el6.x86_64 --nodeps
rpm -e mysql-community-server-8.0.20-1.el6.x86_64 --nodeps
rpm -e mysql-community-common-8.0.20-1.el6.x86_64 --nodeps
安裝依賴
yum -y install wget gcc-c++ ncurses ncurses-devel cmake make perl bison openssl openssl-devel gcc* libxml2 libxml2-devel curl-devel libjpeg* libpng* freetype* make gcc-c++ cmake bison-devel ncurses-devel bison perl perl-devel perl perl-devel net-tools* numactl*
安裝MySQL
cd /server/backup/gs/
rpm -ivh mysql-community-common-8.0.20-1.el6.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-libs-8.0.20-1.el6.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-client-8.0.20-1.el6.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-server-8.0.20-1.el6.x86_64.rpm --nodeps --force
配置/etc/my.cnf,添加如下:
lower_case_table_names=1
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'
完整內容:
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
lower_case_table_names=1
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'
啓動:
groupadd mysql
useradd -g mysql mysql
mkdir -p /var/lib/mysql
mysqld --initialize --user=mysql
chown -R mysql:mysql /var/lib/mysql
chmod -R 777 /var/lib/mysql
centOS6:
service mysqld start
查看啓動狀態
service mysqld status
# 設置開機啓動(可不用,rmp安裝完,默認自啓)
# chkconfig mysqld on
以下爲備份內容,並未執行:
如果以root用戶身份登錄CentOS 6.8服務器,可以執行如下命令。
mysqld --initialize --user=mysql
mysqld --initialize-insecure --user=mysql
如果以mysql用戶身份登錄CentOS 6.8服務器,可以執行如下命令。
mysqld --initialize
mysqld --initialize-insecure
因爲我這裏使用的是root賬戶登錄CentOS 6.8服務器,所以,初始化數據庫時,我執行的是如下命令。
mkdir -p /usr/local/mysql
chown -R mysql.mysql /usr/local/mysql
mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
注意:這裏,我在執行mysqld --initialize命令時,指定了MySQL的安裝目錄。 在MySQL的安裝過程中,建議指定MySQL的安裝目錄。當/usr/local/mysql目錄下存在data目錄時,會初始化失敗,必須確保/usr/local/mysql下沒有data目錄。
查看臨時生成的密碼:
cat /var/log/mysqld.log | grep password
修改初始密碼:
mysql -u root -p
DhPO0Wr-#kqp
# 高版本數據庫使用強密碼規則,密碼設置儘可能麻煩,大寫+小寫+數字+符號
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Woshihenfuzademima$_$';
exit;
創建遠程賬號:
mysql -u root -p
Woshihenfuzademima$_$
CREATE USER 'remote'@'%' IDENTIFIED BY 'Woshihenfuzademima$_$';
GRANT ALL PRIVILEGES ON *.* TO 'remote'@'%'WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit;
配置防火牆
vi /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22000 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3000 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3001 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 4000 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 9527 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
修改完成後,重啓防火牆:service iptables restart
,如果有必要,請登錄雲安全組開放端口。
說明:rpm方式安裝mysql默認位置:
1、數據庫目錄
/var/lib/mysql/
2、配置文件
/usr/share/mysql(mysql.server命令及配置文件)
3、相關命令
/usr/bin(mysqladmin mysqldump等命令)
4、啓動腳本
/etc/rc.d/init.d/(啓動腳本文件mysql的目錄)
Git安裝
卸載舊版本:
查看源版本信息:
yum info git
git --version
如果安裝了,卸載:
yum remove git
安裝依賴:
yum install -y asciidoc docbook2X xmlto texinfo sgml2xml autoconf openjade curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
上傳git安裝包,並解壓:
cd /server/backup/gs/
tar -zxvf git-2.26.2.tar.gz
cd git-2.26.2
make configure
./configure --prefix=/usr/local/git
make && make install
sudo echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/profile
source /etc/profile
驗證Git是否安裝成功:
輸入git --version試試安裝成功。
Gitea安裝
創建git用戶:
sudo useradd git
創建gitea,mysql用戶密碼,專門用於gitea本地訪問:
mysql -u root -p
Woshihenfuzademima$_$
CREATE USER 'gitea'@'localhost' IDENTIFIED BY 'Woshihenfuzademima$_$';
GRANT ALL PRIVILEGES ON *.* TO 'gitea'@'localhost'WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit;
# 高版本建庫或者導入gitea.mysql.sql都會報錯,建議手動建
#SET GLOBAL innodb_file_per_table = ON,innodb_file_format = Barracuda,innodb_large_prefix = ON;
# DROP DATABASE IF EXISTS gitea;
# CREATE DATABASE IF NOT EXISTS gitea CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
手動創建數據庫(導入gitea自帶sql文件報錯,0.13版本修復):
新建數據庫,這裏建議直接新建數據庫,設置好編碼格式utf8mb4,上面我們不是用navicate測試遠程鏈接了嗎,最好使用客戶端進行直接新建數據庫gitea,
上傳二進制文件。
mkdir /home/git/gitea
chown -R git:git /home/git/gitea
# wget -O gitea https://dl.gitea.io/gitea/1.12/gitea-1.12-linux-amd64
mv /server/backup/gs/gitea-1.12-linux-amd64 /home/git/gitea/gitea
chmod +x /home/git/gitea/gitea
chown -R git:git /home/git/gitea/gitea
安裝:
cd /home/git/gitea/
su git
./gitea web --port 3001
# 或者./gitea web 別問我爲啥指定端口,因爲3000佔用了,或者你臨時把3000停止
211.149.239.182:3001
59.110.21.159:3001
安裝完成:根據頁面填寫參數:
APP_NAME = Git
RUN_USER = git
RUN_MODE = prod
[oauth2]
JWT_SECRET = 2n0Rpw8v2KZ4pnGeIPpQX5bLrhNepBOgMSg
[security]
INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE1ODk5OTQwMzh9.5RMyVTbX4M5FycJOwtf8oO4DH87N38fHui-NbItoaVY
INSTALL_LOCK = true
SECRET_KEY = fZA30Uegc1Gt6pUTYBej7ahOoL7GPNR6Tl4ZgFkT3xgdkZuNLRJb3icWD
[database]
DB_TYPE = mysql
HOST = 127.0.0.1:3306
NAME = gitea
USER = gitea
PASSWD = Woshihenfuzademima$_$
SCHEMA =
SSL_MODE = disable
CHARSET = utf8mb4
PATH = /home/git/gitea/data/gitea.db
[repository]
ROOT = /home/git/gitea-repositories
[server]
SSH_DOMAIN = git.yourdomain.com
DOMAIN = git.yourdomain.com
HTTP_PORT = 3001
ROOT_URL = http://git.yourdomain.com:3001/
DISABLE_SSH = false
SSH_PORT = 22
LFS_START_SERVER = true
LFS_CONTENT_PATH = /home/git/gitea/data/lfs
LFS_JWT_SECRET = JGZ83tOyD4gcR5q3F6Odc7rajn_b3_mJdr_t2xEcKVQ
OFFLINE_MODE = false
[mailer]
ENABLED = false
[service]
REGISTER_EMAIL_CONFIRM = false
ENABLE_NOTIFY_MAIL = false
DISABLE_REGISTRATION = false
ALLOW_ONLY_EXTERNAL_REGISTRATION = false
ENABLE_CAPTCHA = false
REQUIRE_SIGNIN_VIEW = false
DEFAULT_KEEP_EMAIL_PRIVATE = false
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
DEFAULT_ENABLE_TIMETRACKING = true
NO_REPLY_ADDRESS = noreply.localhost
[picture]
DISABLE_GRAVATAR = false
ENABLE_FEDERATED_AVATAR = true
[openid]
ENABLE_OPENID_SIGNIN = true
ENABLE_OPENID_SIGNUP = true
[session]
PROVIDER = file
[log]
MODE = file
LEVEL = info
ROOT_PATH = /home/git/gitea/log
加入開機啓動:su root(此處默認執行了以下,因爲gogs有問題,怕也有問題)
ln -s /usr/local/git/bin/git /bin/git
ln -s /usr/local/git/bin/git-upload-pack /bin/git-upload-pack
ln -s /usr/local/git/bin/git-cvsserver /bin/git-cvsserver
ln -s /usr/local/git/bin/gitk /bin/gitk
ln -s /usr/local/git/bin/git-receive-pack /bin/git-receive-pack
ln -s /usr/local/git/bin/git-shell /bin/git-shell
ln -s /usr/local/git/bin/git-upload-archive /bin/git-upload-archive
https://github.com/go-gitea/gitea/blob/master/contrib/init/centos/gitea
# su root
mkdir -p /home/git/gitea/myscripts/init/centos/
vi /home/git/gitea/myscripts/init/centos/gitea
文件內容下文。
centOS6:
cp /home/git/gitea/myscripts/init/centos/gitea /etc/rc.d/init.d/
chmod a+x /etc/rc.d/init.d/gitea
chkconfig gitea on
service gitea start #啓動服務
service gitea stop #停止服務
service gitea restart #重啓服務
## 另一種臨時啓動可以進入安裝目錄~/gitea,執行:
./gitea web 不過這是關閉窗口就隨之關閉
文本內容:
#!/bin/sh
#
# /etc/rc.d/init.d/gitea
#
# Runs the Gitea Git with a cup of tea.
#
#
# chkconfig: - 85 15
#
### BEGIN INIT INFO
# Provides: gitea
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start gitea at boot time.
# Description: Control gitea.
### END INIT INFO
# Source function library.
. /etc/init.d/functions
# Default values
NAME=gitea
GITEA_HOME=/home/git/${NAME}
GITEA_PATH=/home/git/gitea/${NAME}
GITEA_USER=git
SERVICENAME="Gitea - Git with a cup of tea"
LOCKFILE=/var/lock/subsys/gitea
LOGPATH=${GITEA_HOME}/log
LOGFILE=${LOGPATH}/gitea.log
RETVAL=0
# Read configuration from /etc/sysconfig/gitea to override defaults
[ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
# Don't do anything if nothing is installed
[ -x ${GITEA_PATH} ] || exit 0
# exit if logpath dir is not created.
[ -x ${LOGPATH} ] || exit 0
DAEMON_OPTS="--check $NAME"
# Set additional options, if any
[ ! -z "$GITEA_USER" ] && DAEMON_OPTS="$DAEMON_OPTS --user=${GITEA_USER}"
start() {
cd ${GITEA_HOME}
echo -n "Starting ${SERVICENAME}: "
daemon $DAEMON_OPTS "${GITEA_PATH} web -c /home/git/gitea/custom/conf/app.ini > ${LOGFILE} 2>&1 &"
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${LOCKFILE}
return $RETVAL
}
stop() {
cd ${GITEA_HOME}
echo -n "Shutting down ${SERVICENAME}: "
killproc ${NAME}
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${LOCKFILE}
}
case "$1" in
start)
status ${NAME} > /dev/null 2>&1 && exit 0
start
;;
stop)
stop
;;
status)
status ${NAME}
;;
restart)
stop
start
;;
reload)
stop
start
;;
*)
echo "Usage: ${NAME} {start|stop|status|restart}"
exit 1
;;
esac
exit $RETVAL
Nginx安裝
下載上傳文件。
安裝依賴:
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
# 如果已經安裝,卸載原來的Nginx
find -name nginx
yum -y remove nginx
解壓安裝:
# 解壓
cd /server/backup/gs/
tar -vxf nginx-1.18.0.tar.gz
cd nginx-1.18.0
# 指定位置安裝並且開啓ssl
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
whereis nginx
安裝完成截圖:
配置環境變量:
vim /etc/profile
##### nginx #####
export NGINX_HOME=/usr/local/nginx
export PATH=$NGINX_HOME/sbin:$PATH
# 使配置立即生效
source /etc/profile
# 測試是否生效
echo $PATH
/usr/local/nginx/sbin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
nginx -s reload
nginx -v
nginx -t
開機啓動:
# 加入開機自啓
vi /etc/rc.local
/usr/local/nginx/sbin/nginx
chmod 755 /etc/rc.local
# 測試配置文件
/usr/local/nginx/sbin/nginx -t
Nginx配置SSL
獲取證書,上傳服務器。
配置Nginx.cnf:/usr/local/nginx/conf
server_name git.yourdomain.com;
ssl_certificate /usr/local/nginx/cert/_.shidongvr.com_chain.crt;
ssl_certificate_key /usr/local/nginx/cert/_.shidongvr.com_key.key;
INSTALL_LOCK = true
SECRET_KEY = Y81DPGiSppsWRED
Nginx配置文件
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
client_max_body_size 1024M;
client_body_buffer_size 10M;
server {
listen 443 ssl;
server_name git.yourdomain.com;
ssl_certificate /usr/local/nginx/cert/_.shidongvr.com_chain.crt;
ssl_certificate_key /usr/local/nginx/cert/_.shidongvr.com_key.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
proxy_set_header Host $host:3001;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass https://127.0.0.1:3001;
}
location /zhds {
alias /home/zhds/1;
index index.html;
}
}
server {
listen 80;
server_name git.yourdomain.com;
#charset koi8-r;
#access_log logs/host.access.log main;
# location / {
# proxy_pass http://127.0.0.1:3000;
# }
# 強制跳轉https
rewrite ^(.*) https://$server_name$1 permanent;
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
server {
listen 80;
server_name nb.nogit.top;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
# proxy_pass http://127.0.0.1:3000;
root /home/myblog/public;
index index.html;
}
# 強制跳轉https
rewrite ^(.*) https://$server_name$1 permanent;
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
Gitea配置文件
https://github.com/go-gitea/gitea/blob/master/custom/conf/app.ini.sample
https://docs.gitea.io/zh-cn/config-cheat-sheet/
# 應用名稱,改成自己的或者公司名稱
APP_NAME = Git
RUN_USER = git
RUN_MODE = prod
[repository]
ROOT = /home/git/gitea-repositories
# 強制所有倉庫私有
FORCE_PRIVATE = false
# 全局最大每個用戶創建的git工程數目, -1 表示都沒限制,0超管不影響
MAX_CREATION_LIMIT = 0
# 禁用http,只能通過ssh協議操作
DISABLE_HTTP_GIT = false
[ui]
# 默認主題
DEFAULT_THEME = gitea
# 主題,覆蓋默認
THEMES = gitea,arc-green
[ui.meta]
AUTHOR = Git
DESCRIPTION = Hi PGZ!
KEYWORDS = go,git,self-hosted,pgz
[server]
PROTOCOL = https
DOMAIN = git.yourdomain.com
HTTP_PORT = 3001
ROOT_URL = https://git.yourdomain.com/
# 禁用SSH
DISABLE_SSH = false
START_SSH_SERVER = false
SSH_DOMAIN = git.yourdomain.com
SSH_PORT = 22
OFFLINE_MODE = false
CERT_FILE=/usr/local/nginx/cert/_.shidongvr.com_chain.crt
KEY_FILE=/usr/local/nginx/cert/_.shidongvr.com_key.key
# ENABLE_GZIP = true
# Landing page, can be "home", "explore", "organizations" or "login"
LANDING_PAGE = login
LFS_START_SERVER = true
LFS_CONTENT_PATH = /home/git/gitea/data/lfs
LFS_JWT_SECRET = JGZ83tOyD4gcR5q3F6Odc7rajn_b3_mJdr_t2xEcKVQ
[database]
DB_TYPE = mysql
HOST = 127.0.0.1:3306
NAME = gitea
USER = gitea
PASSWD = Woshihenfuzademima$_$
SCHEMA =
# For MySQL, either "false" (default), "true", or "skip-verify"
SSL_MODE = disable
CHARSET = utf8mb4
PATH = /home/git/gitea/data/gitea.db
[admin]
# 禁用普通用戶創建組織
DISABLE_REGULAR_ORG_CREATION = true
[security]
INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE1ODk5OTQwMzh9.5RMyVTbX4M5FycJOwtf8oO4DH87N38fHui-NbItoaVY
INSTALL_LOCK = true
SECRET_KEY = fZA30Uegc1GtaHX9cNL6pUTYBej7ahOoL7GPNR6Tl4ZgFkT3xgdkZuNLRJb3icWD
# How long to remember that a user is logged in before requiring relogin (in days)
LOGIN_REMEMBER_DAYS = 7
[openid]
ENABLE_OPENID_SIGNIN = false
ENABLE_OPENID_SIGNUP = false
[service]
# 登錄驗證碼失效時間,單位分鐘。
# ACTIVE_CODE_LIVE_MINUTES = 180
REGISTER_EMAIL_CONFIRM = false
# 是否發送工單創建等提醒郵件,需要 Mailer 被激活
ENABLE_NOTIFY_MAIL = false
# 禁用註冊,啓用後只能用管理員添加用戶
DISABLE_REGISTRATION = true
ALLOW_ONLY_EXTERNAL_REGISTRATION = false
# 註冊時使用圖片驗證碼
ENABLE_CAPTCHA = false
# 是否所有頁面都必須登錄後纔可訪問
REQUIRE_SIGNIN_VIEW = true
DEFAULT_KEEP_EMAIL_PRIVATE = false
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
DEFAULT_ENABLE_TIMETRACKING = true
NO_REPLY_ADDRESS = noreply.localhost
# 是否顯示註冊按鈕
SHOW_REGISTRATION_BUTTON = false
[mailer]
ENABLED = false
[session]
# Session 內容存儲方式,可選 memory, file, redis 或 mysql
PROVIDER = file
# 如果是文件,那麼這裏填根目錄;其他的要填主機地址和端口。
# PROVIDER_CONFIG = data/sessions
[picture]
# 開啓則只使用內部頭像
DISABLE_GRAVATAR = false
ENABLE_FEDERATED_AVATAR = true
[log]
MODE = file
LEVEL = info
ROOT_PATH = /home/git/gitea/log
[api]
# Enables Swagger. True or false; default is true.
ENABLE_SWAGGER = false
[oauth2]
# ENABLE = false
JWT_SECRET = 2n0Rpw8v2KZ43D3V5nXzpnGeIPpQX5bLrhNepBOgMSg
[other]
SHOW_FOOTER_BRANDING = false
SHOW_FOOTER_VERSION = false
SHOW_FOOTER_TEMPLATE_LOAD_TIME = true
額外
卸載jdk(如果需要)
rpm -e --nodeps java_cup-0.10k-5.el6.x86_64
rpm -e --nodeps java-1.5.0-gcj-1.5.0.0-29.1.el6.x86_64
rpm -e --nodeps gcc-java-4.4.7-23.el6.x86_64
配置gitea模板
tips:簡單配置,0.13後會移除首頁footer部分。目前測試自定義模板暫時不管用,可採用直接更改源碼,儘量微改動。
/home/git/gitea/templates/base
去掉頂部幫助鏈接:
mkdir -p /home/git/gitea/custom/templates/base
更改並上傳head_navbar.tmpl
然後重啓gitea
禁止搜索引擎收錄(可選)
默認情況下Gitea開啓了搜索引擎收錄(截止1.12版本官網doc),不過也無所謂,反正需要登錄可看。
在/home/git/gitea/custom
目錄下新建文件robots.txt
,
vi /home/git/gitea/custom/robots.txt
內容如下:
User-agent: *
Disallow: /home/git/gitea/
Gitea自定義頁面備份
提示:不同版本,文件內容不同,請使用相應版本!!!
https://www.yuque.com/docs/share/290c267a-e455-4c3f-a9fc-54dfa45872d9?#
Gitea的優勢
個人總結:低配也可運行、核心功能有,夠用、社區活躍,更新快
官網不完全橫向對比:https://docs.gitea.io/zh-cn/comparison/
軟件包備用下載地址
網盤有。鏈接:https://pan.baidu.com/s/17TlJyl7VzHzdYmWwo_sVhQ
提取碼:1ihq