管理员 发布的文章

教程 | win10上编译安装lapack库


摘要

项目依赖环境太多,需要一个一个编译安装然后再做依赖,正好一个一个记录一下过程和出现的问题。

安装mingw

教程:win10上安装mingw

下载lapack库

lapack官网
lapack官网下载列表
lapck-3.11.tar.gz直接下载地址(github)
lapack-3.11.tar.gz本站下载地址

cmake配置

  1. Configure 选中 MinGW Makefiles
  2. 处理配置项
    屏幕截图 2023-10-28 144757.jpg
  3. Configure && Generate

编译及安装

1. cd build目录
2. mingw32-make.exe -j 8
3. mingw32-make.exe -j 8 install

屏幕截图 2023-10-28 143234.jpg

报错处理(多重定义问题)

[ 14%] Building Fortran object SRC/CMakeFiles/lapack64.dir/zlassq.f90.obj
[ 14%] Linking Fortran shared library ..\bin\liblapack64.dll
E:/program/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/libgfortran.a(string_intrinsics.o):(.text$_gfortran_concat_string+0x0): multiple definition of `_gfortran_concat_string'
../lib/libblas64.dll.a(d000008.o):(.text+0x0): first defined here
E:/program/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/libgfortran.a(string_intrinsics.o):(.text$_gfortran_string_len_trim+0x0): multiple definition of `_gfortran_string_len_trim'
../lib/libblas64.dll.a(d000038.o):(.text+0x0): first defined here
E:/program/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/libgfortran.a(transfer.o):(.text$_gfortran_transfer_integer_write+0x0): multiple definition of `_gfortran_transfer_integer_write'
../lib/libblas64.dll.a(d000058.o):(.text+0x0): first defined here
E:/program/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/libgfortran.a(transfer.o):(.text$_gfortran_transfer_character_write+0x0): multiple definition of `_gfortran_transfer_character_write'
../lib/libblas64.dll.a(d000053.o):(.text+0x0): first defined here
E:/program/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/libgfortran.a(transfer.o):(.text$_gfortran_st_write+0x0): multiple definition of `_gfortran_st_write'
../lib/libblas64.dll.a(d000032.o):(.text+0x0): first defined here
E:/program/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/libgfortran.a(transfer.o):(.text$_gfortran_st_write_done+0x0): multiple definition of `_gfortran_st_write_done'
../lib/libblas64.dll.a(d000033.o):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[2]: *** [SRC\CMakeFiles\lapack64.dir\build.make:28718: bin/liblapack64.dll] Error 1
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:304: SRC/CMakeFiles/lapack64.dir/all] Error 2
mingw32-make.exe: *** [Makefile:155: all] Error 2

解决办法

build/lapack/SRC/CMakeFiles/lapack64.dir/link.txt文件中gfortran配置参数中添加--allow-multiple-definition参数

E:\program\mingw64\bin\gfortran.exe  -frecursive -fdefault-integer-8 -g -shared -o ..\bin\liblapack64.dll -Wl,--out-implib,..\lib\liblapack64.dll.a -Wl,--major-image-version,3,--minor-image-version,11 -Wl,--whole-archive CMakeFiles\lapack64.dir/objects.a -Wl,--no-whole-archive @CMakeFiles\lapack64.dir\linkLibs.rsp -Wl,--allow-multiple-definition,--output-def,lapack64.def

然后重新编译就能过了。


教程 | win10上安装mingw


摘要

使用gcc在win上编译代码,这样省着在linux的虚拟机上编译代码检查错误了。

下载

下载页面 这个直接选择一个Files->MinGW-W64 GCC-8.1.0->x86_64-win32-sjlj
直接下载地址

解压

解压文件到E:\program\mingw64(自己预设)

配置环境变量

  1. 添加变量名MW_MINGW64_LOC变量值E:\program\mingw64(自己放置的位置)的系统变量
  2. 在Path中添加%MW_MINGW64_LOC%\bin环境变量

校验

输入gcc -v后出现以下信息说明配置正确。
屏幕截图 2023-10-28 143330.jpg


教程 | boost在ubuntu上编译安装


需求

中望这边给的包依赖boost,还是指定1.65.1版本的,但是最新的ubuntu确实安装的1.74,这就很尴尬,直接创建软连接的话还是会报错。那就只能自己编译一下指定版本。

