Bonjour,
Voici comment installer Gitea.
Installer les dépendances :
yum install -y nginx mariadb-server wget git
systemctl enable --now nginx mariadb
Configurer MariaDB :
mysql_secure_installation
mysql -u root -p
CREATE DATABASE gitea;
CREATE USER 'gitea'@localhost IDENTIFIED BY 'my_password';
GRANT ALL PRIVILEGES ON gitea.* TO 'gitea'@localhost IDENTIFIED BY 'my_password';
FLUSH PRIVILEGES;
EXIT
Télécharger Gitea :
export version=1.16.8
wget https://github.com/go-gitea/gitea/releases/download/v$version/gitea-$version-linux-amd64.xz
Installer Gitea :
xz -v -d gitea-$version-linux-amd64.xz
mkdir -p /root/.ssl
mkdir -p /opt/gitea
mkdir -p /opt/gitea/custom/conf
mkdir -p /home/gitea/.ssh
mkdir -p /home/gitea/repositories
mkdir -p /home/gitea/data/avatars
mkdir -p /home/gitea/data/attachments
mkdir -p /var/log/gitea
mv gitea-* /opt/gitea/gitea
chmod +x /opt/gitea/gitea
Créer un utilisateur dédié :
groupadd -r gitea
useradd -r -g gitea -d /home/gitea -s /bin/bash gitea
chown -R gitea: /opt/gitea
chown -R gitea: /home/gitea
chown -R gitea: /var/log/gitea
Créer le service de Gitea :
nano /etc/systemd/system/gitea.service
[Unit]
Description=Gitea
After=syslog.target
After=network.target
After=mysql.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=gitea
Group=gitea
WorkingDirectory=/home/gitea
ExecStart=/opt/gitea/gitea web
Restart=always
Environment=USER=gitea HOME=/home/gitea
[Install]
WantedBy=multi-user.target
systemctl enable gitea
Nginx avec Gitea :
nano /etc/nginx/conf.d/gitea.conf
server {
listen 443 ssl http2;
server_name gitea.my_domain.com;
access_log /var/log/nginx/gitea-access.log;
error_log /var/log/nginx/gitea-error.log error;
## The default `client_max_body_size` is 1M, this might not be enough for some posters, etc.
client_max_body_size 200M;
# SSL Configuration
ssl_certificate /root/.ssl/gitea.my_domain.com.crt;
ssl_certificate_key /root/.ssl/gitea.my_domain.com.key;
ssl_session_cache shared:SSL:10m;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384";
ssl_prefer_server_ciphers on;
# See https://hstspreload.org/ before uncommenting the line below.
# add_header Strict-Transport-Security "max-age=15768000; preload;";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header Content-Security-Policy "frame-ancestors 'self'";
add_header X-Frame-Options DENY;
add_header Referrer-Policy same-origin;
location / {
proxy_pass http://localhost:6000/;
proxy_set_header Host $host;
proxy_buffering off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Protocol $scheme;
proxy_set_header X-Forwarded-Host $http_host;
}
}
Configurer Gitea : (Optionnel)
nano /opt/gitea/custom/conf/app.ini
;https://github.com/gogits/gogs/blob/master/conf/app.ini
APP_NAME = Gitea
RUN_USER = gitea
RUN_MODE = prod
[database]
DB_TYPE = mysql
HOST = 127.0.0.1:3306
NAME = gitea
USER = gitea
PASSWD = MY_Password
SSL_MODE = disable
PATH = data/gitea.db
LOG_SQL = false
[repository]
ROOT = /home/gitea/repositories
FORCE_PRIVATE = false
; Global limit of repositories per user, applied at creation time. -1 means no limit
MAX_CREATION_LIMIT = 0
[server]
DOMAIN = gitea.my_domain.com
HTTP_PORT = 6000
HTTP_ADDR = 127.0.0.1
ROOT_URL = https://gitea.my_domain.com/
DISABLE_SSH = false
SSH_PORT = 22
OFFLINE_MODE = false
APP_DATA_PATH = /home/gitea/data
LANDING_PAGE = explore
[mailer]
ENABLED = true
SMTP_ADDR = 127.0.0.1:25
FROM = "Gitea" <gitea-noreply@my_domain.com>
FORCE_TRUST_SERVER_CERT = true
"Forgejo" <forgejo-noreply@my_domain.com>
[service]
REGISTER_EMAIL_CONFIRM = false
ENABLE_NOTIFY_MAIL = true
DISABLE_REGISTRATION = true
ENABLE_CAPTCHA = false
REQUIRE_SIGNIN_VIEW = false
ENABLE_REVERSE_PROXY_AUTHENTICATION = false
ENABLE_REVERSE_PROXY_AUTO_REGISTERATION = false
[picture]
AVATAR_UPLOAD_PATH = /home/gitea/data/avatars
[attachment]
PATH = /home/gitea/data/attachments
[session]
PROVIDER = memory
[log]
MODE = file
LEVEL = Info
ROOT_PATH = /var/log/gitea
REDIRECT_MACARON_LOG = true
MACARON = file
logger.router.LEVEL = warn
logger.router.MODE = file
logger.access.LEVEL = warn
logger.access.MODE = file
logger.xorm.LEVEL = warn
logger.xorm.MODE = file
[security]
INSTALL_LOCK = true
SECRET_KEY = __KEY__
REVERSE_PROXY_AUTHENTICATION_USER = REMOTE_USER
[git.timeout]
MIGRATE = 7200
[migrations]
ALLOW_LOCALNETWORKS=true
systemctl restart nginx gitea
Créer votre utilisateur Gitea :
cd /opt/gitea
runuser -u gitea -- ./gitea admin user create --username gitea --password my_password --email my@email.com --admin
Supprimer votre utilisateur Gitea :
cd /opt/gitea
runuser -u gitea -- ./gitea admin user delete --username gitea
Voilà vous pouvez vous connecter sur votre application.