<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ouail Derghal</title>
    <description>The latest articles on DEV Community by Ouail Derghal (@ouailderghal).</description>
    <link>https://dev.to/ouailderghal</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F674451%2F9df2d150-4a9c-43ac-8094-878850e1639c.jpg</url>
      <title>DEV Community: Ouail Derghal</title>
      <link>https://dev.to/ouailderghal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ouailderghal"/>
    <language>en</language>
    <item>
      <title>Deploy a self-hosted Git service</title>
      <dc:creator>Ouail Derghal</dc:creator>
      <pubDate>Fri, 26 Nov 2021 17:17:06 +0000</pubDate>
      <link>https://dev.to/ouailderghal/deploy-gitea-to-your-local-server-p80</link>
      <guid>https://dev.to/ouailderghal/deploy-gitea-to-your-local-server-p80</guid>
      <description>&lt;p&gt;There are many popular online code hosting platforms that help you store and manage source code of your projects, &lt;a href="https://github.com"&gt;Github&lt;/a&gt; and &lt;a href="https://gitlab.com"&gt;Gitlab&lt;/a&gt; are the most common solutions among developers. But sometimes you want to host projects on your local server, is that possible ?&lt;/p&gt;

&lt;p&gt;Well, yeah! Gitlab offers a self-managed version ready to deploy, setting it up may be a complex task and requires time and experience. Gitlab is considered as a devops platform, if you don't need such complex solution, then &lt;strong&gt;Gitea&lt;/strong&gt; is the best choice for you.&lt;/p&gt;

&lt;p&gt;Gitea is a cross-platform lightweight code hosting solution written in &lt;strong&gt;Go&lt;/strong&gt;. The goal of this great product is to offer an easy, fast and painless deployment of a self-hosted Git service.&lt;/p&gt;

&lt;p&gt;In this tutorial, we will walk through the steps of Gitea deployment on a Debian server.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup local server virtual machine
&lt;/h2&gt;

&lt;p&gt;For the purpose of this tutorial, we will be using &lt;a href="https://www.vagrantup.com/downloads"&gt;Vagrant&lt;/a&gt; to create a Debian virtual machine that runs on &lt;a href="https://www.virtualbox.org/wiki/Downloads"&gt;Virtualbox&lt;/a&gt; hypervisor. Make sure that you have Virtualbox and Vagrant installed on your machine.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Create the Vagrantfile&lt;/span&gt;
&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; ~/vagrant/debian-bullseye64
vim ~/vagrant/debian-bullseye64/Vagrantfile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is the Vagrant configuration file to run a Debian 11 VM, with a bridged IP address :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="no"&gt;Vagrant&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;configure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"2"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
  &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;vm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;box&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"debian/bullseye64"&lt;/span&gt;
  &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;vm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;network&lt;/span&gt; &lt;span class="s2"&gt;"public_network"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;ip: &lt;/span&gt;&lt;span class="s2"&gt;"10.0.0.20"&lt;/span&gt;

  &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;vm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;provider&lt;/span&gt; &lt;span class="s2"&gt;"virtualbox"&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;vb&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="n"&gt;vb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;gui&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kp"&gt;false&lt;/span&gt;
    &lt;span class="n"&gt;vb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;memory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"512"&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can boot up the VM :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ~/vagrant/debian-bullseye64
vagrant up
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since we've set up a bridged connection, the Debian VM is accessible on the local network. To check if the VM responds, you can ping &lt;code&gt;10.0.0.20&lt;/code&gt; &lt;em&gt;(the IP address may not be the same in your network, check your configuration and update the VM IP address to match your subnet)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;By default, Vagrant sets up an &lt;strong&gt;SSH server&lt;/strong&gt; on the VM, you can access the shell by running &lt;code&gt;vagrant ssh&lt;/code&gt;, make sure that you are on the same directory of the Vagrantfile.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup database
&lt;/h2&gt;

&lt;p&gt;Gitea requires one of the following relational databases : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;MySQL &lt;/li&gt;
&lt;li&gt;PostgreSQL &lt;/li&gt;
&lt;li&gt;MSSQL&lt;/li&gt;
&lt;li&gt;SQLite3&lt;/li&gt;
&lt;li&gt;TiDB &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this tutorial, we are going to use &lt;a href="https://mariadb.com/"&gt;MariaDB&lt;/a&gt;, the open-source equivalent of MySQL. &lt;/p&gt;

