关闭SELinux

$ sudo vi /etc/sysconfig/selinux
SELINUX=disabled

安装PostgreSQL 10

$ sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
$ sudo yum install -y postgresql10-server

/* 修改数据库路径 */
$ sudo vi /usr/lib/systemd/system/postgresql-10.service/
Environment=PGDATA=/opt/storage1/pgsql

$ sudo /usr/pgsql-10/bin/postgresql-10-setup initdb
$ sudo systemctl enable postgresql-10
$ sudo systemctl start postgresql-10

重置postgres密码

删除密码

$ sudo passwd -d postgres
passwd: password expiry information changed.

设置新密码

$ sudo -u postgres passwd
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully

验证新密码

$ sudo -u postgres psql

安装Nginx

这里图个省事就不编译安装了

$ sudo vi /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key

$ sudo yum install nginx

$ sudo vi /etc/nginx/conf.d/gogs.conf
server {
    listen 80;
    server_name mygit;

    # fix | error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413 Request Entity Too Large
    client_max_body_size 100m;

    location / {
        proxy_pass http://localhost:3000;
    }
}

$ sudo systemctl enable nginx
$ sudo systemctl start nginx

/* 防火墙配置 */
$ sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
$ sudo firewall-cmd --reload

安装Gogs

$ wget https://dl.gogs.io/0.12.1/gogs_0.12.1_linux_amd64.tar.gz
$ tar -xvf gogs_0.12.1_linux_amd64.tar.gz

/* 需要git支持 */
$ sudo yum install git

$ sudo vi /etc/systemd/system/gogs.service
[Unit]
Description=Gogs
After=syslog.target
After=network.target
After=mariadb.service mysqld.service postgresql.service memcached.service redis.service
 
[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
Type=simple
User=wii
Group=wii
WorkingDirectory=/home/wii/gogs
ExecStart=/home/wii/gogs/gogs web
Restart=always
Environment=USER=wii HOME=/home/wii
 
[Install]
WantedBy=multi-user.target

$ sudo systemctl enable gogs
$ sudo systemctl start gogs

其它一些配置

$ cat .ssh/config 
host wfeii.com
        hostname wfeii.com
        port 27646
        IdentityFile ~/.ssh/mygit
        IdentitiesOnly yes
$ sudo vi /etc/default/grub
GRUB_TIMEOUT=0

$ sudo grub2-mkconfig -o /boot/grub2/grub.cfg



postgresql 10升11

安装并初始化11版本库

$ sudo yum install -y postgresql10-server
$ sudo vi /usr/lib/systemd/system/postgresql-11.service
Environment=PGDATA=/opt/storage1/pgsql11

$ sudo /usr/pgsql-11/bin/postgresql-11-setup initdb

升级

$ su - postgres
$ /usr/pgsql-10/bin/pg_ctl stop -m fast -D /opt/storage1/pgsql

; 测试
$ /usr/pgsql-11/bin/pg_upgrade -c -j 2 -U postgres -b /usr/pgsql-10/bin/ -B /usr/pgsql-11/bin/ -d /opt/storage1/pgsql -D /opt/storage1/pgsql11
; 升级
$ /usr/pgsql-11/bin/pg_upgrade -j 2 -U postgres -b /usr/pgsql-10/bin/ -B /usr/pgsql-11/bin/ -d /opt/storage1/pgsql -D /opt/storage1/pgsql11
$ ./analyze_new_cluster.sh

清理

$ sudo systemctl stop postgresql-10
$ sudo systemctl disable postgresql-10

$ sudo systemctl enable postgresql-11
$ sudo systemctl start postgresql-11

错误处理

FATAL:  Ident authentication failed for user "git"
DETAIL:  Connection matched pg_hba.conf line 82: "host    all             all             127.0.0.1/32            ident"
$ sudo vi pgsql11/pg_hba.conf
host    all             all             127.0.0.1/32            ident
-----------------------------------------------------------------------
host    all             all             127.0.0.1/32            md5



raspberry_pi安装gogs环境

4B

$ sudo apt-get install postgresql-11
$ sudo /etc/init.d/postgresql stop
$ sudo pg_dropcluster --stop 11 main
$ sudo pg_createcluster --locale en_US.UTF-8 -d /opt/storage2/pgsql 11 main
$ sudo /etc/init.d/postgresql start
sudo su - postgres psql
postgres=# SHOW data_directory;  # 查看目录
postgres=# ALTER USER postgres PASSWORD '你的postgres密码';  # 为postgres修改密码

错误与处理

$ psql < dumpall.sql
ERROR:  invalid locale name: "en_US.UTF-8"

$ apt-get install locales
$ dpkg-reconfigure locales


源码交叉编译树莓派版本(arm)的gogs

$ git clone https://github.com/gogs/gogs.git
$ git checkout v0.12.3
$ CGO_ENABLED=0 GOOS=linux GOARCH=arm go build gogs.go

$ file gogs
gogs: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, Go BuildID=0wYfHkwPV4pz2XlYpy0h/in0Oqr7mdoQL8nwMPHI8/d7VFMtSCOdFlEu-y6DJa/7EtI1ZtIVl27MFY_-fay, not stripped

关于配置app.ini

源码中的完整配置 可供参考

[service]
# 关闭注册功能/隐藏注册按钮
DISABLE_REGISTRATION   = true
# 禁止匿名用户访问网站/强制登录
REQUIRE_SIGNIN_VIEW    = true