[https://gitea.io Gitea] is a community managed lightweight code hosting solution written in Go. It is a fork of Gogs.
1. Gitea was created by a group of users and contributors of the self-hosted Git service Gogs, It is a fork of Gogs and is written in Go.
{{Note|This guide is not for installing Gitea in Docker. If you want to install Gitea in a Docker container, follow [https://docs.gitea.io/en-us/install-with-docker/ the official documentation]}}
2. This guide is for real deploy not for docker deploys.. dockers does not need to setup packages and filesystems configs, for that you must use always docker related configurations.
== Installation ==
3. If even though docker always uses Alpine linux as images, and the software is alpine packages, it still has nothing to do with using alpine specific commands.
First, [[Enable Community Repository | Enable the Community Repository]]
4. Git is the version control system (VCS) software behind gitea perse, so must be installed first. But '''repositories on server are not same as in clients.. server repositories are bare repositories'''.
Then install the {{pkg|gitea}} package:
{{cmd|apk add gitea}}
== Pre Requirements ==
== Setting up the Database ==
This document will guide noob users,
{{Note|These instructions are for MariaDB. If you would like to set up another database, follow [https://docs.gitea.io/en-us/database-prep/ the official documentation]}}
* CVS command line
Install the MariaDB and {{pkg|mariadb-client}} packages:
** git
{{cmd|apk add mariadb mariadb-client}}
** git-lfs
* Database:
** mysql
** postgresql
** sqlite
** tidb
For database professional setup please refers to the [[Production_DataBases_:_mysql]] page or [[Production_DataBases_:_postgresql]] page
A hostname is a unique name created to identify a machine on a network, configured in /etc/hostname.
Create the <code>gitea</code> database and a user with access to it:
To change the computer's hostname edit the <code>/etc/hostname</code> file or execute the following command
{{Note|Everything after the <code>mysql -u root -p</code> should be typed in the MariaDB prompt (looks like <code>MariaDB [(none)]></code>)}}
(make sure to replace <code>myhostname</code> with your desired hostname):
{{Note|Replace the above username 'giteauser' and password 'giteapassword' with something secure. Remember these settings. You will need them later when setting up Gitea.}}
{{cmd|mysql -u root -p
<pre># echo "myhostname" > /etc/hostname</pre>
CREATE DATABASE gitea DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
GRANT ALL ON gitea.* TO 'giteauser'@'localhost' IDENTIFIED BY 'giteapassword';
FLUSH PRIVILEGES;
EXIT}}
You should also add the hostname to your hosts file (<code>/etc/hosts</code>):
If you want, you can uninstall the <code>mariadb-client</code> now as it's not needed anymore:
{{cmd|apk del mariadb-client}}
In {{path|/etc/gitea/app.ini}}, replace the contents of the <code>[database]</code> section with the following:
<pre>
<pre>
127.0.0.1 localhost.localdomain localhost
DB_TYPE = mysql
127.0.1.1 myhostname.mydomain myhostname
HOST = /var/run/mysqld/mysqld.sock
::1 localhost.localdomain localhost
NAME = gitea ; The database name set with 'CREATE DATABASE'
USER = giteauser ; The database user
PASSWD = giteapassword ; The password for the database user
</pre>
</pre>
== Installation ==
This guide does work either if are or not in main or edge the gitea package:, '''take note, do not install any more from edge.. so in fact all gitea dependencies must be listed and installed before gitea and edge brand are activated''', so the following process will guide and show you how to do that; first gain root privileges or access ssh to your alpine server and then:
# added and update normal repositories
# install direct dependences: git, gnupg, make, bash, coreutils and from normal stable repositories
{{warning|Take in consideration that the user <code>gitea</code> or "a gitea" system user must be in the system. Check if the <code>gitea</code> package already crated the user, if not, just created but set home to <code>/var/lib/gitea</code>}}
== Configurations ==
== Configurations ==
Gitea configurations are defined by the gitea service at <code>/etc/init.d/gitea</code> script:
The Gitea service can be configured using {{path|/etc/conf.d/gitea}}:
{| class="wikitable"
{| class="wikitable"
|-
|-
! Artifac !! Name !! Path related
! Description !! Configuration Variable !! Default Value
|-
|-
| Daemon script || gitea || /etc/init.d/gitea
| User to run Gitea under || GITEA_USER || gitea
|-
|-
| Daemon user || gitea || /var/lib/gitea/
| Gitea working directory || GITEA_WORK_DIR || /var/lib/gitea/
| Config global || gitea.ini || /etc/gitea/app.ini
|-
| Web files || STATIC_ROOT_PATH || /usr/share/webapps/gitea/
|-
| Data files || APP_DATA_PATH || /var/lib/gitea/data/
|}
|}
Gitea '''runs as <code>gitea</code> user, and <code>www-data</code> group''', so are ''compatible with any web deploy in system webservers packages of alpine repositories'', but not with any other external installation if does not are same as.
Some additional settings in {{path|/etc/gitea/app.ini}}:
Gitea has two configuration files, the '''system defaults at <code>/var/lib/gitea/conf/app.ini</code>''' and modifiable '''package defaults, at <code>/etc/gitea/app.ini</code>'''. Original files are in <code>/usr/share/webapps/gitea</code> and are defaults non-modifiable. For alterations see next sections where are defined initialization, customization and configurations.
Gitea can be customized: just '''take same path from <code>/usr/share/webapps/gitea/</code> and put in same manner at <code>/var/lib/gitea/custom/</code> place'''.
=== Initialization ===
Gitea just after install does not need many configurations, the daemon service init all the needs, take in consideration that this means:
{| class="wikitable"
{| class="wikitable"
|-
|-
! Config !! Default
! Description !! Configuration Variable !! Default Value
|-
|-
| Start to use || <nowiki>http://localhost:3000</nowiki>
| Gitea customization directory || <code>Cannot be configured</code> || /var/lib/gitea/custom/
|-
|-
| Git repositories || /var/lib/gitea/git
| Web files || STATIC_ROOT_PATH || /usr/share/webapps/gitea/
|-
|-
| Database files || Sqlite at /var/lib/gitea/db/gitea.db
| Data files || APP_DATA_PATH || /var/lib/gitea/data/
For others configurations please check next sections.
{{Note|Gitea has a built-in web server, so there is no need to configure one. However, you can [https://docs.gitea.io/en-us/reverse-proxies/ set up a reverse proxy].}}
==== Controlling and starting gitea ====
Gitea binary itselt '''cannot be start alone''', without parameters will put lot of directories and files in the default path, so to start to use must be:
# Start from init script!
# Make enabled the init script!
# Stop from init script
<pre><nowiki>
rc-update add gitea default
rc-service gitea restart
</nowiki></pre>
To stop:
<pre><nowiki>
rc-service gitea stop
</nowiki></pre>
A '''manual start without init script can be done''' but to use the files installed on the system the steps are:
# stop any running instance
# make a command to run with proper arguments
<pre><nowiki>
rc-service gitea stop
GITEA_WORK_DIR='/var/lib/gitea' /usr/bin/gitea web --config /etc/gitea/app.ini
</nowiki></pre>
This will use the config files and installed files from the package.
==== Post installation ====
'''After install and initialized''' the daemon, you now can just go to <code><nowiki>http://localhost:3000</nowiki></code> and start the post-installation process, '''''if you dont want to change any configuration.. if not check next sections.''''' A starting page will be show.
'''The post install page''', only are show when try to use the system, away of the starting page, by example if browse the repositories or try to login. You must not forget to setup that installation.
'''Administrator account must be configured''' before push "install gitea", the button at the end of the post-configuration page when you first visit the installation. Provide and username for admin user, take note "admin" are a reserved word so choose another name. after provide passowrd you will continue the installation.
=== Configuring ===
{{Note|To customize the look and feel of Gitea, find the correct path in {{path|/usr/share/webapps/gitea/}} and make the same path in {{path|/var/lib/gitea/custom/}}. For example, to add a new Gitea theme, create the {{path|/var/lib/gitea/custom/public/css/}} directory, then add the css for the theme there.}}
Gitea can be customized: just '''take same path from <code>/usr/share/webapps/gitea/</code> and put in same manner at <code>/var/lib/gitea/custom/</code> place''', by example to customize default landing page, just take a copy of the <code>/usr/share/webapps/gitea/templates/home.tmpl</code> and put modified one as <code>/var/lib/gitea/custom/templates/home.tmpl</code> as well.
== Controlling and starting gitea ==
You should not start Gitea without setting certain environment variables and passing some options, since it won't know where to store data and logs, so it is recommended to start gitea using the init script:
{{cmd|service gitea start}}
=== Database configurations ===
To add Gitea to the default runlevel (such that it runs automatically on every boot):
{{cmd|rc-update add gitea}}
Gitea for data '''database backend''' for storing configurations.. SQLite are the default. But for others database backends alpine packages of MySQL/MariaDB or PostgreSQL are like normal tarball of each one, admins must know what they want.. there's no automatic window-like installation here. So first go to [[MariaDB]] or [[PostgreSQL]] wiki pages and with a user database configure in the <code>/etc/gitea/app.ini</code> and modify the <code>DB_TYPE</code> change from sqlite to postgres or mysql, <code>NAME</code> as the database access where gitea will store the data, <code>USER</code> as the user that will access the database, <code>PASSWORD</code> with the password of the user to access to the database defined. <code>HOST</code> must be with "localhost" value since this wiki assumes local installation.
To stop the Gitea service:
{{cmd|service gitea stop}}
'''Setup the database to MySQL:'''
=== Running Gitea without the init script ===
<pre><nowiki>
If (for whatever reason), you would like to start Gitea without using the initscript, you should first stop the Gitea service:
service gitea stop
{{cmd|service gitea stop}}
</nowiki></pre>
Of course you must changed ''"secret_new_root_password"'' by a proper password provided by you.
Then, run Gitea with this command (as the <code>gitea</code> user):
{{cmd|<nowiki>GITEA_WORK_DIR=/var/lib/gitea gitea web --config /etc/gitea/app.ini</nowiki>}}
'''Setup the database to PosgreSQL:'''
This will use the correct configuration file and write to the correct directories.
<pre><nowiki>
== Post installation ==
service gitea stop
</nowiki></pre>
Of course you must changed ''"secret_new_root_password"'' by a proper password provided by you.
After installing Gitea, go to http://localhost:3000 and start the post-installation process.
= See Also =
= See Also =
Revision as of 07:11, 9 December 2021
This material needs expanding ...
Please feel free to help us complete it.
Gitea is a community managed lightweight code hosting solution written in Go. It is a fork of Gogs.
Note: This guide is not for installing Gitea in Docker. If you want to install Gitea in a Docker container, follow the official documentation
mysql_install_db --user=mysql --datadir=/var/lib/mysql
service mariadb start
rc-update add mariadb
mysql_secure_installation
Create the gitea database and a user with access to it:
Note: Everything after the mysql -u root -p should be typed in the MariaDB prompt (looks like MariaDB [(none)]>)
Note: Replace the above username 'giteauser' and password 'giteapassword' with something secure. Remember these settings. You will need them later when setting up Gitea.
mysql -u root -p
CREATE DATABASE gitea DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
GRANT ALL ON gitea.* TO 'giteauser'@'localhost' IDENTIFIED BY 'giteapassword';
FLUSH PRIVILEGES;
EXIT
If you want, you can uninstall the mariadb-client now as it's not needed anymore:
apk del mariadb-client
In /etc/gitea/app.ini, replace the contents of the [database] section with the following:
DB_TYPE = mysql
HOST = /var/run/mysqld/mysqld.sock
NAME = gitea ; The database name set with 'CREATE DATABASE'
USER = giteauser ; The database user
PASSWD = giteapassword ; The password for the database user
Configurations
The Gitea service can be configured using /etc/conf.d/gitea:
Description
Configuration Variable
Default Value
User to run Gitea under
GITEA_USER
gitea
Gitea working directory
GITEA_WORK_DIR
/var/lib/gitea/
Gitea configuration file
GITEA_CONF
/etc/gitea/app.ini
Some additional settings in /etc/gitea/app.ini:
Description
Configuration Variable
Default Value
Gitea customization directory
Cannot be configured
/var/lib/gitea/custom/
Web files
STATIC_ROOT_PATH
/usr/share/webapps/gitea/
Data files
APP_DATA_PATH
/var/lib/gitea/data/
Git repository storage directory
ROOT
/var/lib/gitea/git/
Log directory
ROOT_PATH
/var/log/gitea/
Note: Gitea has a built-in web server, so there is no need to configure one. However, you can set up a reverse proxy.
Note: To customize the look and feel of Gitea, find the correct path in /usr/share/webapps/gitea/ and make the same path in /var/lib/gitea/custom/. For example, to add a new Gitea theme, create the /var/lib/gitea/custom/public/css/ directory, then add the css for the theme there.
Controlling and starting gitea
You should not start Gitea without setting certain environment variables and passing some options, since it won't know where to store data and logs, so it is recommended to start gitea using the init script:
service gitea start
To add Gitea to the default runlevel (such that it runs automatically on every boot):
rc-update add gitea
To stop the Gitea service:
service gitea stop
Running Gitea without the init script
If (for whatever reason), you would like to start Gitea without using the initscript, you should first stop the Gitea service:
service gitea stop
Then, run Gitea with this command (as the gitea user):
GITEA_WORK_DIR=/var/lib/gitea gitea web --config /etc/gitea/app.ini
This will use the correct configuration file and write to the correct directories.
Post installation
After installing Gitea, go to http://localhost:3000 and start the post-installation process.