Talk:Gitea

From ArchWiki
Jump to navigation Jump to search

PostgreSQL draft

Install and configure and start the PostgreSQL, then do this to create gitea user and db:

1. Switch to posgres user:

$ sudo -u postgres -i

2. Start create db wizzard (TODO add explanation why not superuser):

[postgres]$ createuser --interactive
name: gitea
superuser: no

3. then createdb named gitea using gitea user (its ok to launch the createdb command as regular user as well)

[postgres]$ createdb gitea -U gitea

4. then try access the the DB via localhost, cause that's how the gittea will try to access it

[postgres]$ psql -d gitea -U gitea -h 127.0.0.1 -W (connect to gitea db as gitea user, host localhost and -W without anything for empty password)

Now to edit the /etc/gitea/app.ini

Default PostgreSQL port is 5432 if you haven't changed it

/etc/gitea/app.ini
[database]
DB_TYPE = postgres
HOST = 127.0.0.1;5432
NAME = gitea
PASSWD = 
USER = postgres
SSL_MODE = disable


  • TODO setup a password, SSL_MODE wanted?
  • TODO using localhost:port might be unsecure, better to connect directly at the socket (in "/run/postgresql");
    • (try connecting to db psql -d gitea -U gitea and typing \conninfo for details)

Pulec (talk) 01:00, 2 July 2018 (UTC)

Please sign your posts. :)
Any recommendations from Gitea/Gogs for setting up PostgreSQL?
Francoism (talk) 09:38, 24 June 2018 (UTC)
Wrote something based on my setup and my previous experience with Mattermost
Archange (talk) 16:29, 1 November 2018 (UTC)

Upgrading to gitea version >= 1.5 mariadb

The solution in the article seems not to ultimatively solve the problem with the database.

For "set global innodb_large_prefix = `ON`;" to have an effect, the ROW_FORMAT of the table has to be DYNAMIC or COMPRESSED (https://stackoverflow.com/questions/24321896/mysql-row-format-compressed-vs-dynamic) ,to be able to set the ROW_FORMAT to either DYNAMIC or COMPRESSED the file format has to be at least BARRACUDA (https://mariadb.com/kb/en/library/xtradbinnodb-storage-formats/).

For me to get gitea >= 1.5 working with mariadb < 10.2 I first added those four lines to the mariadb config

/etc/mysql/my.cnf
[mysqld]
innodb_file_format = barracuda
innodb_file_per_table = 1
innodb_large_prefix = 1

Then I started gitea >= 1.5 which still resulted in a bunch of errors concerning the key length;

To change the ROW_FORMAT on all tables in the gitea database I run a slightly adapted (to my needs) bash script taken from (https://lxadm.com/MySQL:_changing_ROW_FORMAT_to_DYNAMIC_or_COMPRESSED)

#!/bin/bash

DATABASE=gitea

ROW_FORMAT=DYNAMIC

TABLES=$(echo SHOW TABLES | mysql -s $DATABASE)

for TABLE in $TABLES ; do
    echo "ALTER TABLE $TABLE ROW_FORMAT=$ROW_FORMAT;"
    echo "ALTER TABLE \`$TABLE\` ROW_FORMAT=$ROW_FORMAT" | mysql $DATABASE
done

The escaped back quotes are necessary since one table in the database is called RELEASE which is a reserved word within mysql. You probably will have to run the script multiple times since after each run gitea will add new tables to the database depending on which tables already have been converted to ROW_FORMAT DYNAMIC. If you cannot access your db without a password you have to adapt the mysql command in the for loop accordingly

You can check if all tables have been converted

mysql -u root -p
MariaDB [(none)]> use gitea;
MariaDB [gitea]> show table status;

max key length is 767 bytes

gitea-1.5.1-1-x86_64.pkg.tar.xz

I am using local/mariadb 10.1.36-1

and when creating the DB like in the wiki with

CREATE DATABASE `gitea` DEFAULT CHARACTER SET `utf8mb4` COLLATE `utf8mb4_unicode_ci`;

i get an error at the install page:


Datenbankeinstellungen sind ungültig: Error 1071: Specified key was too long; max key length is 767 bytes

if i change it to:

CREATE DATABASE `gitea` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_general_ci`;

everything works as expected.

MariaDB

As described in the workaround link, I successfully installed Gitea on MariaDB by altering /etc/mysql/my.cnf
I simply added three settings.
/etc/mysql/my.cnf
######################################
## Fixing Gitea installation issues ##
######################################
innodb_default_row_format = dynamic
innodb_file_format = Barracuda
innodb_large_prefix = 1
######################################
Bebedizo (talk) 09:28, 12 December 2018 (UTC)

Apache Reverse Proxy Over Unix Socket

I have the following settings in my VirtualHost directive of Apache 2.4 - and things seem to work.

However, I am not an expert on (reverse) proxies, so I regard this as a starting point for further investigation, e.g. the part with http:// looks awkward.

some-vhost.conf
<VirtualHost *:443>
   ...
   AllowEncodedSlashes NoDecode
   <Location />
      Require all granted
      ProxyPass unix:/run/gitea/gitea.socket|http://127.0.0.1:3000/
      ProxyPassReverse unix:/run/gitea/gitea.socket|http://127.0.0.1:3000/
   </Location>
   ...
</VirtualHost>

Bebedizo (talk) 09:45, 12 December 2018 (UTC)

Apache Reverse Proxy with gitea in subfolder

Gitea within a subfolder of the apache document root. This means my URL is https://foo.bar and gitea is reachable via https://foo.bar/git:

subfolders/gitea.conf
<Proxy *>
    Order allow,deny
    Allow from all
</Proxy>
SSLProxyEngine On
SSLProxyCheckPeerCN Off
ProxyPass /git https://localhost:3000
ProxyPassReverse /git https://localhost:3000

Use full absolute path with LFS_CONTENT_PATH

I updated my app.ini from the pacnew of 1.9.x-ish release and noticed git ssh:// access was broken. Further investigation revealed that the default LFS_CONTENT_PATH=data/lfs in the updated default app.ini.pacnew was the cause of the breakage.
In my old app.ini from 1.8.3 it was LFS_CONTENT_PATH=/var/lib/gitea/data/lfs which didn't come from the upstream release nor from PKGBUILD's gitea-arch-defaults.patch. I suspect the gitea server set it during the initial config but didn't confirmed it so I'm posting this in the discussion page. Tinywrkb (talk) 23:23, 25 August 2019 (UTC)