boost下载地址

boost官网
boost指定版本下载定制

解压文件

tar -xvzf boost_1_65_1.tar.gz

bjam

boost库自带一套编译工具bjam,bjam本身也是跨平台的,也需要自行编译出来。解压我们下载的boost_1_65_1.zip文件,在目录下有bootstrap.sh和bootstrap.bat两个脚本文件,它们分别用来编译unix和windows下的bjam。

编译bjam

./bootstrap.sh

编译及安装boost

./b2 install --prefix="../boost1.65.1" --build-dir="build" --with-filesystem

解释: 这里试安装boost,安装目录为上级目录的boost1.65.1,编译目录为build,只编译安装filesyste这个组件

b2参数说明

参数说明
stage生成链接库(动态库或静态库)到statedir中。(不含头文件)
---stagedir=在stage生成模式下的输出目录,支持相对路径。
install生成链接库(动态库或静态库)到prefix/lib中,并将头文件放到prefix/include中
---prefix=在install生成模式下的输出目录。
---build-type=构建指定的预定义库。
complete构建所有可能的变体。
---build-dir=设置编译过程中间产物的存放路径。
---show-libraries显示需要构建和安装步骤的boost库列表,然后退出。
---layout=确定是否选择库名和头位置,以便在同一系统上可以使用多版本的boost或多个编译器。
versionedboost二进制文件的名称包括boost版本号、编译器的名称和版本以及编码的构建属性。
---help帮助文档
---with-编译哪些库,例如--with-wave --with-test,表示只编译wave和test库。
---without-排除哪些库,例如--without-wave --without-test,表示除了wave库和test库其它都编译。
-toolset=msvc-14.0/msvc-14.1/msvc-14.2/gcc指定编译器。b2.exe会自行检索当前系统下的编译器,如果该参数为缺省值,那么b2.exe将使用boost源码根目录下的project-config.jam文件中的第一个编译器。
variant=debug/release设置生成的库是调试版本还是发布版本。默认值为release debug即两者都编译。
link=static/shared设置生成的库是动态库还是静态库。默认值为satic。
threading=single/multi设置是否支持多线程(线程安全)。默认值为multi(多线程)。
runtime-link=static/shared设置运行时库的链接方式。默认shared(动态链接)。
address-model=32/64设置生成的库地址模式,是32位还是64位。默认两者都编译。
--project-config=project-config.jam加载指定项目配置文件。默认值为project-config.jam。

教程 | Gogs首页等页面修改


需求

这边gogs的环境搭完了,但是说实话瞅着默认页面有点难受,并不细化它的格局,需要修改修改。本身是通过docker搭建的环境,并且已经在本地磁盘挂载了对应的/data目录。直接加文件就能修改。

data目录结构

data
├─ git
│  ├─ .ssh
│  ├─ repositories
│  └─ .gitignore
├─ gogs
│  ├─ conf
│  ├─ data
│  └─ log
└─ ssh

修改首页

在/data/gogs创建templates文件夹,在里面创建home.tmpl,将github项目中gogs/templates/home.tmpl的内容拷贝进去。

