GNU/Linux >> Linux Esercitazione >  >> Panels >> Panels

Come installare Gogs su Ubuntu 18.04

In questa guida spiegheremo come installare Gogs su un VPS Ubuntu 18.04 con MariaDB come database di back-end.

Gogs è un servizio Git self-hosted gratuito e open source scritto nel linguaggio di programmazione Go. È facile da installare, è multipiattaforma ed è leggero, il che consente a Gogs di funzionare facilmente su tutti i tipi di hardware. Questa guida dovrebbe funzionare anche su altri sistemi VPS Linux, ma è stata testata e scritta per un VPS Ubuntu 18.04.

Prerequisiti

  • Un server con Ubuntu 18.04
  • Un account utente con privilegi sudo o accesso all'utente "root" stesso

Fase 1:installa i pacchetti richiesti

Accedi al tuo VPS tramite SSH come root o come utente sudo:

ssh userame@IP_Address

Una volta fatto, esegui i seguenti comandi per aggiornare tutti i pacchetti alle ultime versioni disponibili:

sudo apt-get update
sudo apt-get upgrade

Successivamente, dobbiamo installare git. Puoi farlo usando il seguente comando:

sudo apt-get install git

Fase 2:crea un database MySQL

Gogs può utilizzare database MySQL, PostgreSQL, MSSQL, TiDB e SQLite3 per il suo database back-end.

In questo tutorial useremo MySQL. Installa il server MySQL più recente eseguendo il comando seguente:

sudo apt-get install mysql-server

Al termine dell'installazione di MySQL, proteggi l'installazione di MariaDB utilizzando mysql_secure_installation sceneggiatura. Questa parte è facoltativa, ma fortemente consigliata in quanto migliora la sicurezza del server del database:

sudo mysql_secure_installation

Quindi, rispondi alle domande di sicurezza come segue:

Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y

Accedi alla console MySQL con l'utente root MySQL, utilizzando la password che hai impostato nel passaggio precedente:

mysql -u root -p

Crea un database MySQL e un utente per Gogs e concedi le autorizzazioni all'utente utilizzando i seguenti comandi:

mysql> CREATE SCHEMA `gogs` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql> GRANT ALL PRIVILEGES ON gogs.* TO 'gogs'@'localhost' IDENTIFIED BY 'strongpassword';
mysql> FLUSH PRIVILEGES;
mysql> \q

Assicurati di sostituire "strongpassword" con una password efficace.

Fase 3:installa Gogs

Innanzitutto, crea un nuovo utente di sistema per Gogs:

sudo adduser --home /opt/gogs --shell /bin/bash --gecos 'Gogs application' gogs

I seguenti comandi scaricheranno il binario di Gogs dalla pagina di Gogs Github:

sudo wget https://github.com/gogs/gogs/releases/download/v0.11.86/linux_amd64.tar.gz

Estrai l'archivio nella directory /opt/gogs:

tar xvf linux_amd64.tar.gz --strip-components=1 -C /opt/gogs

Cambia la proprietà della directory all'utente Gogs:

sudo chown -R gogs:gogs /opt/gogs/

Quindi, copia il file dell'unità di sistema:

sudo cp /opt/gogs/scripts/systemd/gogs.service /etc/systemd/system/

Apri il file dell'unità utilizzando il tuo editor di testo preferito:noi usiamo nano.

sudo nano /etc/systemd/system/gogs.service

Una volta aperto il file, modificalo come segue:

[Unit]
[Unit]
Description=Gogs
After=syslog.target
After=network.target
After=mariadb.service mysqld.service postgresql.service memcached.service redis.service

[Service]
# Modify these two values and uncomment them if you have
# repos with lots of files and get an HTTP error 500 because
# of that
###
#LimitMEMLOCK=infinity
#LimitNOFILE=65535
Type=simple
User=gogs
Group=gogs
WorkingDirectory=/opt/gogs
ExecStart=/opt/gogs web
Restart=always
Environment=USER=gogs HOME=/opt/gogs

# Some distributions may not support these hardening directives. If you cannot start the service due
# to an unknown option, comment out the ones not supported by your version of systemd.
ProtectSystem=full
PrivateDevices=yes
PrivateTmp=yes
NoNewPrivileges=true

[Install]
WantedBy=multi-user.target

Salva e chiudi il file, quindi avvia e abilita il servizio Gogs:

