Wang Xiaoer blogs at itwxe.com

First, build the environment and premise

Setting up the environment:

Operating system: CentOS7.6

Docker version: Docker-CE-18.09.9

Lsky Pro version: 1.6.3

MySQL version: 5.7

Install the prerequisite

Gitea can be stored as a database using MySQL, PostgreSQL, MSSQL, or SQLite3. If you are familiar with one of these databases, you can select the corresponding database. I chose MySQL.

If you already have Docker and MySQL installed, you can skip this step. If you don’t have these two environmental buddies, check out the following two articles separately.

  • Install Docker:www.itwxe.com/posts/ca163…
  • Install MySQL:www.itwxe.com/posts/53489…

After installing MySQL, you need to create database gitea, which will be used in subsequent configuration. The command and screenshot are as follows:

Enter the docker mysql container
docker exec -it mysql /bin/bash
# login MySQL
mysql -uroot -p
# Create database lsky
create database if not exists gitea default character set = 'utf8mb4';
Create user name and password 123456 to connect to gitEA database
GRANT ALL PRIVILEGES ON gitea.* TO 'gitea'@The '%' IDENTIFIED BY '123456';
FLUSH PRIVILEGES;
Copy the code

Docker install Gitea

Gitea official Chinese document address: docs.gitea. IO /zh-cn/insta…

Start the Gite container by running the command:

docker run -d --restart=always --name=gitea -p 10022:22 -p 13000:3000 -v /itwxe/dockerData/gitea:/data Gitea/gitea: 1.14.6Copy the code

After starting the container, I need to access it with the domain name, so after configuring the domain name mapping in the DNS console, Nginx configuration reference is as follows:

    server {
        listen 443 ssl;
        server_name gitea.itwxe.com;
        ssl_certificate /usr/local/nginx/ssl/any/fullchain.cer;
        ssl_certificate_key /usr/local/nginx/ssl/any/itwxe.com.key;
        ssl_session_cache shared:SSL:1m;
        ssl_session_timeout 30m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphersHIGH:! aNULL:! MD5:! EXPORT56:! EXP;ssl_prefer_server_ciphers on;
        proxy_connect_timeout 500;
        proxy_send_timeout 500;
        proxy_read_timeout 500;
        client_max_body_size 50m;

        location / {
            proxy_pass http://127.0.0.1:13000;
            proxy_set_header Host $host;
            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_headerREMOTE-HOST $remote_addr; }}Copy the code

After the configuration is complete, nginx -t verifies that the configuration is correct. If the configuration is correct, nginx -s reload reloads nginx.

Access the configured domain name and start the interface configuration installation. There are several points to note.

There are some optional Settings below, so you can set them according to your needs.

After setting, click Install now. When the installation is complete, you can see what the home screen looks like.

At this point, Gitea is set up. After that, let’s create a warehouse and see if it can be uploaded properly. Test the warehouse to use my blog code to test.

First create a warehouse, this need not say much, the full interface operation, dot dot is finished, create the finished interface and buttons as shown in figure.

The figure also shows how to submit to the remote repository. This is the basic Git skills, which will not be described in detail. You need to use SSH to configure SSH by yourself, and GENERALLY I use HTTPS.

At this point, you are finished building your own Git service based on Gitea.

Now that you’ve read this, like, comment, follow, or collect it!