Install Gogs build a personal warehouse on Linux

Source: Internet
Author: User
Tags install go nginx reverse proxy

Gogs is a github-like open source file/code management system (based on Git), it's very simple to build, and can be used to build a personal private warehouse

Install Mysql,nginx (nginx as reverse proxy) before installing Gogs.

Create a git user

Gogs Run as a git user by default

    • New Git user
adduser git
    • Log in as a git user
su git

CD to git user home directory/home/git new. SSH folder permissions set to 0755

Install Go

    1. The latest binary installation package is available on the Go Language website
wget https://storage.googleapis.com/golang/go1.5.2.linux-386.tar.gztar xzvf go1.5.2.linux-386.tar.gzmv go /usr/local/lib/go

Install the Go Language runtime environment

Gogs is written by the go language and needs to be installed Golang running environment
If other programs in the system do not need to run the Go Language program, you can configure the runtime environment only for the GIT user created above, or choose to configure the Go language runtime for all users of the system

    1. Configure environment variables, switch to user git, and configure the go run environment for that user only
su gitcd ~
    1. Write Environment variables
      vim /etc/profileLast line Join
export PATH=$PATH:/usr/local/lib/go/bin
    1. Make environment variables effective
source /etc/profile

The Go language runtime installation is complete

    1. Test if the Golang is installed successfully
go env

Installing Gogs

    1. Download the precompiled Binary installation package
      Install package versions Address: Https://gogs.io/docs/installation/install_from_binary
su gitcd ~wget -c http://7d9nal.com2.z0.glb.qiniucdn.com/gogs_v0.8.10_linux_386.tar.gztar zxf gogs_v0.8.10_linux_386.tar.gz
    1. Set up a database
      /home/git/gogs/scripts/mysql.sql is a database initialization file
      Tip: The database must support the INNODB engine
cd gogsmysql -u root -p < scripts/mysql.sql #(需输入密码)即可初始化好数据库
    1. Log in to MySQL to create a new user Gogs and assign all permissions for the database gogs to that user
mysql -u root -pgrant all privileges on gogs.* to 'gogs'@'localhost' identified by '密码';flush privileges;exit;
    1. Edit Gogs/scripts/supervisor/gogs Modify the following
directory=/home/git/gogs/command=/home/git/gogs/gogs web

Everyone changes according to the actual path

Nginx Reverse Proxy

    1. http
server {    server_name 域名或IP;    listen 80;    location / { # 如果你希望通过子路径访问,此处修改为子路径,注意以 / 开头并以 / 结束        proxy_pass http://127.0.0.1:3000/;    }}
    1. Https
server {    listen 443 ssl;    server_name 域名或IP;    ssl_certificate /path/to/gogs.io.unified.crt;    ssl_certificate_key /path/to/gogs.io-decrypted.key;    location / {        proxy_set_header X-Real-IP $remote_addr;        proxy_pass http://localhost:3000 $request_uri;    }}

Detailed configuration

The configuration file is in the Gogs directory custom/conf/app.ini , which is a text file in INI format. For detailed configuration explanations and default values please refer to the official documentation, where the key configuration is probably the following.

    • RUN_USERBy default git , specifies which user gogs to run
    • ROOTStorage root path for all warehouses
    • PROTOCOLIf you use the Nginx anti-generation, please use http , if the direct naked run to the external service, casual
    • DOMAINDomain name. Will affect the SSH clone address
    • ROOT_URLThe full root path affects the point at which the link on the page is accessed, and the address of the HTTP clone
    • HTTP_ADDRListen to the address, using Nginx suggestions 127.0.0.1 , otherwise 0.0.0.0 you can also
    • HTTP_PORTListening Port, default3000
    • INSTALL_LOCKLock the Installation page
    • Mailer related options

Mailer can use Mailgun's free mail delivery service to fill the Mailgun SMTP configuration into the configuration.

Run Gogs

    1. Manually turn on Gogs
su gitcd ~/gogs./gogs web
    1. Join Service Run
      Copy/home/git/gogs/scripts/init/debian/gogs to/ETC/INIT.D
      Root user under Service Gogs stop|start|restart|reload|status

CentOS Installation: https://www.jianshu.com/p/c9ca7c16bd1f

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.