{{template "base/head" .}}
<div class="home">
    <div class="ui stackable middle very relaxed page grid">
        <div class="sixteen wide center aligned centered column">
            <div class="logo">
                <img src="{{AppSubURL}}/img/gogs-hero.png" />
            </div>
            <div class="hero">
                <h2>{{.i18n.Tr "app_desc"}}</h2>
            </div>
        </div>
    </div>
    {{if eq .Lang "de-DE"}}
        <div class="ui stackable middle very relaxed page grid">
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-flame"></i> Einfach zu installieren
                </h1>
                <p class="large">
                    Starte einfach <a target="_blank" rel="noopener noreferrer" href="https://gogs.io/docs/installation/install_from_binary.html">die Anwendung</a> für deine Plattform. Gogs gibt es auch für <a target="_blank" rel="noopener noreferrer" href="https://github.com/gogs/gogs/tree/main/docker">Docker</a>, <a target="_blank" rel="noopener noreferrer" href="https://github.com/geerlingguy/ansible-vagrant-examples/tree/master/gogs">Vagrant</a> oder als <a target="_blank" rel="noopener noreferrer" href="https://gogs.io/docs/installation/install_from_packages.html">Installationspaket</a>.
                </p>
            </div>
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-device-desktop"></i> Plattformübergreifend
                </h1>
                <p class="large">
                    Gogs läuft überall. <a target="_blank" rel="noopener noreferrer" href="http://golang.org/">Go</a> kompiliert für: Windows, macOS, Linux, ARM, etc. Wähle dasjenige System, was dir am meisten gefällt!
                </p>
            </div>
        </div>
        <div class="ui stackable middle very relaxed page grid">
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-rocket"></i> Leichtgewicht
                </h1>
                <p class="large">
                    Gogs hat minimale Systemanforderungen und kann selbst auf einem günstigen und stromsparenden Raspberry Pi betrieben werden.
                </p>
            </div>
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-code"></i> Quelloffen
                </h1>
                <p class="large">
                    Der komplette Code befindet sich auf <a target="_blank" rel="noopener noreferrer" href="https://github.com/gogits/gogs/">GitHub</a>! Unterstütze uns bei der Verbesserung dieses Projekts. Trau dich!
                </p>
            </div>
        </div>
    {{else if eq .Lang "zh-CN"}}
        <div class="ui stackable middle very relaxed page grid">
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-flame"></i> 易安装
                </h1>
                <p class="large">
                    您除了可以根据操作系统平台通过 <a target="_blank" rel="noopener noreferrer" href="https://gogs.io/docs/installation/install_from_binary.html">二进制运行</a>,还可以通过 <a target="_blank" rel="noopener noreferrer" href="https://github.com/gogs/gogs/tree/main/docker">Docker</a> 或 <a target="_blank" rel="noopener noreferrer" href="https://github.com/geerlingguy/ansible-vagrant-examples/tree/master/gogs">Vagrant</a>,以及 <a target="_blank" rel="noopener noreferrer" href="https://gogs.io/docs/installation/install_from_packages.html">包管理</a> 安装。
                </p>
            </div>
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-device-desktop"></i> 跨平台
                </h1>
                <p class="large">
                    任何 <a target="_blank" rel="noopener noreferrer" href="http://golang.org/">Go 语言</a> 支持的平台都可以运行 Gogs,包括 Windows、Mac、Linux 以及 ARM。挑一个您喜欢的就行!
                </p>
            </div>
        </div>
        <div class="ui stackable middle very relaxed page grid">
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-rocket"></i> 轻量级
                </h1>
                <p class="large">
                    一个廉价的树莓派的配置足以满足 Gogs 的最低系统硬件要求。最大程度上节省您的服务器资源!
                </p>
            </div>
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-code"></i> 开源化
                </h1>
                <p class="large">
                    所有的代码都开源在 <a target="_blank" rel="noopener noreferrer" href="https://github.com/gogits/gogs/">GitHub</a> 上,赶快加入我们来共同发展这个伟大的项目!还等什么?成为贡献者吧!
                </p>
            </div>
        </div>
    {{else if eq .Lang "fr-FR"}}
        <div class="ui stackable middle very relaxed page grid">
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-flame"></i> Facile à installer
                </h1>
                <p class="large">
                    Il suffit de <a target="_blank" rel="noopener noreferrer" href="https://gogs.io/docs/installation/install_from_binary.html">lancer l'exécutable</a> correspondant à votre système.
                    Ou d'utiliser Gogs avec <a target="_blank" rel="noopener noreferrer" href="https://github.com/gogs/gogs/tree/main/docker">Docker</a> ou
                    <a target="_blank" rel="noopener noreferrer" href="https://github.com/geerlingguy/ansible-vagrant-examples/tree/master/gogs">Vagrant</a>
                    ou en l'installant depuis un <a target="_blank" rel="noopener noreferrer" href="https://gogs.io/docs/installation/install_from_packages.html">package</a>.
                </p>
            </div>
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-device-desktop"></i> Multi-plateforme
                </h1>
                <p class="large">
                    Gogs tourne partout où <a target="_blank" rel="noopener noreferrer" href="http://golang.org/">Go</a> peut être compilé : Windows, macOS, Linux, ARM, etc. Choisissez votre préféré !
                </p>
            </div>
        </div>
        <div class="ui stackable middle very relaxed page grid">
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-rocket"></i> Léger
                </h1>
                <p class="large">
                    Gogs utilise peu de ressources. Il peut même tourner sur un Raspberry Pi très bon marché. Économisez l'énergie de vos serveurs !
                </p>
            </div>
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-code"></i> Open Source
                </h1>
                <p class="large">
                    Toutes les sources sont sur <a target="_blank" rel="noopener noreferrer" href="https://github.com/gogits/gogs/">GitHub</a> ! Rejoignez-nous et contribuez à rendre ce projet encore meilleur.
                </p>
            </div>
        </div>
    {{else if eq .Lang "es-ES"}}
        <div class="ui stackable middle very relaxed page grid">
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-flame"></i> Fácil de instalar
                </h1>
                <p class="large">
                    Simplemente <a target="_blank" rel="noopener noreferrer" href="https://gogs.io/docs/installation/install_from_binary.html">arranca el binario</a> para tu plataforma. O usa Gogs con <a target="_blank" rel="noopener noreferrer" href="https://github.com/gogs/gogs/tree/main/docker">Docker</a> o <a target="_blank" rel="noopener noreferrer" href="https://github.com/geerlingguy/ansible-vagrant-examples/tree/master/gogs">Vagrant</a>, o utilice el <a target="_blank" rel="noopener noreferrer" href="https://gogs.io/docs/installation/install_from_packages.html">paquete</a>.
                </p>
            </div>
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-device-desktop"></i> Multiplatforma
                </h1>
                <p class="large">
                    Gogs funciona en cualquier parte, <a target="_blank" rel="noopener noreferrer" href="http://golang.org/">Go</a> puede compilarse en: Windows, macOS, Linux, ARM, etc. !Elige tu favorita!
                </p>
            </div>
        </div>
        <div class="ui stackable middle very relaxed page grid">
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-rocket"></i> Ligero
                </h1>
                <p class="large">
                    Gogs tiene pocos requisitos y puede funcionar en una Raspberry Pi barata. !Ahorra energía!
                </p>
            </div>
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-code"></i> Open Source
                </h1>
                <p class="large">
                    ¡Está todo en <a target="_blank" rel="noopener noreferrer" href="https://github.com/gogits/gogs/">GitHub</a>! Uniros contribuyendo a hacer este proyecto todavía mejor. ¡No seas tímido y colabora!
                </p>
            </div>
        </div>
    {{else if eq .Lang "pt-BR"}}
        <div class="ui stackable middle very relaxed page grid">
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-flame"></i> Fácil de instalar
                </h1>
                <p class="large">
                    Simplesmente <a target="_blank" rel="noopener noreferrer" href="https://gogs.io/docs/installation/install_from_binary.html">rode o executável</a> para o seu sistema operacional. Ou obtenha o Gogs com o <a target="_blank" rel="noopener noreferrer" href="https://github.com/gogs/gogs/tree/main/docker">Docker</a> ou <a target="_blank" rel="noopener noreferrer" href="https://github.com/geerlingguy/ansible-vagrant-examples/tree/master/gogs">Vagrant</a>, ou baixe o <a target="_blank" rel="noopener noreferrer" href="https://gogs.io/docs/installation/install_from_packages.html">pacote</a>.
                </p>
            </div>
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-device-desktop"></i> Multi-plataforma
                </h1>
                <p class="large">
                    Gogs roda em qualquer sistema operacional em que <a target="_blank" rel="noopener noreferrer" href="http://golang.org/">Go</a> consegue compilar: Windows, macOS, Linux, ARM, etc. Escolha qual você gosta mais!
                </p>
            </div>
        </div>
        <div class="ui stackable middle very relaxed page grid">
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-rocket"></i> Leve e rápido
                </h1>
                <p class="large">
                    Gogs utiliza poucos recursos e consegue mesmo rodar no barato Raspberry Pi. Economize energia elétrica da sua máquina!
                </p>
            </div>
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-code"></i> Código aberto
                </h1>
                <p class="large">
                    Está tudo no <a target="_blank" rel="noopener noreferrer" href="https://github.com/gogits/gogs/">GitHub</a>! Contribua e torne este projeto ainda melhor. Não tenha vergonha de contribuir!
                </p>
            </div>
        </div>
    {{else if eq .Lang "ru-RU"}}
        <div class="ui stackable middle very relaxed page grid">
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-flame"></i> Простой в установке
                </h1>
                <p class="large">
                    Просто <a target="_blank" rel="noopener noreferrer" href="https://gogs.io/docs/installation/install_from_binary.html">запустите исполняемый файл</a> для вашей платформы. Используйте Gogs с <a target="_blank" rel="noopener noreferrer" href="https://github.com/gogs/gogs/tree/main/docker">Docker</a> или <a target="_blank" rel="noopener noreferrer" href="https://github.com/geerlingguy/ansible-vagrant-examples/tree/master/gogs">Vagrant</a>, или загрузите <a target="_blank" rel="noopener noreferrer" href="https://gogs.io/docs/installation/install_from_packages.html">пакет</a>.
                </p>
            </div>
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-device-desktop"></i> Кроссплатформенный
                </h1>
                <p class="large">
                    Gogs работает на любой операционной системе, которая может компилировать <a target="_blank" rel="noopener noreferrer" href="http://golang.org/">Go</a>: Windows, macOS, Linux, ARM и т. д. Выбирайте, что вам больше нравится!
                </p>
            </div>
        </div>
        <div class="ui stackable middle very relaxed page grid">
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-rocket"></i> Легковесный
                </h1>
                <p class="large">
                    Gogs имеет низкие системные требования и может работать на недорогом Raspberry Pi. Экономьте энергию вашей машины!
                </p>
            </div>
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-code"></i> Открытый исходный код
                </h1>
                <p class="large">
                    Всё это на <a target="_blank" rel="noopener noreferrer" href="https://github.com/gogits/gogs/">GitHub</a>! Присоединяйтесь к нам, внося вклад, чтобы сделать этот проект еще лучше. Не бойтесь помогать!
                </p>
            </div>
        </div>
    {{else if eq .Lang "uk-UA"}}
        <div class="ui stackable middle very relaxed page grid">
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-flame"></i> Простий у втановленні
                </h1>
                <p class="large">
                    Просто <a target="_blank" rel="noopener noreferrer" href="https://gogs.io/docs/installation/install_from_binary.html">запустіть виконуваний файл</a> для вашої платформи. Використовуйте Gogs с <a target="_blank" rel="noopener noreferrer" href="https://github.com/gogs/gogs/tree/main/docker">Docker</a> або <a target="_blank" rel="noopener noreferrer" href="https://github.com/geerlingguy/ansible-vagrant-examples/tree/master/gogs">Vagrant</a>, або завантажте <a target="_blank" rel="noopener noreferrer" href="https://gogs.io/docs/installation/install_from_packages.html">пакет</a>.
                </p>
            </div>
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-device-desktop"></i> Кросплатформність
                </h1>
                <p class="large">
                    Gogs працює у будь-якій операційній системі, що може компілювати <a target="_blank" rel="noopener noreferrer" href="http://golang.org/">Go</a>: Windows, macOS, Linux, ARM і т. д. Обирайте що вам більше до вподоби!
                </p>
            </div>
        </div>
        <div class="ui stackable middle very relaxed page grid">
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-rocket"></i> Легковісний
                </h1>
                <p class="large">
                    Gogs має низькі системні вимоги та може працювати на недорогому Raspberry Pi. Економте енергію вашої машини!
                </p>
            </div>
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-code"></i> Відкритий сирцевий код
                </h1>
                <p class="large">
                    Все це у <a target="_blank" rel="noopener noreferrer" href="https://github.com/gogits/gogs/">GitHub</a>! Приєднуйтеся до нас, робіть внесок, щоб зробити цей проект ще краще. Не бійтеся допомагати!
                </p>
            </div>
        </div>
    {{else if eq .Lang "it-IT"}}
        <div class="ui stackable middle very relaxed page grid">
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-flame"></i> Facie da installare
                </h1>
                <p class="large">
                    Basta <a target="_blank" rel="noopener noreferrer" href="https://gogs.io/docs/installation/install_from_binary.html">avviare il binario</a> per la tua piattaforma.
                </p>
            </div>
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-device-desktop"></i> Multipiattaforma
                </h1>
                <p class="large">
                    Gogs funziona ovunque, <a target="_blank" rel="noopener noreferrer" href="http://golang.org/">Go</a> si può compilare su: Windows, macOS, Linux, ARM, etc. Scegli il tuo preferito!
                </p>
            </div>
        </div>
        <div class="ui stackable middle very relaxed page grid">
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-rocket"></i> Leggero
                </h1>
                <p class="large">
                    Gogs ha requisiti bassi e può funzionare su un Raspberry Pi economico. Risparmiare energia!
                </p>
            </div>
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-code"></i> Open Source
                </h1>
                <p class="large">
                    Sta tutto su <a target="_blank" rel="noopener noreferrer" href="https://github.com/gogits/gogs/">GitHub</a>! È tutto su GitHub! Unisciti a noi contribuendo a rendere questo progetto ancora miglior$
                </p>
            </div>
        </div>
    {{else}}
        <div class="ui stackable middle very relaxed page grid">
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-flame"></i> Easy to install
                </h1>
                <p class="large">
                    Simply <a target="_blank" rel="noopener noreferrer" href="https://gogs.io/docs/installation/install_from_binary.html">run the binary</a> for your platform. Or ship Gogs with <a target="_blank" rel="noopener noreferrer" href="https://github.com/gogs/gogs/tree/main/docker">Docker</a> or <a target="_blank" rel="noopener noreferrer" href="https://github.com/geerlingguy/ansible-vagrant-examples/tree/master/gogs">Vagrant</a>, or get it <a target="_blank" rel="noopener noreferrer" href="https://gogs.io/docs/installation/install_from_packages.html">packaged</a>.
                </p>
            </div>
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-device-desktop"></i> Cross-platform
                </h1>
                <p class="large">
                    Gogs runs anywhere <a target="_blank" rel="noopener noreferrer" href="http://golang.org/">Go</a> can compile for: Windows, macOS, Linux, ARM, etc. Choose the one you love!
                </p>
            </div>
        </div>
        <div class="ui stackable middle very relaxed page grid">
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-rocket"></i> Lightweight
                </h1>
                <p class="large">
                    Gogs has low minimal requirements and can run on an inexpensive Raspberry Pi. Save your machine energy!
                </p>
            </div>
            <div class="eight wide center column">
                <h1 class="hero ui icon header">
                    <i class="octicon octicon-code"></i> Open Source
                </h1>
                <p class="large">
                    It's all on <a target="_blank" rel="noopener noreferrer" href="https://github.com/gogits/gogs/">GitHub</a>! Join us by contributing to make this project even better. Don't be shy to be a contributor!
                </p>
            </div>
        </div>
    {{end}}
