原创 如何在Linux下部署Git+Bugzilla+Gogs服务

2017-1-15 15:29 4452 6 6

如果需要在小团队内做代码协同,Git+Bugzilla+Gogs是不错的选择,因为它们免费、开源且轻量。


以下操作会同时在Fedora24和Ubuntu14.04 LTS下进行。


遇到任何问题,都可以参考Git、Bugzilla和Gogs的官方文档。


===============================================================================


第一步:安装Git


其实在Linux系统下,安装软件有许多种方法,可以从软件源里安装,也可以使用源代码编译。


这里只使用软件源安装方法,其他方法殊途同归。


在Fedora下:


dnf update


dnf install git


dnf install git-gui


在Ubuntu下:


apt-get update


apt-get dist-upgrade


apt-get install git


apt-get install git-gui


使用git和git gui:


$ git config --global user.name [username]


$ git config --global user.email [email]


$ git gui


推荐先升级一下系统,刷新一下软件源列表。


git-gui是我习惯使用的Git图形界面,你也可以安装类似的图形界面,或者不安装。


用户名和邮箱是一定要配置的,否则无法正常使用Git。


===============================================================================


第二步:安装数据库PostgreSQL


在Fedora下:


dnf install postgresql-server


psql -V


postgresql-setup --initdb


systemctl start postgresql.service


systemctl enable postgresql.service


systemctl status postgresql.service


在Ubuntu下:


apt-get install postgresql


psql -V


service postgresql start


service postgresql status


apt-get install bum


bum


新建用户的命令是一样的:


cd /var


su - postgres


$ createuser -U postgres -dRSP bugs


$ createuser -U postgres -dRSP gogs


然后配置数据库:


cd /var/lib/pgsql/data/


cd /etc/postgresql/9.3/main/


vim postgresql.conf



  • listen_addresses = 'localhost'


  • listen_addresses = '*'


vim pg_hba.conf


-host all all 127.0.0.1/32 ident


+host all all 127.0.0.1/32 trust


-host all all ::1/128 ident


+host all all ::1/128 trust


安装好PostgreSQL之后,使能服务,并使用“systemctl enable”或者“bum”保证开机自动启动。


然后为它们新添用户,一个名为bugs(Bugzilla),一个名为gogs(Gogs),密码都为空。


接着配置PostgreSQL的权限,配置完成之后要重启PostgreSQL服务。


最后为PostgreSQL服务打开防火墙。


===============================================================================


第三步:安装Bugzilla


在Fedora下:


dnf install bugzilla


/usr/share/bugzilla/checksetup.pl --check-modules


dnf install "perl(::)"


/usr/share/bugzilla/checksetup.pl


cd /etc/bugzilla/


vim localconfig



  • $db_driver = 'mysql';


  • $db_driver = 'Pg';



/usr/share/bugzilla/checksetup.pl


cd /etc/httpd/conf.d


vim bugzilla.conf



  • AllowOverride Limit Options FileInfo Indexes


  • AllowOverride All



systemctl start httpd.service


systemctl enable httpd.service


systemctl status httpd.service


在Ubuntu下:


apt-get install apache2


apt-get install postgresql-server-dev-9.3


cd /var/www/html


git clone --branch release-5.0-stable \


https://github.com/bugzilla/bugzilla bugzilla

vim /etc/apache2/sites-available/bugzilla.conf



  • ServerName localhost



  • AddHandler cgi-script .cgi


  • Options +ExecCGI


  • DirectoryIndex index.cgi index.html


  • AllowOverride All




a2ensite bugzilla


service apache2 reload


a2enmod cgi headers expires


service apache2 restart


cd /var/www/html/bugzilla/


./checksetup.pl


/usr/bin/perl install-module.pl --all


./checksetup.pl


vim localconfig



  • $webservergroup = "apache"


  • $webservergroup = "www-data"


  • $db_driver = 'mysql';


  • $db_driver = 'Pg';



/usr/share/bugzilla/checksetup.pl


在Ubuntu下需要安装postgresql-server的devel文件,执行checksetup.pl时会有提示。


如果checksetup.pl成功,则会要求输入管理员的用户名和密码,按照实际情况设置即可。


Bugzilla的安装看起来比较复杂,但可以归结为几个基本步骤:


