Reference documentation for http://gogs.IO/docs/installation
The way I am using package management install.
[root@yy ~]# cat /etc/redhat-release
CentOS release 6.6 (Final)
[root@yy ~]# cat /etc/issue
CentOS release 6.6 (Final)
Kernel \r on an \m
[root@yy ~]# uname -a
Linux yy 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
[root@yy ~]# uname -r
2.6.32-504.el6.x86_64
1. the import package file validation and add yum gogs warehouse
[root@yy ~]# rpm –import https://rpm.packager.io/key
[root@yy ~]# echo “[gogs]
> name=Repository for pkgr/gogs application.
> baseurl=https://rpm.packager.io/gh/pkgr/gogs/centos6/pkgr
> enabled=1″ | sudo tee /etc/yum.repos.d/gogs.repo
[gogs]
name=Repository for pkgr/gogs application.
baseurl=https://rpm.packager.io/gh/pkgr/gogs/centos6/pkgr
enabled=1
[root@yy ~]#
[root@yy ~]# cat /etc/yum.repos.d/gogs.repo
[gogs]
name=Repository for pkgr/gogs application.
baseurl=https://rpm.packager.io/gh/pkgr/gogs/centos6/pkgr
enabled=1
2. install the gogs
[root@yy ~]# yum install gogs -y
3. configure a temporary variable
APP_NAME=”gogs”
MYSQL_PASSWORD=”123456789″
HOSTNAME=”www.yuanyang.com”
4. install MySQL
[root@yy ~]# yum install mysql-server -y
[root@yy ~]# service mysqld restart
[root@yy ~]# chkconfig mysqld
[root@yy ~]# chkconfig –list mysqld
Mysqld 0: off 1: off 2: off 3: off 4: off 5: off 6: off
5. Configuring MySQL
[root@yy ~]# mysqladmin -u root password “ABCabc123”
[root@yy ~]# mysql -u root -pABCabc123
mysql> CREATE DATABASE IF NOT EXISTS gogs;
Query OK, 1 row affected (0.00 sec)
mysql> use gogs;
Database changed
mysql> set global storage_engine=INNODB;
Query OK, 0 rows affected (0.00 sec)
6. install and configure Apache
Install nginx website, Internet reason because I here, and there is a Apache server itself, so do with Apache.
Gogs itself contains the Web feature, the port defaults to 3000, we use Apache reverse proxy feature, use port 80 access.
[root@yy tools]# yum install -y httpd httpd-devel
[root@yy tools]# vim /etc/httpd/conf/httpd.conf
Finally add the following content of the configuration file, which, depending on your situation changes.
<VirtualHost *:80>
ServerAdmin [email protected]
ServerAlias www.abc.com
ProxyPreserveHost On
ProxyRequests Off
<Proxy *>
AddDefaultCharset off
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
ErrorLog /etc/httpd/logs/error.log
CustomLog /etc/httpd/logs/access.log combined
</VirtualHost>
Start Apache
[root@yy logs]# service httpd restart
Check whether the port and service start
[root@yy logs]# lsof -i tcp:3000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
gogs 2886 gogs 4u IPv6 20047 0t0 TCP *:hbci (LISTEN)
[root@yy logs]# lsof -i tcp:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 3545 root 4u IPv6 25412 0t0 TCP *:http (LISTEN)
httpd 3547 apache 4u IPv6 25412 0t0 TCP *:http (LISTEN)
httpd 3548 apache 4u IPv6 25412 0t0 TCP *:http (LISTEN)
httpd 3549 apache 4u IPv6 25412 0t0 TCP *:http (LISTEN)
httpd 3550 apache 4u IPv6 25412 0t0 TCP *:http (LISTEN)
httpd 3551 apache 4u IPv6 25412 0t0 TCP *:http (LISTEN)
httpd 3552 apache 4u IPv6 25412 0t0 TCP *:http (LISTEN)
httpd 3553 apache 4u IPv6 25412 0t0 TCP *:http (LISTEN)
httpd 3554 apache 4u IPv6 25412 0t0 TCP *:http (LISTEN)
httpd 3555 apache 4u IPv6 25412 0t0 TCP *:http (LISTEN)
Closing the waterproof wall and SELinux
[root@yy logs]# service iptablers stop
[root@yy logs]# setenforce 0
Configured in your browser after you enter here http://you_ipaddress you can access the
7. configure Apache to use HTTPS access gogs
[root@yy logs]# yum install openssl mod_ssl -y
See if all three files
[root@yy conf.d]# ls /etc/pki/tls/certs/localhost.crt
/etc/pki/tls/certs/localhost.crt
[root@yy conf.d]# ls /etc/pki/tls/private/localhost.key
/etc/pki/tls/private/localhost.key
[root@yy conf.d]# ls /etc/httpd/conf.d/ssl.conf
/etc/httpd/conf.d/ssl.conf
[root@yy conf.d]# vim /etc/httpd/conf.d/ssl.conf
Modify the SSL configuration file at the end of the </VirtualHost> front plus the following
ProxyPass /git http://127.0.0.1:3000
ProxyPassReverse /git http://127.0.0.1:3000
<Location /git>
Order allow,deny
Allow from all
</Location>
8. modify the gogs profile
[root@yy conf.d]# cd /opt/gogs/custom/conf/
[root@yy conf]# ls
app.ini
[root@yy conf]# cp app.ini app.ini.back
[root@yy conf]# vim app.ini
Modify the configuration file
Find DOMAIN = localhost, and turned it into a DOMAIN = 172.16.1.231 (IP or domain name of the server)
ROOT_URL =% (PROTOCOL) s://% (DOMAIN) s:% (HTTP_PORT) s/preceded by # comment out this line.
And change
ROOT_URL = https://172.16.1.231/git if there is a domain name, replace the IP domain name
The following figure:
Gogs and restart Apache
[root@yy conf]# /etc/init.d/gogs restart
This job runs via upstart, invoking upstart now…
gogs start/running
[root@yy conf]# service httpd restart
Stopping httpd: [determine]
Starting httpd:httpd:apr_sockaddr_info_get () failed for yy
httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName
[Determine]
Use https://you_ipaddress/git to access gogs
Now you can follow the installation wizard to complete the Web