CentOS安裝Gitea教程
簡介
Gitea是一個極易安裝,運行非常快速,安裝和使用體驗良好的自建Git服務。采用Go作為后端語言,這使得只要生成一個可執行程序即可。並且他還支持跨平台,支持Linux、macOS和Windows以及各種架構,除了x86,amd64,還包括ARM和 PowerPC。
Github地址:https://github.com/go-gitea/gitea
功能
- 支持活動時間線
- 支持SSH以及HTTP/HTTPS協議
- 支持SMTP、LDAP和反向代理的用戶認證
- 支持反向代理子路徑
- 支持用戶、組織和倉庫管理系統
- 支持添加和刪除倉庫協作者
- 支持倉庫和組織級別Web鈎子(包括Slack集成)
- 支持倉庫Git鈎子和部署密鑰
- 支持倉庫工單(Issue)、合並請求(Pull Request)以及Wiki
- 支持遷移和鏡像倉庫以及它的Wiki
- 支持在線編輯倉庫文件和Wiki
- 支持自定義源的Gravatar和Federated Avatar
- 支持郵件服務
- 支持后台管理面板
- 支持MySQL、PostgreSQL、SQLite3、MSSQL和TiDB(實驗性支持)數據庫
- 支持多語言本地化(21種語言)
二進制安裝
1、安裝MySQL數據庫
手動安裝數據庫方法不在這里說明,很簡單。恰巧我這個站長安了寶塔服務器管理面板。啥啥套件都一鍵安裝了。
寶塔可視化服務器面板安裝。
#Centos系統
yum install -y wget && wget -O install.sh http://download.bt.cn/install/install.sh && sh install.sh
#Ubuntu系統
wget -O install.sh http://download.bt.cn/install/install-ubuntu.sh && sudo bash install.sh
#Debian系統
wget -O install.sh http://download.bt.cn/install/install-ubuntu.sh && bash install.sh
安裝完成后,安裝MySQL,至少5.7版本。
2、安裝Git
先查看下內置的git版本,是否達到最新gitea的git版本要求。然后覺得是否升級。
#Debian和Ubuntu系統
apt-get -y install git
#CentOS系統
yum -y install git
3、安裝Gitea
添加執行權限
chmod +x /home/git/gitea/gitea
修改所有人
chown -R git:git /home/git/gitea /var/log/gitea
常見問題
1、進入ip:3000打不開網站
打不開需要關閉防火牆,或者打開對應的3000端口。
CentOS 7
systemctl stop firewalld.service
systemctl disable firewalld.service
其它系統
iptables -I INPUT -p tcp --dport 3000 -j ACCEPT
service iptables save
service iptables restart
2、保持程序一直運行
首先新建編輯下面這個文件
vi /etc/systemd/system/gitea.service
輸入下面配置文件
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
|
[Unit]
Description=Gitea (Git with a cup of tea)
After=syslog.target
After=network.target
After=mysqld.service
#After=postgresql.service
#After=memcached.service
#After=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
RestartSec=2s
Type=simple
User=git
Group=git
WorkingDirectory=/home/git/gitea
ExecStart=/home/git/gitea/gitea web
Restart=always
Environment=USER=git HOME=/home/git/gitea
[Install]
WantedBy=multi-user.target
|
之后執行
systemctl daemon-reload
sudo systemctl start gitea
如果服務不能啟動,你要注意的是下面幾點(systemctl status giea查看服務狀態,journalctl -b 0 -u gitea查看日志)
首先你的gitea放的目錄問題,因為使用git用戶啟動的服務,所以你的gitea所在目錄肯定要讓git用戶有訪問權限,所以root目錄下是不可以的
之后上面的配置參數你也要按照自己的環境目錄來寫,不要復制粘貼了,After=mysqld.service表示在mysql服務啟動之后再啟動gitea服務,所以這個根據你的數據庫來選擇去掉哪個注釋
服務操作相關命令
查看服務列表與狀態
systemctl list-units --type=service
啟動一個服務:
systemctl start postfix.service
關閉一個服務:
systemctl stop postfix.service
重啟一個服務:
systemctl restart postfix.service
顯示一個服務的狀態:
systemctl status postfix.service
在開機時啟用一個服務:systemctl enable postfix.service
在開機時禁用一個服務:systemctl disable postfix.service
查看服務是否開機啟動: systemctl is-enabled postfix.service
查看已啟動的服務列表: systemctl list-unit-files | grep enabled
查看啟動失敗的服務列表: systemctl --failed
轉載請注明:天狐博客 » CentOS安裝Gitea教程