1.安装httpd(Fedora24已自带)或apache2(Ubuntu需安装);


2.安装Bugzilla及它需要的所有Perl模块,全部安装比较省事;


3.修改Bugzilla和httpd(或apache2)服务的配置,使能Bugzilla页面;


4.使能httpd(或apache2)服务的防火墙;


5.启动服务。


在浏览器中输入下面的地址,验证是否成功安装:


http://127.0.0.1/


http://127.0.0.1/bugzilla/


配置Bugzilla邮件服务需要关闭SELinx!


配置Bugzilla邮件服务需要关闭SELinx!


配置Bugzilla邮件服务需要关闭SELinx!


一般来说,安装过程不会easy,这时候就要发挥开源软件挖坑添坑的艰苦作业精神,反复尝试,直到成功。


祝大家在此过程中得到快乐,哈哈!


===============================================================================


第四步:安装Gogs


在Fedora下:


dnf install mercurial


dnf install golang


go version


$ vim ~/.bashrc



  • export GOPATH=/home/xxx/go


  • export GOROOT=/usr/lib/golang


  • export PATH=${PATH}:$GOROOT/bin



$ source ~/.bashrc


$ go get -u github.com/gogits/gogs


$ cd $GOPATH/src/github.com/gogits/gogs


$ go build


$ ./gogs web


目前在Ubuntu下有坑未填:


$ go get -u github.com/gogits/gogs


src/github.com/gogits/gogs/modules/setting/setting.go:24:2: code in directory /home/xxx/go/src/github.com/strk/go-libravatar expects import "strk.kbt.io/projects/go/libravatar"


等待添坑的过程可谓煎熬,这就是开源软件的弊端,你不给钱,就不能催更!


如果有兴趣,可以在Ubuntu下尝试以下步骤。也许Gogs已经解决了这个Bug ^_^


apt-get install mercurial


cd /usr/local/


wget https://storage.googleapis.com/golang/go1.6.3.linux-386.tar.gz


tar xvf go1.6.3.linux-386.tar.gz


/usr/local/go/bin/go version


rm /etc/alternatives/go


ln -s /usr/local/go/bin/go /etc/alternatives/go


which go


$ vim ~/.bashrc



  • export GOPATH=/home/xxx/go


  • export GOROOT=/usr/local/go


  • export PATH=${PATH}:$GOROOT/bin



$ source ~/.bashrc


$ go get -u github.com/gogits/gogs


$ cd $GOPATH/src/github.com/gogits/gogs


$ go build


$ ./gogs web


在Ubuntu下,我们可以采用更简单的方法,将对应版本的二进制包下载并解压,然后进入目录执行:


$ ./gogs web


嗒答!嗒答!嗒答!!!掌声有木有?!总之很Easy就是了!


现在来配置数据库PostgreSQL,Bugazilla会在安装过程中创建,但Gogs不会。


创建名为gogs的数据库:


su - postgres


$ createdb -O gogs gogs


$ exit


service postgres restart


在浏览器中输入下面的网址,验证Gogs是否安装成功:


http://127.0.0.1:3000


===============================================================================


第五步:安装和配置supervisor:


首先通过软件源安装supervisor,然后修改其/etc下的配置文件supervisord.conf:



  • [program:gogs]


  • directory=/home/xxx/go/src/github.com/gogits/gogs/


  • command=/home/xxx/go/src/github.com/gogits/gogs/gogs web


  • autostart=true


  • autorestart=true


  • startsecs=10


  • stdout_logfile=/var/log/gogs/stdout.log


  • stdout_logfile_maxbytes=1MB


  • stdout_logfile_backups=10


  • stdout_capture_maxbytes=1MB


  • stderr_logfile=/var/log/gogs/stderr.log


  • stderr_logfile_maxbytes=1MB


  • stderr_logfile_backups=10


  • stderr_capture_maxbytes=1MB


  • environment = HOME="/home/xxx", USER="xxx"


  • user = xxx



接着创建目录/var/log/gogs,使用命令启动supervisord服务。


观察运行情况:


cat /var/log/gogs/stdout.log


cat /var/log/gogs/stderr.log


cat /var/log/httpd/error_log


最后,祝大家在开源软件的世界里畅游愉快!


PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
我要评论
0
6
关闭 站长推荐上一条 /3 下一条