This file is a rundown of the different steps to install gitea. As a fork of gogs, gitea installs the same way gogs does, but I didn't find an exhaustive how-to to install it. I did however find an extensive guide on this blog post, most of this data is reused here.
- Install
- Database configuration
- Fetch and build gitea
- Pre-configure gitea
- Systemd configuration
- Starting gitea
- First installation
- Others
- Fresh install of Raspbian GNU/Linux 9 light or newer
- some patience
$ sudo apt install git golang mariadb-client mariadb-server
$ sudo adduser --disabled-login --gecos 'gitea' git
$ echo export GOPATH="PATH" >> ~/.bashrc
As said, I am using MySQL. This part replace or create a gitea
database and create an account to access it.
Be sure to set SOME_PASSWORD
to something you'll remember.
$ sudo mariadb -u root
> create database gitea character set utf8 collate utf8_general_ci;
> grant all on gitea.* to 'git'@'localhost' identified by 'SOME_PASSWORD';
> quit
This will fetch and build the latest version of gitea and put it in $GOPATH/code.gitea.io/gitea
.
$ go get -u code.gitea.io/gitea
$ cd $GOPATH/src/code.gitea.io/gitea
$ go build
Once build, I recommend you move a few files around. I don't like having a folder filled with source, cvs folders and compilation products in it.
$ export LOC=/usr/local/gitea
$ sudo mkdir -m 775 $LOC $LOC/bin $LOC/systemd
$ sudo chown -R git $LOC
$ sudo -u git cp $GOPATH/src/code.gitea.io/gitea/gitea $LOC/bin
$ sudo -u git cp -r $GOPATH/src/code.gitea.io/gitea/conf $LOC
$ sudo -u git cp -r $GOPATH/src/code.gitea.io/gitea/options/locale $LOC/conf
$ sudo -u git cp -r $GOPATH/src/code.gitea.io/gitea/public $LOC
$ sudo -u git cp -r $GOPATH/src/code.gitea.io/gitea/templates/ $LOC
$ sudo -u git cp $GOPATH/src/code.gitea.io/gitea/contrib/systemd $LOC
After that you can customize gitea.
$ sudo -u git vi $LOC/systemd/gitea.service
$ sudo -u git vi $LOC/conf/app.ini
The app.ini
file you got here is unmodified. It will be modified by the installation process you will go through afterward. A few things can be configured before hand, though. Read the cheat sheet for more info.
- The project folder root is set in
[repository].ROOT
. I set it to gitea-repos, beside the gitea application folder - The database url and credentials are set in the
[database]
section - The
DOMAIN
andHTTP_ADDR
of the[server]
and the[repository].ROOT_URL
are used for display and a displaying the cloning URL - I suggest setting
[service].DISABLE_REGISTRATION
and[service].REQUIRE_SIGNIN_VIEW
totrue
if you really want to go private server - I also suggest setting
[log].ROOT_PATH
to a folder you'll remember (like /home/git/gitea/logs) - Setting up security can also be a good idea: set configure the
[server].CERT_FILE
and[server].KEY_FILE
entries accordingly
Copy the systemd script to the /lib/systemd/system folder:
$ cd /lib/systemd/system/
$ sudo ln -s /usr/local/share/gitea/gitea.service
Edit that file (remember you need root powers for that) to change the different paths:
- WORKINGDIR=/home/git/gitea
- ExecStart=/home/git/gitea/gitea web
- Environment=USER=git HOME=/home/git
Also decomment the After=mysqld.service
Start gitea after that:
git:~$ sudo systemctl start gitea
Use your webbrowser to go to http://:3000 (you can use the https if you set up certificates.)
You should be redirected to gitea install page. Fill the mandatory fields and press Install. If you set DISABLE_REGISTRATION to true in the Pre-configure gitea
step, you'll also have to create the administrator account there.
Once the installation is done, you should be redirected to the Dashboard.
Simply press the + on the right of the Dashboard then select New Migration
. You can migrate local git bare repositories too.
In order to use git-ssh to clone projects and push commits, you have to add your public ssh key to your account. That is done in 'Your Settings' -> 'SSH Keys'. Notice that if you don't do that, the URL checkout presented in the URL will not work. You should still be able to checkout and push using the regular git URLs.
For example: a user is named JAppleseed
. After setting his public key in gitea, his project should be clonable from git@yourserver:JAppleseed/MyProject.git
. Without the public key set, a git clone will result in a 'JAppleseed/MyProject.git is not a valid repository' message.
Using git@yourserver:<your git repo root>/jappleseed/myproject.git
or something equivalent based on the filesystem will work, though it will not be thanks to gitea.
Q. I failed the original configuration process!! I want a do over!
A. Stop the gitea process, reset the database entry (see Database configuration), and set [security].INSTALL_LOCK
to false
in the gitea/custom/conf/app.ini
file.
Q. The install webpage doesn't appear after I've done the systemctl start gitea
command
A. Take a look at the logs of the app (or the systemctl status gitea). You set them in the Pre-configure gitea
step. There should be a "listening to XXX.XXX.XXX.XXX:3000" in the log. Anyway, starting the web server takes some time. Like up to 10s on a raspberry pi 2.
Q. I can't checkout using the short URLs
A. Either you didn't set your public key (or it's not correct) or your git command tool doesn't know which key to use because you got multiple keys in your .ssh folder. I suggest reading a few docs on git or ssh to solve your problem.