commit(auto)
This commit is contained in:
parent
f08aa666c0
commit
8efc34bef9
4 changed files with 233 additions and 1 deletions
229
content/20240215215031 Raspi4にGiteaをインストール.md
Executable file
229
content/20240215215031 Raspi4にGiteaをインストール.md
Executable file
|
@ -0,0 +1,229 @@
|
|||
# 20240215215031 Raspi4にGiteaをインストール
|
||||
#raspi #gitea #cloudflare
|
||||
|
||||
#### Giteaとは
|
||||
[Documentation | Gitea Documentation](https://docs.gitea.com/)
|
||||
Git+いろいろでgithubのような便利な機能があるやつ。
|
||||
> Gitea is a painless self-hosted all-in-one software development service, it includes Git hosting, code review, team collaboration, package registry and CI/CD. It is similar to GitHub, Bitbucket and GitLab. Gitea was forked from [Gogs](http://gogs.io/) originally and almost all the code has been changed. See the [Gitea Announcement](https://blog.gitea.com/welcome-to-gitea/) blog post to read about the justification for a fork.
|
||||
|
||||
|
||||
#### インストール
|
||||
goが必要。 [[20240205152229 raspi4にgoをインストールする |raspi4にgoをインストールする]]
|
||||
|
||||
[Installation from binary | Gitea Documentation](https://docs.gitea.com/installation/install-from-binary) を見ながらやる。
|
||||
Binary installをする。バイナリは [Gitea | gitea](https://dl.gitea.com/gitea/) から、あたらし目のやつをダウンロード。
|
||||
raspi4なので linux-arm64 を選ぶ。20240215 時点では、
|
||||
`gitea-1.21.5-linux-arm64` が最新だった。
|
||||
|
||||
```
|
||||
$ wget https://dl.gitea.com/gitea/1.21.5/gitea-1.21.5-linux-arm64
|
||||
$ wget https://dl.gitea.com/gitea/1.21.5/gitea-1.21.5-linux-arm64.asc
|
||||
$ chmod a+x ./gitea-1.21.5-linux-arm64
|
||||
```
|
||||
|
||||
##### GPG
|
||||
```
|
||||
$ gpg --keyserver keys.openpgp.org --recv 7C9E68152594688862D62AF62D9AE806EC1592E2
|
||||
gpg: directory '/home/kazbo/.gnupg' created
|
||||
gpg: keybox '/home/kazbo/.gnupg/pubring.kbx' created
|
||||
gpg: /home/kazbo/.gnupg/trustdb.gpg: trustdb created
|
||||
gpg: key 2D9AE806EC1592E2: public key "Teabot <teabot@gitea.io>" imported
|
||||
gpg: Total number processed: 1
|
||||
gpg: imported: 1
|
||||
```
|
||||
|
||||
```
|
||||
gitea@saipi4:~ $ gpg --verify gitea-1.21.5-linux-arm64.asc gitea-1.21.5-linux-arm64
|
||||
gpg: Signature made Thu 01 Feb 2024 21:18:18 JST
|
||||
gpg: using RSA key CC64B1DB67ABBEECAB24B6455FC346329753F4B0
|
||||
gpg: Good signature from "Teabot <teabot@gitea.io>" [unknown]
|
||||
gpg: WARNING: This key is not certified with a trusted signature!
|
||||
gpg: There is no indication that the signature belongs to the owner.
|
||||
Primary key fingerprint: 7C9E 6815 2594 6888 62D6 2AF6 2D9A E806 EC15 92E2
|
||||
Subkey fingerprint: CC64 B1DB 67AB BEEC AB24 B645 5FC3 4632 9753 F4B0
|
||||
```
|
||||
|
||||
|
||||
##### git(入ってなかったら入れる)
|
||||
```
|
||||
gitea@saipi4:~ $ sudo apt install git
|
||||
```
|
||||
|
||||
##### ユーザー git を作成
|
||||
```
|
||||
$ sudo adduser \
|
||||
--system \
|
||||
--shell /bin/bash \
|
||||
--gecos 'Git Version Control' \
|
||||
--group \
|
||||
--disabled-password \
|
||||
--home /home/git \
|
||||
git
|
||||
|
||||
Adding system user `git' (UID 108) ...
|
||||
Adding new group `git' (GID 114) ...
|
||||
Adding new user `git' (UID 108) with group `git' ...
|
||||
Creating home directory `/home/git' ...
|
||||
```
|
||||
|
||||
```
|
||||
$ sudo visudo
|
||||
```
|
||||
以下を追加
|
||||
```
|
||||
git ALL=(ALL:ALL) NOPASSWD:ALL
|
||||
```
|
||||
|
||||
##### Create required directory structure
|
||||
|
||||
書いてあるコマンドを実行するには、
|
||||
```
|
||||
$ sudo -i
|
||||
root@saipi4:~#
|
||||
```
|
||||
が必要
|
||||
```
|
||||
mkdir -p /var/lib/gitea/{custom,data,log}
|
||||
chown -R git:git /var/lib/gitea/
|
||||
chmod -R 750 /var/lib/gitea/
|
||||
mkdir /etc/gitea
|
||||
chown root:git /etc/gitea
|
||||
chmod 770 /etc/gitea
|
||||
```
|
||||
|
||||
##### Configure Gitea's working directory
|
||||
```
|
||||
$ sudo cp gitea-1.21.5-linux-arm64 /usr/local/bin/gitea
|
||||
```
|
||||
Adding bash/zsh autocompletion
|
||||
|
||||
Bashを使っているので
|
||||
```
|
||||
$ wget https://raw.githubusercontent.com/go-gitea/gitea/main/contrib/autocompletion/bash_autocomplete
|
||||
$ sudo cp ./bash_autocomplete /usr/share/bash-completion/completions/gitea
|
||||
```
|
||||
##### Running Gitea
|
||||
|
||||
以下を実行
|
||||
```
|
||||
$ sudo -u git GITEA_WORK_DIR=/var/lib/gitea/ /usr/local/bin/gitea web -c /etc/gitea/app.ini
|
||||
```
|
||||
これで設定画面が LAN内から見える。 自分の場合は `http://saipi4.local:3000/`
|
||||
うまくいっているのを確認したら `ctrl+c`で終了
|
||||
|
||||
サービス化
|
||||
[Run as service in Linux | Gitea Documentation](https://docs.gitea.com/installation/linux-service) を見ながらやる。
|
||||
|
||||
```
|
||||
$ wget https://raw.githubusercontent.com/go-gitea/gitea/release/v1.21/contrib/systemd/gitea.service
|
||||
$ sudo cp ./gitea.service /etc/systemd/system/
|
||||
$ sudo systemctl daemon-reload
|
||||
$ sudo systemctl enable gitea
|
||||
Created symlink /etc/systemd/system/multi-user.target.wants/gitea.service → /etc/systemd/system/gitea.service.
|
||||
$ sudo systemctl start gitea
|
||||
$ sudo systemctl status gitea
|
||||
● gitea.service - Gitea (Git with a cup of tea)
|
||||
Loaded: loaded (/etc/systemd/system/gitea.service; enabled; preset: enabled)
|
||||
Active: active (running) since Thu 2024-02-15 16:47:29 JST; 4s ago
|
||||
Main PID: 5531 (gitea)
|
||||
Tasks: 9 (limit: 3918)
|
||||
CPU: 1.059s
|
||||
CGroup: /system.slice/gitea.service
|
||||
└─5531 /usr/local/bin/gitea web --config /etc/gitea/app.ini
|
||||
|
||||
Feb 15 16:47:29 saipi4 gitea[5531]: 2024/02/15 16:47:29 cmd/web.go:111:showWebStartupMessage() [I] Gitea version: 1.21.>
|
||||
Feb 15 16:47:29 saipi4 gitea[5531]: 2024/02/15 16:47:29 cmd/web.go:112:showWebStartupMessage() [I] * RunMode: prod
|
||||
Feb 15 16:47:29 saipi4 gitea[5531]: 2024/02/15 16:47:29 cmd/web.go:113:showWebStartupMessage() [I] * AppPath: /usr/loca>
|
||||
Feb 15 16:47:29 saipi4 gitea[5531]: 2024/02/15 16:47:29 cmd/web.go:114:showWebStartupMessage() [I] * WorkPath: /var/lib>
|
||||
Feb 15 16:47:29 saipi4 gitea[5531]: 2024/02/15 16:47:29 cmd/web.go:115:showWebStartupMessage() [I] * CustomPath: /var/l>
|
||||
Feb 15 16:47:29 saipi4 gitea[5531]: 2024/02/15 16:47:29 cmd/web.go:116:showWebStartupMessage() [I] * ConfigFile: /etc/g>
|
||||
Feb 15 16:47:29 saipi4 gitea[5531]: 2024/02/15 16:47:29 cmd/web.go:117:showWebStartupMessage() [I] Prepare to run insta>
|
||||
Feb 15 16:47:29 saipi4 gitea[5531]: 2024/02/15 16:47:29 cmd/web.go:304:listen() [I] Listen: http://0.0.0.0:3000
|
||||
Feb 15 16:47:29 saipi4 gitea[5531]: 2024/02/15 16:47:29 cmd/web.go:308:listen() [I] AppURL(ROOT_URL): http://localhost:>
|
||||
Feb 15 16:47:29 saipi4 gitea[5531]: 2024/02/15 16:47:29 ...s/graceful/server.go:70:NewServer() [I] Starting new Web ser>
|
||||
lines 1-19/19 (END)
|
||||
```
|
||||
再びLAN内からアクセスしてみる。 大丈夫そうならOK。
|
||||
**保存とかはしない!**
|
||||
|
||||
|
||||
nginxの設定に `/git` を追加
|
||||
```
|
||||
$ sudo nano /etc/nginx/sites-available/default
|
||||
```
|
||||
|
||||
```
|
||||
# gitea
|
||||
# https://docs.gitea.com/administration/reverse-proxies
|
||||
location /gitea/ {
|
||||
client_max_body_size 512M;
|
||||
|
||||
# make wnginx use unescaped URI, keep "%2F" as is
|
||||
rewrite ^ $request_uri;
|
||||
rewrite ^/gitea(/.*) $1 break;
|
||||
proxy_pass http://127.0.0.1:3000$uri;
|
||||
proxy_set_header Connection $http_connection;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
```
|
||||
nginxを一回止める
|
||||
```
|
||||
$ sudo systemctl stop nginx
|
||||
```
|
||||
|
||||
gteaの設定を削除(もしあれば)
|
||||
```
|
||||
$ sudo rm /etc/gitea/app.ini
|
||||
$ sudo rm /var/lib/gitea/data/gitea.db
|
||||
```
|
||||
|
||||
|
||||
必要ならトンネルを追加。
|
||||
```
|
||||
- hostname: gitea.kinoshita-lab.org
|
||||
service: http://localhost
|
||||
```
|
||||
結局こうやっても、
|
||||
https://gitea.kinoshita-lab.org/gitea/
|
||||
でアクセスすることになり微妙。
|
||||
|
||||
giteaの起動
|
||||
|
||||
```
|
||||
$ sudo systemctl start gitea
|
||||
```
|
||||
|
||||
`http://[サーバー]:3000` にアクセス
|
||||
|
||||
変更した所は以下
|
||||
- データベースのタイプ: SQLite3
|
||||
- サイトタイトル: ...
|
||||
- サーバードメイン: pi4.kinoshita-lab.org **「ssh」サーバーのドメイン」であることに注意**
|
||||
- SSHサーバーのポート: `*****`
|
||||
- GiteaのベースURL: https://gitea.kinoshita-lab.org/gitea/ **ここ重要**
|
||||
- 「アップデートチェッカーを有効にする」: check.
|
||||
|
||||
と設定して、 "Giteaをインストール" ボタンを押す。
|
||||
この後は localhost:3000 ではアクセスできないので、こうなる
|
||||
![[Pasted image 20240215205432.png| 250]]
|
||||
nginxをrestart
|
||||
|
||||
GiteaのベースURL で設定したURLにアクセス。
|
||||
|
||||
こんな感じなら成功。
|
||||
|
||||
![[Pasted image 20240215212253.png|500]]
|
||||
アカウントを作る。最初に登録した人は管理者になるっぽい。
|
||||
|
||||
SSHキーの登録
|
||||
作成、サインインしたら自分のアイコン->設定
|
||||
SSH/PGPキー をクリック SSHキーの管理 -> [[20240204222141 sshを公開鍵認証にする|sshを公開鍵認証にする]] で設定したキーをコピペ
|
||||
|
||||
|
||||
|
||||
### cf.
|
||||
- [Reverse Proxies | Gitea Documentation](https://docs.gitea.com/administration/reverse-proxies) Nginx with a sub-pathの所
|
BIN
content/assets/Pasted image 20240215205717.png
Executable file
BIN
content/assets/Pasted image 20240215205717.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 98 KiB |
BIN
content/assets/Pasted image 20240215212253.png
Executable file
BIN
content/assets/Pasted image 20240215212253.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 114 KiB |
|
@ -13,7 +13,10 @@ kazboことKaz(uki) Saita/斉田一樹の書きちらかしたメモが堆積し
|
|||
ここに書かれている内容は、できるだけ有用で普遍性があるように努力はしていますが、時期や状況により、たまたまうまくいったことなども書かれています。やってみてうまくいかないことはありえます。
|
||||
|
||||
できるかぎりリンク切れが無いように整備していますが、時々無い記事もあるかもしれません。
|
||||
ddd
|
||||
|
||||
変更のテストだよ。
|
||||
|
||||
|
||||
### 方針のようなもの
|
||||
- [[20240122201309 全体的な書き方の方針|全体的な書き方の方針]]
|
||||
- [[000000000002 メモ ノートの書き方|メモ ノートの書き方]]
|
||||
|
|
Loading…
Reference in a new issue