Linux下安装gitea

1、创建运行gitea的用户

groupadd git

useradd git -g git -s /bin/false

2、安装git

yum -y install git

3、安装gitea

wget -O gitea https://dl.gitea.io/gitea/1.4.0/gitea-1.4.0-linux-amd64

4、给执行权限

chmod +x gitea

5、修改所属人和所属组

chown -R git:git /安装路径

6、创建数据库并授权

#mysql -u root -p12345678

create database gitea;

create user ‘gitea’@’%’ identified by ‘12345678’;

grant create,alter,drop,select,insert,update,delete on gitea.* to gitea@’%’;

flush privileges ;

7、运行gitea并浏览器访问进行配置

/安装路径 web

浏览器进行配置(忽略)

例外:

nginx反向代理通过https访问gitea,域名访问:

#vi /usr/local/nginx/conf/nginx.conf

server {
    listen 443 ssl;
    server_name 域名;
    //证书地址
    ssl_certificate /root/a.pem;
    ssl_certificate_key /root/a.key;
    resolver 8.8.8.8;
    location / {
            proxy_pass http://你的gitea的访问地址/;
            proxy_set_header Host $http_host;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_send_timeout 1h;
            proxy_read_timeout 1h;
            client_max_body_size 128m;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $http_connection;
    }
}
 server {
    listen 80;
    server_name 域名;
    resolver 8.8.8.8;
    location / {
            proxy_pass http://你的gitea的访问地址/;
            proxy_set_header Host $http_host;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_send_timeout 1h;
            proxy_read_timeout 1h;
            client_max_body_size 128m;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $http_connection;
    }
 }

重启nginx
#systemctl restart nginx

通过服务启动gitea

#vi /usr/lib/systemd/system/gitea.service

[Unit]
Description=gitea

[Service]
User=root
ExecStart=/usr/local/gitea/gitea
Restart=on-abort

[Install]
WantedBy=multi-user.target

#systemctl daemon-reload

#systemctl start gitea

#systemctl enable gitea


版权声明:本文为weixin_44330881原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。