Instalar Gitea con CentOS 7, Certbot, Nginx y SQLite
       
       November 2019 · 2 minute read
       Posted in:   CentOS,  Certbot, Gitea, Self-Hosting, Software, Software
       Libre,
       
       
       En el siguiente  post les enseñaré lo del título instalando Gitea,  un
       servicio  Git autogestionado, fork  de  Gogs.  ?  Asumiré que ya  está
       instalado CentOS. Recuerda reemplazar example.com con tu dominio.
       
       Primero instalaremos los requisitos si no lo están:
       
       sudo yum install epel-release
       sudo yum install nginx git sqlite certbot python2-certbot-nginx
       
       Luego activaremos e iniciaremos nginx:
       
       sudo systemctl enable nginx
       sudo systemctl start nginx
       
       Usaremos certbot para transformar la conección en HTTPS, siguiendo las
       instrucciones en inglés.
       
       sudo certbot --nginx -d example.com
       
       (Tendrás  que  ingresa  tu  mail,  luego  a,   después  1  si  quieres
       suscribirte a EFF, finalmente 2 para redirigir a HTTPS)
       
       Después modificaremos la configuración del vhost Nginx, suele estar en
       default.conf.
       
       sudo nano /etc/nginx/conf.d/default.conf
       
       Debe quedar algo así:
       
       server {
           server_name  example.com;
           root /var/www/example.com;
           
       #Si se quiere Gitea en el dominio directamente usar esto y no lo del subdirectorio.
           location / {
              proxy_pass http:/localhost:3000
           }
       
       #Si se quiere Gitea en un subdirectorio usar esto y no lo del dominio directo.
            location /git/ {
               proxy_pass http://localhost:3000/;
             }
       
       listen 443 ssl http2; # managed by Certbot
           ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
           ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
           include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
           ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
       
       }
       server {
           if ($host = example.com) {
               return 301 https://$host$request_uri;
           } # managed by Certbot
       
       
           listen 80;
           server_name  example.com;
           return 404; # managed by Certbot 
       
       Luego creamos un usuario para instalar Gitea en él.
       
       sudo adduser --system --shell /bin/bash --comment 'Git Version Control' --user-group --home-dir /home/git -m git
       
       Iniciamos sesión con ese usuario.
       
       su - git
       
       Creamos  un directorio, descargamos Gitea buscando  el link aquí [1] y
       lo ejecutamos.
       
       mkdir gitea
       cd gitea
       wget -O gitea https://dl.gitea.io/gitea/1.10.0/gitea-1.10.0-linux-amd64
       chmod +x gitea
       ./gitea web -c custom/conf/app.ini
       
       Vamos  al navegador a http://example.com:3000/install,  rellenamos con
       lo siguiente e  instalamos (https://example.com/git es la  otra opción
       en URL base si queremos subdirectorio):
       
 (IMG)   
       
 (IMG)   
       
 (IMG)   
       
       Luego  de instalar,  paramos gitea  con Ctrl+C, y  cerramos sesión del
       usuario git con Ctrl+D y crearemos el servicio para su ejecución:
       
       sudo nano /etc/systemd/system/gitea.service
       
       Pegamos esto:
       
       [Unit]
       Description=Gitea (Git with a cup of tea)
       After=syslog.target
       After=network.target
       [Service]
       RestartSec=2s
       Type=simple
       User=git
       Group=git
       WorkingDirectory=/home/git/gitea/
       ExecStart=/home/git/gitea/gitea web -c /home/git/gitea/custom/conf/app.ini
       Restart=always
       Environment=USER=git HOME=/home/git
       [Install]
       WantedBy=multi-user.target 
       
       Iniciamos y habilitamos el servicio:
       
       sudo systemctl enable gitea
       sudo systemctl start gitea
       
       Finalmente revisamos si está activo:
       
       sudo systemctl status gitea
       
       Y  revisamos  el  link  en  el  navegador.  ¡Y  ya  está!  Sólo  queda
       registrarte como primer usuario.
       
       Espero que esta guía haya sido de ayuda.
       
       References:
 (HTM)   [1] aquí
       Secciones:
 (DIR) Home
 (DIR) Posts (Feed)
 (DIR) Ayúdame
 (DIR) Contacto
 (DIR) CV
       
       Links:
 (HTM) Mail
       
 (DIR) Home
       
        skrlet13 CC-BY-SA
       ___________________________________________________________________
                       Gophered by Gophernicus/3.1.1 on OpenBSD/amd64 7.3