ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# [===>gitea 官网](https://docs.gitea.io/zh-cn/install-with-docker/) # [Linux上搭建gitea](https://segmentfault.com/a/1190000021956914) ## 二进制安装 **1、安装`MySQL`/`Mariadb`数据库** ~~~undefined 安装完成后,安装MySQL,至少5.5.3版本。 ~~~ **2、安装Git** ~~~cmake #Debian和Ubuntu系统 apt-get -y install git #CentOS系统 yum -y install git ~~~ **3、安装Gitea** 最新版本下载地址:[https://dl.gitea.io/gitea](https://link.segmentfault.com/?enc=ZtQHEZHt6NmSAVXe95NpZA%3D%3D.XF2WTEX5ZLLme43kzFzZLi1KRTrgnEd3ScCNTAWdLc0%3D)。 ~~~awk cd /usr/local/gitea wget -O gitea https://dl.gitea.io/gitea/1.6.0/gitea-1.6.0-linux-amd64 chmod +x gitea #添加用户 useradd gitea #设置权限 chown -R gitea:gitea /usr/local/gitea ./gitea web ~~~  ​​​​接下来打开[http://ip](https://link.segmentfault.com/?url=http%3A%2F%2Fip%2F):3000即可。 **4、域名访问** 如果想用域名访问,可以用Nginx反代。反代配置为: ~~~nginx #在配置文件里添加 location / { proxy_pass http://localhost:3000 proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } ~~~  ​**5、使用服务来启动** 新建一个rclone.service文件: ~~~awk vi /usr/lib/systemd/system/gitea.service ~~~ 写入: ~~~ini [Unit] Description=gitea [Service] User=root ExecStart=/usr/local/gitea/gitea Restart=on-abort [Install] WantedBy=multi-user.target ~~~ ``` [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=/var/lib/gitea/ ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea Restart=always [Install] WantedBy=multi-user.target ```  重载daemon,让新的服务文件生效: ~~~ebnf systemctl daemon-reload ~~~ 现在就可以用systemctl来启动gitea了: ~~~crmsh systemctl start gitea ~~~ 设置开机启动: ~~~routeros systemctl enable gitea ~~~ 停止、查看状态可以用: ~~~fortran systemctl stop gitea systemctl status gitea ~~~  ​​​​​​​接下来就是打开网址去初始化gitea配置。 ***** **docker版本** 1.新建 **.env** ``` # gitea GITEA_USER_UID=1000 GITEA_USER_GID=1000 GITEA_DB_TYPE=mysql GITEA_DB_HOST=mysql:3306 GITEA_DB_NAME=gitea GITEA_DB_USER=gitea GITEA_DB_PASSWD=8e0855eb612dea2a # Mysql MYSQL_ROOT_PASSWORD=8e0855eb612deppp MYSQL_USER=gitea MYSQL_PASSWORD=8e0855eb612dea2a MYSQL_DATABASE=gitea ``` 2.docker-compose.yml ``` version: "3" services: mysql: image: mysql:5.7.27 environment: MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:?err} MYSQL_USER: ${GITEA_DB_USER:?err} MYSQL_PASSWORD: ${GITEA_DB_PASSWD:?err} MYSQL_DATABASE: ${GITEA_DB_NAME:?err} volumes: - ./mysql-data:/var/lib/mysql networks: - gitea restart: unless-stopped security_opt: - seccomp:unconfined logging: driver: "json-file" options: max-size: "10m" max-file: "3" gitea: image: gitea/gitea:1 depends_on: - mysql environment: USER_UID: ${GITEA_USER_UID:?err} USER_GID: ${GITEA_USER_GID:?err} DB_TYPE: ${GITEA_DB_TYPE:?err} DB_HOST: ${GITEA_DB_HOST:?err} DB_NAME: ${GITEA_DB_NAME:?err} DB_USER: ${GITEA_DB_USER:?err} DB_PASSWD: ${GITEA_DB_PASSWD:?err} volumes: - ./gitea-data:/data ports: - "222:22" - "3000:3000" networks: - gitea restart: unless-stopped logging: driver: "json-file" options: max-size: "10m" max-file: "3" networks: gitea: driver: bridge ```