20230115-Gogs入門到實踐

1.Git安裝

git安裝
# dnf install -y git

2.數(shù)據(jù)庫安裝(MySQL8)

依賴包安裝

# dnf -y install wget  cmake gcc gcc-c++ ncurses  ncurses-devel  libaio-devel  openssl openssl-devel perl

創(chuàng)建mysql用戶

# groupadd mysql
# useradd mysql -d /var/lib/mysql/ -g mysql
# tail -1  /etc/passwd
mysql:x:1000:1000::/var/lib/mysql/:/bin/bash

獲取mysql-8.0.31安裝包

# wget -c https://dev.mysql.com/get/mysql-8.0.31-1.el8.x86_64.rpm-bundle.tar
# tar -xvf mysql-8.0.31-1.el8.x86_64.rpm-bundle.tar

安裝mysql

# rpm -ivh mysql-community-common-8.0.31-1.el8.x86_64.rpm 
# rpm -ivh mysql-community-client-plugins-8.0.31-1.el8.x86_64.rpm 
# rpm -ivh mysql-community-libs-8.0.31-1.el8.x86_64.rpm 
# rpm -ivh mysql-community-client-8.0.31-1.el8.x86_64.rpm 
# rpm -ivh mysql-community-icu-data-files-8.0.31-1.el8.x86_64.rpm 
# rpm -ivh mysql-community-server-8.0.31-1.el8.x86_64.rpm 

初始化mysql數(shù)據(jù)庫

# mysqld --initialize --console

查看數(shù)據(jù)庫初始化密碼

# cat /var/log/mysqld.log  | grep localhost
2023-01-13T19:01:34.497431Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: yl)TpkEQj9B6

啟動mysql服務(wù)

# chmod 777 /var/lib/mysql/auto.cnf
# chown -R mysql:mysql /var/lib/mysql/
# systemctl start mysqld
# systemctl status mysqld
# systemctl enable mysqld

確認數(shù)據(jù)庫版本

# mysqladmin --version
mysqladmin  Ver 8.0.31 for Linux on x86_64 (MySQL Community Server - GPL)

確認mysql版本

# mysqladmin --version
mysqladmin  Ver 8.0.31 for Linux on x86_64 (MySQL Community Server - GPL)

修改mysql數(shù)據(jù)庫root密碼

# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.31

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.03 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> 

開啟開啟mysql的遠程訪問

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> 

3.安裝Gogs服務(wù)

創(chuàng)建git用戶

# groupadd git
# useradd git -d /home/git/ -g git
# tail -1  /etc/passwd
git:x:1001:1001::/home/git/:/bin/bash

下載Gogs安裝程序

# wget https://dl.gogs.io/0.12.9/gogs_0.12.9_linux_amd64.tar.gz
# tar xvf gogs_0.12.9_linux_amd64.tar.gz
# ll gogs
total 44560
-rwxrwxr-x 1 mysql mysql 45608848 Jun  8  2022 gogs
-rw-rw-r-- 1 mysql mysql     1054 Jun  8  2022 LICENSE
-rw-rw-r-- 1 mysql mysql     7021 Jun  8  2022 README.md
-rw-rw-r-- 1 mysql mysql     5372 Jun  8  2022 README_ZH.md
drwxrwxr-x 7 mysql mysql      112 Jun  8  2022 scripts

創(chuàng)建gogs數(shù)據(jù)庫并導(dǎo)入數(shù)據(jù)

# cd gogs/
# mysql -uroot -p < scripts/mysql.sql
Enter password: 

確認gogs數(shù)據(jù)庫

# mysql -uroot -p
Enter password: 
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| gogs               |
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.01 sec)
mysql> use gogs;
Database changed
mysql> show tables;
Empty set (0.00 sec)
mysql> exit

創(chuàng)建git用戶

# groupadd git
# useradd git -d /home/git/ -g git
# tail -1  /etc/passwd
git:x:1001:1001::/home/git/:/bin/bash

將gogs安裝包所有者改為git

# chown -R git:git ~/gogs
# mv ~/gogs /home/git/

配置gogs自啟動文件

# cp /home/git/gogs/scripts/systemd/gogs.service /lib/systemd/system/
# systemctl start gogs
# systemctl enable gogs
# systemctl status gogs

4.首次登錄Gogs,并配置

首次登錄Gogs:http://172.26.37.127:3000/ ,并配置

1)配置數(shù)據(jù)庫信息



2)配置應(yīng)用基本設(shè)置



3)配置可選設(shè)置

4)配置管理員用戶

5)確認配置文件

# cat /home/git/gogs/custom/conf/app.ini

6)登錄gogs

5.在Gogs中創(chuàng)建項目并利用

1)創(chuàng)建CMDB倉庫



2)first commit

$ git clone http://172.26.37.127:3000/luorf/CMDB.git
$ touch README.md
$ git init
$ git add README.md
$ git commit -m "first commit"
$ git remote add origin http://172.26.37.127:3000/luorf/CMDB.git
$ git push -u origin master

參考URL

https://gpu.xuandashi.com/31361.html
https://dev.mysql.com/downloads/mysql/
http://www.itdecent.cn/p/c25fba32b4f0
https://dev.mysql.com/doc/refman/8.0/en/server-option-variable-reference.html
https://blog.csdn.net/u013618714/article/details/126179117
https://gogs.io/
https://dl.gogs.io/
https://gogs.io/docs
https://blog.51cto.com/u_8406447/5769472

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容