&lt;p&gt;To get MariaDB running on Debian VM, you need to install MariaDB server package :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install server package&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; mariadb-server
&lt;span class="c"&gt;# Launch the installation &lt;/span&gt;
mysql_secure_installation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the installation is finished, you need to create a new user and database :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;create&lt;/span&gt; &lt;span class="k"&gt;database&lt;/span&gt; &lt;span class="nv"&gt;`gitea`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;create&lt;/span&gt; &lt;span class="k"&gt;user&lt;/span&gt; &lt;span class="s1"&gt;'gitea'&lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="s1"&gt;'localhost'&lt;/span&gt; &lt;span class="n"&gt;identified&lt;/span&gt; &lt;span class="k"&gt;by&lt;/span&gt; &lt;span class="s1"&gt;'superSecReTPASSwD'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;grant&lt;/span&gt; &lt;span class="k"&gt;all&lt;/span&gt; &lt;span class="k"&gt;privileges&lt;/span&gt; &lt;span class="k"&gt;on&lt;/span&gt; &lt;span class="nv"&gt;`gitea`&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;to&lt;/span&gt; &lt;span class="s1"&gt;'gitea'&lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="s1"&gt;'localhost'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;flush&lt;/span&gt; &lt;span class="k"&gt;privileges&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Install Gitea binaries
&lt;/h2&gt;

&lt;p&gt;At the date of this tutorial, the latest available version of Gitea is &lt;code&gt;1.15.4&lt;/code&gt;, you can check the official &lt;a href="https://try.gitea.io/"&gt;Gitea website&lt;/a&gt;. Run the following commands to download Gitea binary :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;wget &lt;span class="nt"&gt;-O&lt;/span&gt; gitea https://dl.gitea.io/gitea/1.15.4/gitea-1.15.4-linux-amd64
&lt;span class="nb"&gt;chmod &lt;/span&gt;755 gitea &lt;span class="c"&gt;# make the binary executable&lt;/span&gt;
&lt;span class="nb"&gt;sudo mv &lt;/span&gt;gitea /usr/local/bin/ &lt;span class="c"&gt;# move binary to $PATH&lt;/span&gt;
which gitea &lt;span class="c"&gt;# check if gitea binary is available in $PATH&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can execute Gitea binary, a local server will be started on port &lt;code&gt;3000&lt;/code&gt; and bound to &lt;code&gt;0.0.0.0&lt;/code&gt; IP address, you can access Gitea externally from your browser by visiting &lt;code&gt;http://10.0.0.20:3000&lt;/code&gt;. For now, we need to prepare the Debian VM for Gitea before using it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prepare virtual machine for Gitea
&lt;/h2&gt;