sudo systemctl daemon-reload
sudo systemctl start gogs
sudo systemctl enable gogs

Verifica che il servizio Gogs sia stato avviato correttamente:

● gogs.service - Gogs
   Loaded: loaded (/etc/systemd/system/gogs.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2019-04-07 12:25:32 CDT; 6min ago
 Main PID: 19220 (gogs)
    Tasks: 8 (limit: 2320)
   CGroup: /system.slice/gogs.service
           └─19220 /opt/gogs/gogs web

Apr 07 12:25:32 localhost systemd[1]: Started Gogs.
Apr 07 12:25:32 localhost gogs[19220]: 2019/04/07 12:25:32 [ WARN] Custom config '/opt/gogs/custom/conf/app.ini' not found, ignore this if you're running first time
Apr 07 12:25:32 localhost gogs[19220]: 2019/04/07 12:25:32 [TRACE] Custom path: /opt/gogs/custom
Apr 07 12:25:32 localhost gogs[19220]: 2019/04/07 12:25:32 [TRACE] Log path: /opt/gogs/log
Apr 07 12:25:32 localhost gogs[19220]: 2019/04/07 12:25:32 [TRACE] Log Mode: Console (Trace)
Apr 07 12:25:32 localhost gogs[19220]: 2019/04/07 12:25:32 [ INFO] Gogs 0.11.86.0130
Apr 07 12:25:32 localhost gogs[19220]: 2019/04/07 12:25:32 [ INFO] Cache Service Enabled
Apr 07 12:25:32 localhost gogs[19220]: 2019/04/07 12:25:32 [ INFO] Session Service Enabled
Apr 07 12:25:32 localhost gogs[19220]: 2019/04/07 12:25:32 [ INFO] SQLite3 Supported
Apr 07 12:25:32 localhost gogs[19220]: 2019/04/07 12:25:32 [ INFO] Run Mode: Development
Apr 07 12:25:33 localhost gogs[19220]: 2019/04/07 12:25:33 [ INFO] Listen: http://0.0.0.0:3000

Fase 4:imposta i gog

Una volta completata l'installazione, vai su http://server_ip:3000/install e compila tutti i campi richiesti. Ricorda di sostituire "server_ip" con l'indirizzo IP pubblico del tuo server:

Impostazioni database
– Tipo di database:MySQL
– Host:127.0.0.1:3306
– Utente:gogs
– Password:password sicura
– Nome database:gogs

Impostazioni generali di Gogs
– Nome applicazione:Gogs
– Percorso radice del repository:/opt/gogs/gogs-repositories
– Utente eseguito:gogs
– Dominio:IP_SERVER
– Porta SSH :22
– Porta HTTP:3000
– URL applicazione:http://SERVER_IP:3000/
– Percorso registro:/opt/gogs/log

Infine, fai clic su Installa e sei a posto.

L'accesso amministrativo è automaticamente concesso al primo utente registrato:

Questo è tutto. Hai installato correttamente Gogs sul tuo Ubuntu 18.04 VPS. Per ulteriori informazioni su come gestire l'installazione di Gogs, fare riferimento alla documentazione ufficiale di Gogs.

Ovviamente, non devi fare nulla di tutto ciò se utilizzi uno dei nostri servizi di hosting VPS Linux, nel qual caso puoi semplicemente chiedere ai nostri esperti amministratori Linux di configurarlo per te. Sono disponibili 24 ore su 24, 7 giorni su 7 e si prenderanno immediatamente cura della tua richiesta.

PS . Se ti è piaciuto questo post, condividilo con i tuoi amici sui social network utilizzando le scorciatoie di condivisione qui sotto, o semplicemente lascia un commento in basso nella sezione commenti. Grazie.


Panels
  1. Come installare R su Ubuntu 16.04

  2. Come installare Attendize su Ubuntu 16.04

  3. Come installare Joomla 3 su Ubuntu 16.04

  4. Come installare Nginx su Ubuntu 16.04

  5. Come installare Phabricator su Ubuntu 16.04

Come installare Docker su Ubuntu 18.04

Come installare Apache su Ubuntu 18.04

Come installare MariaDB 10.4 su Ubuntu 18.04

Come installare MongoDB su Ubuntu 18.04

Come installare Gogs su Ubuntu 18.04 LTS

Come installare Vai su Ubuntu 18.04