Instalar Gitea con CentOS 7, Certbot, Nginx y SQLite

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:

s s u u d d o o y y u u m m i i n n s s t t a a l l l l e n p g e i l n - x r e g l i e t a s s e q l i t e c e r t b o t p y t h o n 2 - c e r t b o t - n g i n x

Luego activaremos e iniciaremos nginx:

s s u u d d o o s s y y s s t t e e m m c c t t l l e s n t a a b r l t e n n g g i i n n x x

Usaremos certbot para transformar la conección en HTTPS, siguiendo las instrucciones en inglés.

s u d o c e r t b o t - n g i n x - d e x a m p l e . c o m

(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.

s u d o n a n o / e t c / n g i n x / c o n f . d / d e f a u l t . c o n f

Debe quedar algo así:

s # # l } s e S S i e r i i s r v t v e s r s l } s e s s i s e i } l s r r e o e o e l n s s n s r f i e e r o c o } l l c l # s r t { v t q a p q c 4 _ _ l _ { ( t v u e u t r u a p 4 c c u d $ r m e e r r i i o i t r 3 e e d h h e a n r n _ v e o x e i o r r e p o t n _ n a r n y r o x s t t a s u a 8 n 4 a r e _ e n y s i i / r t r g 0 a 0 m / / p _ l f f e a n e ; m 4 e w G a G / p i i t m = d e ; w i { s i g a h c c c 3 w t s t i s t a a / / e 0 b # e / e e t s t t t l e x 1 y e x e a h a / p e e e t a x m a x t h 2 _ t c m h C a a m a e t e { t ; / k s / p t e m n p m n p n t e e e l l t r p a l p : p # t y n e e p t l g e l e / u : c c t . s b e e . e l l n / m / / r s c : . d c . o / a l e y e o t c o c d c s l n e t p n m / o b m o o a u o a t c t c ) $ m y ; m m l b c g s / / r h ; ; i h d a e e l o y { o C n o i l d n e p p s e i s r h c t t t t r o t e o b r s i $ t : c s y y e s r b d 3 t t p n n s e o i 0 o : C t c s l q t r 0 r 3 e / r - - u e 0 i 0 r l y s d e c o 0 t i p s h s t 0 b v t l p t a u / o e - a _ m s ; t l n r u e a e i g a r n r x v i m i t a e n s ; e e m / x . s p e . p u t l x c e s o e a o m a . m n ; r y c p f o l ; # e n m e s o / . # m t f c a o l u o m n o l m a a y l / n g d c p a e n e h r g d o l a i e i v d b l d n k y o o . e b m p y y C d i e . e e n m p C r l i ; e e t o m r b s # ; t o u d b t b i m # o d r a t i e n m r c a a e t g n c o e a t . d g o e r b d i y o b . C y e r C t e b r o t t b o t

Luego creamos un usuario para instalar Gitea en él.

s u d o a d d u s e r - s y s t e m - s h e l l / b i n / b a s h - c o m m e n t ' G i t V e r s i o n C o n t r o l ' - u s e r - g r o u p - h o m e - d i r / h o m e / g i t - m g i t

Iniciamos sesión con ese usuario.

s u - g i t

Creamos un directorio, descargamos Gitea buscando el link aquí y lo ejecutamos.

m c w c k d g h / d e m g i g t o i r i d t t - e g e O + a i a x t g w e i g e a t i b e t a e - a c h t c t u p s s t : o / m / / d c l o . n g f i / t a e p a p . . i i o n / i g i t e a / 1 . 1 0 . 0 / g i t e a - 1 . 1 0 . 0 - l i n u x - a m d 6 4

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):

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:

s u d o n a n o / e t c / s y s t e m d / s y s t e m / g i t e a . s e r v i c e

Pegamos esto:

[ D A A [ R T U G W E R E [ W U e f f S e y s r o x e n I a n s t t e s p e o r e s v n n i c e e r t e r u k c t i s t t r r r v a = = p i S a r t e ] i = = i r s g = n t r o a d p s n c t i i g g a t n l B t y e e S m t i D r = m l y i s t ] e p t i t a e ] = o l w c l r = l n m n o o = e e / w t u = g r 2 c h a = l G . k s t o y U t i t . o m s S i t a t r e E - e r a y / R u a g r = g = s e g / i g e ( t e h t i r G t o / t . i m g t t e i H a / t O r w g e M g i i a E e t t = t h g / g i h a i t o t e m c e a e u a / p / w g e i o b t f - t c e a / ) h o m e / g i t / g i t e a / c u s t o m / c o n f / a p p . i n i

Iniciamos y habilitamos el servicio:

s s u u d d o o s s y y s s t t e e m m c c t t l l e s n t a a b r l t e g g i i t t e e a a

Finalmente revisamos si está activo:

s u d o s y s t e m c t l s t a t u s g i t e a

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.