&lt;p&gt;To make Gitea instance work properly on your server, you need to install &lt;strong&gt;Git&lt;/strong&gt; :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; git
&lt;span class="c"&gt;# check installed git version&lt;/span&gt;
git &lt;span class="nt"&gt;--version&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a new system user for Gitea :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;adduser &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--system&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--shell&lt;/span&gt; /bin/bash &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--gecos&lt;/span&gt; &lt;span class="s1"&gt;'Gitea'&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--group&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--disabled-password&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--home&lt;/span&gt; /home/git &lt;span class="se"&gt;\&lt;/span&gt;
   git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create folder structure for Gitea repositories and configuration files :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; /var/lib/gitea/&lt;span class="o"&gt;{&lt;/span&gt;custom,data,log&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="nb"&gt;sudo mkdir&lt;/span&gt; /etc/gitea
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Update permissions and change ownership of Gitea directories to the previously created Git user :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo chown &lt;/span&gt;root:git /etc/gitea
&lt;span class="nb"&gt;sudo chown&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; git:git /var/lib/gitea/
&lt;span class="nb"&gt;sudo chmod&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; 750 /var/lib/gitea/
&lt;span class="nb"&gt;sudo chmod &lt;/span&gt;770 /etc/gitea
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should update permissions of &lt;code&gt;/etc/gitea&lt;/code&gt; after installation, it was previously set with write  permissions so the installer can write the configuration file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;750 /etc/gitea
&lt;span class="nb"&gt;chmod &lt;/span&gt;640 /etc/gitea/app.ini
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can run Gitea server, make sure that you have exported the Gitea working directory variable &lt;em&gt;(You can skip this step, we will later run Gitea with a Linux service)&lt;/em&gt; :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;GITEA_WORK_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/var/lib/gitea/ &lt;span class="c"&gt;# working directory&lt;/span&gt;
gitea web &lt;span class="nt"&gt;-c&lt;/span&gt; /etc/gitea/app.ini &lt;span class="c"&gt;# launch Gitea web server&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you get a permission error, don't panic ! The explanation of this behavior is that your current user could not read the &lt;code&gt;app.ini&lt;/code&gt; configuration file, your user should be a member of Git group. In my case, the current user is &lt;code&gt;vagrant&lt;/code&gt; and it is not a member of Git group, adding it to that latter will fix the permission error.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;usermod &lt;span class="nt"&gt;-aG&lt;/span&gt; git &lt;span class="nv"&gt;$USER&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can kill Gitea server by hitting Control+c.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gitea service
&lt;/h2&gt;

&lt;p&gt;Running Gitea server manually is not practical, the ideal solution is to configure it to run on the system startup, to do so, you need to write a custom &lt;em&gt;Linux service&lt;/em&gt; that starts Gitea every time the system boots up.&lt;/p&gt;

&lt;p&gt;Create a new &lt;em&gt;systemd service&lt;/em&gt; and open it with your favorite editor, I will be using vim :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;vim /etc/systemd/system/gitea.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since Gitea saves data on MariaDB database, our custom service should be run after MariaDB service.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="nn"&gt;[Unit]&lt;/span&gt;
&lt;span class="py"&gt;Description&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;Gitea&lt;/span&gt;
&lt;span class="py"&gt;After&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;syslog.target&lt;/span&gt;
&lt;span class="py"&gt;After&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;network.target&lt;/span&gt;
&lt;span class="py"&gt;Wants&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;mariadb.service&lt;/span&gt;
&lt;span class="py"&gt;After&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;mariadb.service&lt;/span&gt;

&lt;span class="nn"&gt;[Service]&lt;/span&gt;
&lt;span class="py"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;simple&lt;/span&gt;
&lt;span class="py"&gt;User&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;git&lt;/span&gt;
&lt;span class="py"&gt;Group&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;git&lt;/span&gt;
&lt;span class="py"&gt;WorkingDirectory&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;/var/lib/gitea/&lt;/span&gt;
&lt;span class="py"&gt;ExecStart&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;/usr/local/bin/gitea web --config /etc/gitea/app.ini&lt;/span&gt;
&lt;span class="py"&gt;Environment&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea&lt;/span&gt;
&lt;span class="py"&gt;RestartSec&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;2s&lt;/span&gt;
&lt;span class="py"&gt;Restart&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;always&lt;/span&gt;

&lt;span class="nn"&gt;[Install]&lt;/span&gt;
&lt;span class="py"&gt;WantedBy&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;multi-user.target&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can enable and run Gitea service :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl daemon-reload
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable &lt;/span&gt;gitea &lt;span class="nt"&gt;--now&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Congratulations! Now you have Gitea service running and enabled at system startup, try to reboot the VM and access Gitea server by visiting &lt;a href="http://10.0.0.20:3000"&gt;http://10.0.0.20:3000&lt;/a&gt;, you should see the setup page for Gitea in a web UI.&lt;/p&gt;

&lt;h2&gt;
  
  
  Firewall configuration
&lt;/h2&gt;

&lt;p&gt;If you are trying to deploy Gitea to a public server, then the usage of a firewall is recommended as a security measure. We will not dive in details into firewall configuration, but here are some basic commands to install and enable the firewall, and allow port 3000 through the firewall &lt;em&gt;(the one that Gitea uses to serve the web UI)&lt;/em&gt; :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; ufw &lt;span class="c"&gt;# install uncomplicated firewall&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable &lt;/span&gt;ufw &lt;span class="nt"&gt;--now&lt;/span&gt; &lt;span class="c"&gt;# enable and run firewall service&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw &lt;span class="nb"&gt;enable&lt;/span&gt; &lt;span class="c"&gt;# change firewall status to active&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw allow 22/tcp &lt;span class="c"&gt;# allow ssh&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw allow 3000/tcp &lt;span class="c"&gt;# allow Gitea&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Gitea web UI
&lt;/h2&gt;

&lt;p&gt;When you open Gitea web UI for the first time, you will be prompted with a configuration page, the web UI saves your configuration to &lt;code&gt;/etc/gitea/app.ini&lt;/code&gt;, you can skip the settings page and set your configuration directly by editing the configuration file.&lt;/p&gt;

&lt;p&gt;Enter the database information that you previously created :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Gw1cF2BP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/91s2x8qlil929gyftfog.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Gw1cF2BP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/91s2x8qlil929gyftfog.png" alt="Gitea initial configuration" width="832" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You have also to setup Gitea general parameters :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--h-dzkT3N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c2pi5ily7w41utwhaa9b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--h-dzkT3N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c2pi5ily7w41utwhaa9b.png" alt="Gitea general settings" width="833" height="858"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Set up the administrator account :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--h1T2Hl-O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3c3vrkk6xsgdm29drq8o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--h1T2Hl-O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3c3vrkk6xsgdm29drq8o.png" alt="Gitea administrator account" width="835" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you can hit &lt;code&gt;Install Gitea&lt;/code&gt; to apply configuration, you will be redirected  to the login page. Use your administrator account to get access to your Gitea instance.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PRw3PLFI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a4mmz3ya0mrixmndwg8w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PRw3PLFI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a4mmz3ya0mrixmndwg8w.png" alt="" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Custom configuration
&lt;/h2&gt;

&lt;p&gt;There are many configuration options than can be applied to you Gitea instance, let's assume that we are using Gitea in a team, and only the administrator can create accounts for new members. &lt;/p&gt;

&lt;p&gt;How to prevent users from creating accounts on our Gitea instance ? The solution is pretty simple, you have to ssh into the Debian VM (or your physical server) and edit the &lt;code&gt;app.ini&lt;/code&gt; configuration file. Under the &lt;em&gt;service&lt;/em&gt; section, update &lt;code&gt;DISABLE_REGISTRATION&lt;/code&gt; to &lt;strong&gt;true&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="nn"&gt;[service]&lt;/span&gt;
&lt;span class="py"&gt;REGISTER_EMAIL_CONFIRM&lt;/span&gt;  &lt;span class="p"&gt;=&lt;/span&gt;  &lt;span class="s"&gt;false&lt;/span&gt;
&lt;span class="py"&gt;ENABLE_NOTIFY_EMAIL&lt;/span&gt;     &lt;span class="p"&gt;=&lt;/span&gt;  &lt;span class="s"&gt;false&lt;/span&gt;
&lt;span class="py"&gt;DISABLE_REGISTRATION&lt;/span&gt;    &lt;span class="p"&gt;=&lt;/span&gt;  &lt;span class="s"&gt;true      &amp;lt;---&lt;/span&gt;
&lt;span class="err"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Restart Gitea service :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl daemon-reload
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl restart gitea
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the registration feature is disabled :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HRaUHr2v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ypclyio781q0hkzmme8l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HRaUHr2v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ypclyio781q0hkzmme8l.png" alt="Gitea disabled registration" width="844" height="130"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All available configuration options are listed in &lt;a href="https://docs.gitea.io/en-us/config-cheat-sheet/"&gt;Gitea configuration cheat sheet&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;In this tutorial, we set up a Debian VM with a bridged network connection, we created database configuration and we deployed Gitea. We also configured Gitea directly form the configuration file.&lt;/p&gt;

&lt;p&gt;If you are trying to deploy Gitea to a public server with a domain name, you can use &lt;strong&gt;NGINX reverse proxy&lt;/strong&gt;. This will let you set up a domain name and also  &lt;strong&gt;SSL/TLS certficates&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>git</category>
      <category>gitea</category>
      <category>debian</category>
      <category>vagrant</category>
    </item>
  </channel>
</rss>