</div>
{{template "base/footer" .}}

根据需求修改这个home.tmpl,然后重启容器(docker restart 容器名称)。

修改静态文件

在/data/gogs创建public文件夹,在里面创建css、js等文件,这里不需要重启容器。

这里通过保存自定义图标到 /data/gogs/public/img/favicon.png 实现站点图标的重载。静态文件的路径要在/data/gogs/templates中的模板中有定义, 其中{{AppSubURL}}对应的就是/data/gogs/public。

结果

屏幕截图 2023-10-03 104238.jpg


教程 | Gogs-一款极易搭建的自助 Git 服务


需求

自己需要一个git服务,gitlab有点大,小小的树莓派带不动啊。选择一个极简的git服务来管理。这里用docker来安装服务。

composer处理基础环境

version: '3.6'
services:
  postgres-gogs:
    container_name: gogs_database
    image: postgres:9.6
    restart: always
    volumes:
      - "/mnt/data/gitGogs/postgres:/var/lib/postgresql/data" # 挂载数据库文件目录
    environment:
      POSTGRES_USER: gogs
      POSTGRES_PASSWORD: yak_gogs
      POSTGRES_DB: gogs
    networks:
      - "net_gogs"
  gogs:
    container_name: gogs
    image: gogs/gogs
    restart: always
    ports:
      - "9822:22" # 暴漏ssh端口
      - "9880:3000" # 暴漏web端口
    volumes:
      - "/mnt/data/gitGogs/data:/data" # 挂载数据目录
    depends_on:
      - "postgres-gogs"
    networks:
      - "net_gogs"
networks:
  net_gogs:

安装

访问http://IP:9880
首次进入自动跳转安装界面填写对应信息,数据库这里选择postgres,在填写对应的管理员信息。立即安装即可。

成果

屏幕截图 2023-10-03 100428.jpg