centos6.6安裝web版GIT   gogs

centos6.6安装gogs

参考文档 http://gogs.io/docs/installation

我使用的是包管理的方式进行安装的。

[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.导入包校验文件并添加gogs的yum仓库

[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.安装gogs

[root@yy ~]# yum install gogs -y

3.配置临时变量

APP_NAME=”gogs”
MYSQL_PASSWORD=”123456789”
HOSTNAME=”www.yuanyang.com”

4.安装mysql

[root@yy ~]# yum install mysql-server -y
[root@yy ~]# service mysqld restart
[root@yy ~]# chkconfig mysqld
[root@yy ~]# chkconfig --list mysqld
mysqld 0:关闭1:关闭2:关闭3:关闭4:关闭5:关闭6:关闭

5.配置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.安装和配置apache

官网是安装的nginx,因为我这里网络的原因,和服务器本身就有一个apache,所以就用apache来做。

gogs本身就带有web功能,端口默认为3000,我们使用apache反向代理功能,使用80端口访问.

[root@yy tools]# yum install -y httpd httpd-devel

[root@yy tools]# vim /etc/httpd/conf/httpd.conf

在配置文件最后加上下面的内容,具体请根据自己的情况修改。

<VirtualHost *:80>
ServerAdmin yuanyang@yuanyang.com

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>

启动apache

[root@yy logs]# service httpd restart

检查端口和服务是否启动

[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)

关闭防水墙和selinux

[root@yy logs]# service iptablers stop
[root@yy logs]# setenforce 0

这里配置好了后在浏览器中输入http://you_ipaddress就可以访问了




    		    centos6.6安裝web版GIT &nbsp; gogs

7.配置apache使用https方式访问gogs

[root@yy logs]# yum install openssl mod_ssl -y

查看是否生成了这三个文件

[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

修改ssl配置文件在最后的</VirtualHost> 前面加上如下内容

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.修改gogs配置文件

[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

修改配置文件

找到DOMAIN = localhost,把它改成DOMAIN = 172.16.1.231(服务器的IP或者域名)

把ROOT_URL = %(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s/这一行前面加#注释掉。

并改成

ROOT_URL = https://172.16.1.231/git 如果有域名的话把那个IP换成域名

如下图:




    		    centos6.6安裝web版GIT &nbsp; gogs

重启gogs和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

停止 httpd: [确定]
正在启动 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
[确定]

使用https://you_ipaddress/git访问gogs




    		    centos6.6安裝web版GIT &nbsp; gogs

现在你可以按照安装向导完成你的web版GIT gogs的配置了。

本文出自 “蒲公英的秘密” 博客,请务必保留此出处http://yylinfan.blog.51cto.com/8670422/1695714

Database error: [Table 'ac_search_cache' is marked as crashed and should be repaired]

SELECT * FROM ac_search_cache WHERE hash = '557539e6b7938b6ba4ec65e2938fde101d25a605' LIMIT 1;