赞
踩
以下教程为在Ubuntu16.04上搭建gitea1.14.1,同时附上官方教程链接
本教程采用的数据库为MySQL
mysql -uroot -p
password
密码可以设置为自己的密码,这里采用gitea作为用户密码
SET old_passwords=0;
CREATE USER 'gitea' IDENTIFIED BY 'gitea';
这里采用utf8mb4而不是utf8作为字符集,是因为utf8mb4支持的Unicode字符更多
CREATE DATABASE giteadb CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_unicode_ci';
GRANT ALL PRIVILEGES ON giteadb.* TO 'gitea';
FLUSH PRIVILEGES;
exit # 退出数据库
mysql -ugitea -p
password
本教程采用二进制文件安装
这里下载的gitea版本为1.14.1,新版本可以查看此链接
wget -O gitea https://dl.gitea.io/gitea/1.14.1/gitea-1.14.1-linux-amd64
chmod +x gitea
git --version
需要在root用户下执行
adduser \
--system \
--shell /bin/bash \
--gecos 'Git Version Control' \
--group \
--disabled-password \
--home /home/git \
git
mkdir -p /var/lib/gitea/{custom,data,log}
chown -R git:git /var/lib/gitea/
chmod -R 750 /var/lib/gitea/
mkdir /etc/gitea
chown root:git /etc/gitea
chmod 770 /etc/gitea
touch /etc/gitea/app.ini
chown root:git /etc/gitea/app.ini
chmod 770 /etc/gitea/app.ini
这里官方安装教程提示只是临时将/etc/gitea设置了用户git的写入权限,在web的安装过程中就可以写入配置文件,在安装完成后,可以通过以下命令将权限修改为只读
chmod 750 /etc/gitea
chmod 640 /etc/gitea/app.ini
cp gitea /usr/local/bin/gitea
这里采用官方推荐的通过创建一个service file来自动启动gitea
将以下内容写入到/etc/systemd/system/gitea.service中,因为本教程采用的是MySQL数据库,所以同时将有关MySQL配置的注释打开,如果采用其他的数据可以打开其他注释并将MySQL的配置注释了
[Unit] Description=Gitea (Git with a cup of tea) After=syslog.target After=network.target ### # Don't forget to add the database service requirements ### # Requires=mysql.service #将此注释打开 #Requires=mariadb.service #Requires=postgresql.service #Requires=memcached.service #Requires=redis.service # ### # If using socket activation for main http/s ### # #After=gitea.main.socket #Requires=gitea.main.socket # ### # (You can also provide gitea an http fallback and/or ssh socket too) # # An example of /etc/systemd/system/gitea.main.socket ### ## ## [Unit] ## Description=Gitea Web Socket ## PartOf=gitea.service ## ## [Socket] ## Service=gitea.service ## ListenStream=<some_port> ## NoDelay=true ## ## [Install] ## WantedBy=sockets.target ## ### [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 RestartSec=2s Type=simple User=git Group=git WorkingDirectory=/var/lib/gitea/ # If using Unix socket: tells systemd to create the /run/gitea folder, which will contain the gitea.sock file # (manually creating /run/gitea doesn't work, because it would not persist across reboots) #RuntimeDirectory=gitea ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini Restart=always Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea # If you install Git to directory prefix other than default PATH (which happens # for example if you install other versions of Git side-to-side with # distribution version), uncomment below line and add that prefix to PATH # Don't forget to place git-lfs binary on the PATH below if you want to enable # Git LFS support #Environment=PATH=/path/to/git/bin:/bin:/sbin:/usr/bin:/usr/sbin # If you want to bind Gitea to a port below 1024, uncomment # the two values below, or use socket activation to pass Gitea its ports as above ### #CapabilityBoundingSet=CAP_NET_BIND_SERVICE #AmbientCapabilities=CAP_NET_BIND_SERVICE ### [Install] WantedBy=multi-user.target
sudo systemctl enable gitea
sudo systemctl start gitea
url链接为http://serverip:3000/
默认即可
选择此选项意味着只能通过管理员来手动创建用户账户
点击install Gogs之后便可登录
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。