其他的144hu.com几个进口,都试过了wwW144hu.comcom还是没能登上。

404 Not Found
404 Not Found
The requested URL was not found on this server.
您要找的内容已被删除133,091被浏览8,055,161分享邀请回答mp.weixin.qq.com/s/A4qhTKoNVDGaSyGiR08nvA建议想系统、高效学英语的同学,关注微信公众号:六浪记 我将更详细的写英语学习的方法论。欢迎大家关注。58K1,702 条评论分享收藏感谢收起29K964 条评论分享收藏感谢收起609被浏览18,807分享邀请回答7925 条评论分享收藏感谢收起375 条评论分享收藏感谢收起gerrit的部署,配置和使用记录
时间: 19:25:40
&&&& 阅读:448
&&&& 评论:
&&&& 收藏:0
标签:&&&&&&&&&&&&&&&&&&&&&&&&&&&&
一、&&&&&&&&&&& apache服务的安装
1.&&&&& 安装Apache
有两种时候可以安装Apache服务器:安装Linux操作系统的时候安装Web服务器rpm包,和安装完系统后安装Apache服务器。(源码安装)
提示:可以用命令#rpm-qa|grep httpd检查一个系统是否安装了Apache服务器,如果没有输出,则表明没有安装。以下为某个安装了Apache服务器输出的一个范例。如果是以源码安装的Apache服务器,则此种方法无效,需要用find工具查找httpd文件是否存在。
httpd-tools-2.2.15-9.el6.x86_64
httpd-manual-2.2.15-9.el6.noarch
httpd-2.2.15-9.el6.x86_64
如果在安装Linux操作系统期间没有安装Apache,这就需要使用包文件来安装。
1.RPM包的安装。从Linux的安装光盘和互联网上,都可以得到Apache的RPM安装包,然后把安装包复制到硬盘,并切换到安装包文件所在的目录。本文以httpd-2.2.15-9.el6.x86_64.rpm为例。执行命令:
# rpm-ivh httpd-2.2.15-9.el6.x86_64.rpm
然后再执行:
# rpm -ivh httpd-nanual-2.2.15-9.el6.x86_64.rpm
把手册也安装上去。
2.源码安装。到网站. org下载欲安装的版本,笔者喜欢尝试最新的版本,当前的最新有效版本为httpd-2.2.0.tar.gz。在httpd-2.2.0.tar.gz文件所在的当前目录解压文件# tar zxvf httpd-2.2.0.tar.gz,然后切换目录到httpd-2.2.0,进行配置:
#cd httpd-2.2.0.tar./configure--prefix=/usr/local/apache
顺利完成这步后,接着进行编译安装:
#make install。
其中,配置这一过程,使用了选项&--prefix=/usr/local/apache&来指定Apache的安装目录,使Apache服务器所需的大部分文件都被复制在这个目录里。实际上,配置是一个很灵活的选择,根据需要可以添加更多的选项,支持更多的功能。
2.&&&&& 配置文件
Apache的配置文件是httpd.conf,一般在/etc/http/conf或/usr/local/apache/conf目录,以rpm包形式安装的Apache,配置文件的位置是/etc/httpd/conf/httpd.conf。对Apache服务器进行得最多的操作恐怕就是在时时更改这个文件的内容。当然,如果只是运行简单的静态网页,也可以不用对它做任何更改。
打开配置文件httpd.conf,可以获悉根文档的目录位置。前面安装的Apache的根文档位置是/usr/local/apache/htdocs(rpm包安装的Apache的根文档位置是/var/www/html),欲运行自己的网站,需要把做好的网页文件和目录复制到Apache的根文档才可以。
3.&&&&& 上传网页文件及目录
上传网页文件及目录的最佳方式是启用FTP服务。创建一个系统用户,使该用户对目录/usr/local/apache/htdocs具有读写权限或者该用户的主目录为/user/local/apache/htdocs。在这里我们创建一个用户,使其主目录为Apache的根文档目录:
# useradd -d/usr/local/apache/htdocs Webuser //添加的用户为Webuser,
# passwd Webuser //给该用户设置一个访问密码。
这样就可以很方便地修改或上传网页文件和目录了。有人认为,用SSH客户端工具也可以实现文件的上传。
4.&&&&& 启用/关闭Apache服务
上面的步骤都准备好以后,就可以启用这个网站服务器了。启用方法如下:
# /usr/local/apache/bin/apachctl start&& //源码安装的启动方式
#/usr/local/apache/bin/apachectl stop
# service httpd start//rpm包安装的启动方式
# service httpd stop
如果不出意外,Apache服务器将如我们所期待的那样运行起来,我们只要在某台能访问Apache服务器的计算机浏览器里输入Apache服务器的IP地址或者预先解析好的域名,网站的主页就会出现在浏览器里。在Apache服务器端,通过输入命令:
# ps -aux|grep httpd
检查Apache服务器是否正在运行。到此,一个具备基本功能的Apache服务器就诞生了。
有时候,我们可能需要用一个Apache服务器来做多个Web服务器,比如运行几个不同的网站,这样就可以大大地节省开支。
使用虚拟主机大致有以下几个步骤:
1.确定使用虚拟主机的方式。虚拟主机有基于域名、IP、端口等几种形式,应该根据自己的实际情况来决定。
2.修改配置文件/etc/httpd/conf/httpd.conf或/usr/local/apache/conf/httpd.conf。3.域名解析(基于域名的虚拟主机),这一步需要在域名服务器上进行。
4.启用/关闭虚拟主机。启用/关闭Apache守护进程即可,但这将关闭所有的Web服务。
设置虚拟主机实例
讲述一个虚拟主机的实例。
先描述一下需求:一台服务器,要求运行一个以PHP为脚本的网站,另外还要用它来做网络流量监控(需要Web服务)。在这里,我们采用二进制源码包的方式来安装配置Apache虚拟服务器,以便于对Apache服务器有更深刻的理解。
(1)安装Apache服务器。从下载包httpd-2.2.0.tar.gz到目录/root,然后执行操作:
# tar zxvf&
httpd-2.2.0.tar.gz&&&&& //包解压
# cd # tar zxvf&
httpd-2.2.0.&&&&&&
#./configure --prefix=/usr/local/apache
--enable-module=most --enable-shared=max
# make install
至此,Apache就算安装好了。
先测试一下,运行命令:
# /usr/local/apache/bin/apachectl start
然后在与之联网的计算机的浏览器里输入运行Apache服务的计算机IP地址,出现测试页面表明配置一切正常。
(2)安装PHP。下载包php-4.3.11.tar.gz到目录/root,然后执行下面的操作:
# tar -zxvf
php-4.3.11.tar.gz&&& //解压文件
#./configure --prefix=/usr/local/php
--with-apxs2=/usr/local/apache/bin/apxs& //正常//完成后会在/usr/local/apache/modules 里生成文件libphp4.so,并且会在//apache的配置文件httpd.conf里加上一行LoadModule php4_module //modules/libphp4.so
# make install
#cp php.ini-dist&
/usr/local/lib/php.ini&& //拷贝文件
完成后看是否真在目录/usr/local/apache/modules生成文件libphp4.so,再打开配置文件httpd.conf查看LoadModule php4_module modules/libphp4.so是否被自动追加。
(3)修改Apache配置文件/usr/local/apache/conf/httpd.conf。加入行TypeAdd
application /x-httpd-php .php4到307行的位置,当然其他位置也是可以的。
注意:php4前面有一个空格。笔者第一次配置PHP整合Apache的时候就犯了这个错误,用了好几天的时间才弄明白。另外PHP前面那个&.&(小黑点)一定不要漏掉了。
(4)启动一下apache服务器。找几个php脚本的网页文件,把它复制到apache指定的根文档目录/usr/local/apache/htdocs,然后在与之联网的计算机的浏览器中输入apache所在机器的URL(形如 ),来检验一下配置是否成功。
(5)创建虚拟服务器。Apache/2.2.0与以前的版本有些差异,它是以包含文件的方式来加载用户定义的虚拟主机配置,前面的版本定义虚拟主机就在httpd.conf文件中。我们还是先在主配置文件中把虚拟主机的配置文件/usr/local/apache/conf/extra/httpd-vhosts.conf包含进来。具体的操作就是把行#Include conf/extra/httpd-vhosts.conf的注释去掉,使之成为Include
conf/extra/httpd-vhosts.conf,这一行在httpd.conf的行号是394,然后保存后退出。接着我们打开文件/usr/local/apache/conf/extra/httpd-vhosts.conf,其默认状态如下:
ServerAdmin
DocumentRoot
/www/docs/dummy-host.example.com
ServerName dummy-host.example.com
ServerAlias
logs/dummy-host.example.com-error_log
logs/dummy-host.example.com-access_log common
等我们先安装配置mrtg,然后再回过头来修改文件/usr/local/apache/conf/extra/httpd-vhosts.conf。
(6)启用交换机的SNMP功能。要监控连接在交换机每个端口的服务器网络流量,必须启用交换机的SNMP,这样就不必更改被监控服务器的任何设置。启用交换机SNMP功能的方法,请参照相关文档。
(7)安装和配置mrtg。把软件包下载到硬盘,解压后直接安装就可以了。
(8)修改虚拟主机配置文件。需要指定根文档目录、服务器名称这几项。
如果要对虚拟主机的访问进行用户验证,还需要在Apache的主配置文件对虚拟机的根文档目录进行相关的处理。把下面的行插入到Apache的主配置文件httpd.conf中。
AuthName "mrtg
AuthType Basic
AuthUserFile
/usr/local/apache/.mrtg&& //带点是为了使文件的属性为隐藏
require valid-user
保存后退出。然后运行命令:
# /usr/local/apache/bin/htpasswd -c
/usr/local/apache/.mrtg& sery
按照提示设定用户sery的访问密码。
(九)做域名解析。在域名服务器上解析主机mrtg.sery.com.
(十)启用Apache服务。用指令# ps -aux | grep httpd 检查Apache是否正常运行,然后在另外的计算机浏览器里输入Apache服务器的URL,如输入则应该访问到主配置文件设定的网页,如果输入mrtg.sery.com则访问上面设定的虚拟机页面,并且需要输入正确的用户名和密码才能访问。
通过上面的实践,我们可以得出这样一个结论:Apache服务器功能设定的主要操作就是修改配置文件&&主配置文件httpd.con及包含配置文件。当然,Apache的配置不仅仅是上文所描述的那些,可以说是非常丰富,也是非常灵活的。限于篇幅,不再详叙。至于要让Apache随系统启动,可以把守护进程/usr/local/apache/bin/httpd&加在文件/etc/rc.local里即可。
提示:为了在同一环境下使用更多的Apache服务,可以安装多个Apache到不同的目录,安装目录在安装过程中的配置操作./configure -
prefix=&安装目录&制定,所有Apache的配置原则都是一致的,所有配置完成后,把它们全部启动起来。关于配置多个虚拟主机与安装多个Apache服务究竟有多大的差别,望各位读者自己去做评判。
最后,说几个apache的配置
1、ServerRoot
这段.将它设成你的Apache安装目录,我的是ServerRoot
"/etc/httpd"
2、DocumentRoot
这段.把他设成你网站的根目录,我的是DocumentRoot "/var/www/html"&
3、DirectoryIndex&&这段.把它改成DirectoryIndex&&index.php
index.Html index.html&&这样,你的网站目录的默认首页是 index.php, 如果没有index.php系统会自动寻找index.html、html做为默认首页了。
4、把/etc/httpd/conf.d/welcome.conf中的所有行去掉后,就不会显示默认的首页了。
二、&&&&&&&&&&&
Git和gitweb的安装
git安装方式也有两中
解压后切换到其目录
  $ tar xvfj git-1.7.6.tar.bz2
  $ cd git-1.7.6
  使用默认配置进行安装,如果想修改配置,可以使用 ./configure --help 来获取帮助
  $ ./configure
  $ make
  $ make install
直接rpm &ivh git-1.7.1-2.el6_0.1.x86_64.rpm
安装完成后会产生这个目录/var/lib/git/。
git基本操作
(1)git初始化一个工程:git
(2)设置全局用户信息及邮箱:
git config --global user.name "Xiaochun.li"
git config --global user.email lei..cn
(3)cd worktree
(4)git远程clone:git clone
git://10.1.80.85/loongson-32
(5)如果需要创建自己的分支:git branch branchname
列出所有本地分支:git branch
删除某本地分支:git branch -d branchname
切换本地分支:git checkout branchname
(6)git增加文件:git add a b c readme-cs2c
git删除文件:git rm a b c
(7)git本地提交:git commit -m "what we
git删除本地上一个commit:git reset --soft HEAD~1
git修改一个已经提交的commit:git commit --amend
(8)git远程提交:
git push ssh://root@10.1.80.85/var/lib/git/loongson-32
(9)git合并远程分支
git remote add loongson
git://git.printk.org/linux-loongson-release.git
git://git.printk.org/linux-loongson-release.git
git merge loongson/linux-loongson/v2.6.36
(10)git查看远程分支
git remote show loongson
git remote show
git://git.printk.org/linux-loongson-release.git
(11)、git 删除错误提交的commit
git reset --hard &commit_id&
git push origin HEAD --force
(12)、其他:
根据&soft &mixed &hard,会对working tree和index和HEAD进行重置:
git reset &mixed:此为默认方式,不带任何参数的git reset,即时这种方式,它回退到某个版本,只保留源码,回退commit和index信息
git reset &soft:回退到某个版本,只回退了commit的信息,不会恢复到index file一级。如果还要提交,直接commit即可
git reset &hard:彻底回退到某个版本,本地的源码也会变为上一个版本的内容
HEAD 最近一个提交
HEAD^ 上一次
&commit_id&每次commit的SHA1值. 可以用git log 看到,也可以在页面上commit标签页里找到.
(13)、其他操作总结:
创建一个 Git 版本库
$ cd project/
$ git init&&&&&&&&& # 创建 .git 目录 ( 1.4.4.4 版本之后用这个命令 )
$ git add .&&&&&&&& # 将那些未被跟踪的文件加入版本库中
$ git commit&&&&&&& # 将工作目录的变化提交到版本库中
Git 将根据在版本库根目录中的 .gitignore
文件中列出的文件名,忽略对那些文件的跟踪,文件和目录名,可以用 shell 正则表达式来表示。
分支与合并
$ git checkout -b linux-work& # 创建一个名叫
"linux-work" 的分支
$ &make changes&
$ git commit -a
$ git checkout master&&&&&&&& # 回到主分支
$ git merge linux-work&&&&&&& # 将在 linux-work 分支上的变更集合并入
master 分支
&&&&&&&&&&&&&&&&&&&&&&&&&&&&& # (适用于 Git 1.5 以上版本)
$ git pull . linux-work&&&&&& # 将在 linux-work 分支上的变更集合并入
master 分支
&&&&&&&&&&&&&&&&&&&&&&&&&&&&& # (适用于 Git 的所有版本)
$ git apply & ../p/foo.patch
$ git commit -a
$ &make changes&
$ git commit -a -m "commit
$ git format-patch HEAD^& # 生成一个
0001-commit-message.patch 的文件
&&&&&&&&&&&&&&&&&&&&&&&&& # ( 这里的意思是生成当前分支的最新版本到他的父版本 HEAD^
&&&&&&&&&&&&&&&&&&&&&&&&& # 的所有文件的补丁,当然你应该知道 HEAD 的概念是什么 )
# 从主版本库中克隆
foo$ git clone git://git.kernel.org/pub/scm/git/git.git
foo$ cd git
# 将本地变更推入远程版本库
foo$ git push
:my-repository.git/
# 抓取远程版本库中的其中一个分支到本地版本库
foo$ git fetch
:my-repository.git/ remote-branch:local-branch
# 将远程版本库中的变化合并到本地
bar$ git pull git://foo/repo.git/ branch
# 用 git 协议建立版本库服务
foo$ cd /my/repository/
foo$ touch .git/git-daemon-export-ok
foo$ git daemon&&&&&&&&&&&&&&&&&&&&& # 这样其他人就可以通过
git://your.machine/my/repository/.git/ 来抓取版本库
# 建立一个裸版本库( 没有工作目录的 )
foo$ mkdir my-repo.git
foo$ cd my-repo.git
foo$ git --bare init
foo$ chmod a+x .git/hooks/post-update # 用 HTTP 协议来传输版本时要这样
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& # 并且你需要用 push 命令来植入你的版本库的内容
查看各个版本
# 用图形界面工具查看历史
foo$ gitview&&&&&&&&&&& # 这个命令打开图形界面窗口,你可以从中看到版本的历史沿革关系
# 查看日志
foo$ git log&&&&&&&&&&&& # 输出当前分支的日志
foo$ git log -p&&&&&&&&& # 输出日志,并同时在每个提交信息之后显示补丁
# 查看指定的变更
foo$ git show HEAD&&&&&& # 显示变更信息,差异比较位置,
&&&&&&&&&&&&&&&&&&&&&&&& # 以及到当前分支最新状态的补丁。
查看历史记录
# 根据名称查看
foo$ git log v1.0.0&&&&&&&&&&&&&&&&&&&&&&&& # 列举历史记录至标签
foo$ git log master&&&&&&&&&&&&&&&&&&&&&&&& # 列举
"master" 分支的历史记录
# 根据名称关联查看
foo$ git show master^&&&&&&&&&&&&&&&&&&&&&& # 检查 master 分支的最后一个父版本的内容
foo$ git show master~2&&&&&&&&&&&&&&&&&&&&& # 检查 master 祖父版本的最后内容
foo$ git show master~3&&&&&&&&&&&&&&&&&&&&& # 检查 master 曾祖父的最后内容
# 根据 "git
describe" 的输出
foo$ git show v1.4.4-g730996f&&&&&&&&&&&&&& # 你可以用 "git
describe" 命令得到这个输出
# 根据哈希序列号(在 git 内部,所有的对象都是由哈希序列号来标记的)
foo$ git show
fad074b236cda7d1977dbe
foo$ git show f665776&&&&&&&&&&&&&&&&&&&&&&& # 通常你只要输入前几个数字已经足够
# 制作标签
foo$ git tag v1.0.0&&&&&&&&&&&&&&&&&&&&&&&&& # 将当前 HEAD 制作为
"v1.0.0" 的标签
foo$ git tag interesting
v1.4.4-g730996f&&&& # 标记你感兴趣的东西(不是
比较版本记录
# 比较两个分支的差异
foo$ git diff origin..master&&&&&&&&&&&&&& # 比较 origin 与 master 的差异并输出至终端
foo$ git diff origin..master &
my.patch&&& # 输出到 my.patch 文件
# 取得尚未提交的工作于版本记录的差异
foo$ git diff --stat HEAD
"摘草莓"补丁
foo$ git cherry-pick other-branch~3&&&& # 将另外一个分支的第四个补丁应用到当前分支
Gitweb安装
Gitweb安装需要先安装git
安装完成后会生成这个/var/www/git/目录,用于连接到git daemon指定的仓库的目录中。
安装完成后修改一些配置文件的内容,
1、/etc/gitweb.conf增加$projectroot
= "/var/www/git";,该地址和apache服务所制定的目录一样。
2、/etc/gitweb.conf增加如下内容our
@git_base_url_list = qw(git://10.1.80.128
&&&&&&&&&&&&&&& ssh://10.1.80.128/var/lib/git);这个是在gitweb的网页中显示URL路径的。如下图
3、修改vim
/etc/httpd/conf.d/git.conf中的第一行Alias
/git /var/www/git为Alias
/var/www/git
4、/etc/httpd/conf/httpd.conf中DirectoryIndex
gitweb.cgi index.html index.html.var
5、如果service httpd
restart 出现警告的话,可以把文件/etc/httpd/conf/httpd.conf 中的#ServerName 的#号去掉,打开这句话。
2和4不是必须的。
创建一个git版本库
1、裸版本库
Mkdir my-repo.git
Cd my-repo.git
Git &bare init
2、有目录和文件
Cd myproject/
Git add ./
Git commit &m &****&
Git daemon 安装
至此,本地的git 仓库就创建好了。想要在远程clone这个project,还需要使用gitdaemon
下载安装git-daemon的rpm包,安装后会在/etc/xinetd.d/git中有关git的配置,可以修改。
此时不能在远程用,如git clone git://10.1.80.128/test.git时候会报错,如下:
Initialized
empty Git repository in /home/xiaochun/kernel/test/.git/
10.1.80.128[0:
10.1.80.128]: errno=Connection refused
fatal: unable
to connect a socket (Connection refused)
查了半天,最后发现此守护进程默认没有开启,修改/etc/xinetd.d/git文件,
默认为关闭,修改后需要重启生效。方法为:/etc/rc.d/init.d/xinetd restart
然后可以验证是否开启监听端口
Git协议的默认端口是9418,通过以下命令可以验证,当然你也可以不用默认端口
9418 /etc/services
也可以修改git存放的根目录,使在下载git仓库时候输入较少的路径
git&daemon&--verbose&--export-all&--base-path=/data3/&--reuseaddr
到此,就可以远程下载git代码了。
clone git://10.1.80.128/loongson-32
10.1.80.128/gitweb/
如果要在局域网中用网页访问的话,就的修改需要访问主机的/etc/hosts.
如果要在广域网访问的话,就得申请DNS,或者在已经申请的DNS配置。
三、&&&&&&&&&&&
Gerrit 的安装和配置
在128上创建gerrit2用户,从google code上下载gerrit最新稳定版本2.5:
[root@localhost ~]# adduser gerrit2
[root@localhost ~]# su gerrit2
[gerrit2@localhost root]$ cd
[gerrit2@localhost ~]$ wget http://gerrit.googlecode.com/files/gerrit-full-2.5.war
2.&&&&& 为gerrit创建数据库:(用mysql数据库的话)
mysql& CREATE USER ‘gerrit2‘@‘localhost‘ IDENTIFIED BY ‘qwer1234‘;
Query OK, 0 rows affected (0.00 sec)
mysql& CREATE DATABASE
Query OK, 1 row affected (0.00 sec)
mysql& ALTER DATABASE reviewdb charset=latin1;
Query OK, 1 row affected (0.00 sec)
mysql& GRANT ALL ON reviewdb.* TO ‘gerrit2‘@‘localhost‘;
Query OK, 0 rows affected (0.00 sec)
mysql& FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
charset=latin1导致gerrit不支持中文,但是选用utf8会有其他问题,具体可以参考薛总文档。
3.&&&&& 安装gerrit:
[gerrit2@localhost ~]$ java -jar gerrit-full-2.5.war init -d ~/code_review
*** Gerrit Code Review 2.5
Create ‘/home/gerrit2/code_review‘ [Y/n]?
*** Git Repositories
Location of Git repositories&& [git]:
*** SQL Database
Database server type&&&&&&&&&& [H2/?]: mysql
Gerrit Code Review is not shipped with MySQL Connector/J 5.1.10
**& This library is required for your configuration. **
Download and install it now [Y/n]?
Downloading http://repo2.maven.org/maven2/mysql/mysql-connector-java/5.1.10/mysql-connector-java-5.1.10.jar ... OK
Checksum mysql-connector-java-5.1.10.jar OK
Server hostname&&&&&&&&&&&&&&& [localhost]:
Server port&&&&&&&&&&&&&&&&&&& [(MYSQL default)]:
Database name&&&&&&&&&&&&&&&&& [reviewdb]:
Database username&&&&&&&&&&&&& [gerrit2]:
gerrit2‘s password&&&&&&&&&&&& :
confirm password :
*** User Authentication
Authentication method&&&&&&&&& [OPENID/?]: http
Get username from custom HTTP header [y/N]?
SSO logout URL&&&&&&&&&&&&&&&& :
*** Email Delivery
SMTP server hostname&&&&&&&&&& [localhost]:
SMTP server port&&&&&&&&&&&&&& [(default)]:
SMTP encryption&&&&&&&&&&&&&&& [NONE/?]:
SMTP username&&&&&&&&&&&&&&&&& :
*** Container Process
Run as&&&&&&&&&&&&&&&&&&&&&&&& [gerrit2]:
Java runtime&&&&&&&&&&&&&&&&&& [/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre]:
Copy gerrit.war to /home/gerrit2/code_review/bin/gerrit.war [Y/n]?
Copying gerrit.war to /home/gerrit2/code_review/bin/gerrit.war
*** SSH Daemon
Listen on address&&&&&&&&&&&&& [*]:
Listen on port&&&&&&&&&&&&&&&& [29418]:
Gerrit Code Review is not shipped with Bouncy Castle Crypto v144
& If available, Gerrit can take advantage of features
in the library, but will also function without it.
Download and install it now [Y/n]?
Downloading http://www.bouncycastle.org/download/bcprov-jdk16-144.jar ... OK
Checksum bcprov-jdk16-144.jar OK(网速不好这块会失败,我们可以现在no)
Generating SSH host key ... rsa... dsa... done
*** HTTP Daemon
Behind reverse proxy&&&&&&&&&& [y/N]?y
Proxy uses SSL (https://)&&&&& [y/N]?
Subdirectory on proxy server&& [/]:
Listen on address&&&&&&&&&&&&& [*]:
Listen on port&&&&&&&&&&&&&&&& [8080]:
*** Plugins
Prompt to install core plugins [y/N]?
Initialized /home/gerrit2/code_review
Executing /home/gerrit2/code_review/bin/gerrit.sh start
Starting Gerrit Code Review:
Waiting for server to start ... OK
Opening browser &
简单说明六点:
1)Authentication method [OPENID/?]: http,默认为openid,需要在公网上验证邮箱是否能够登录,因此改为http方式认证。
2)Database server type [H2/?]: mysql
数据库选用mysql,因为128默认没有H2,用H2也可以。
3)SSO logout URL :
默认没填,其实可以填一下,因为gerrit的logout功能不太好,总是返回到http的根,因此会与http默认配置有冲突,但是可以配置。
4)这些默认配置文件都放在code_review/etc/路径下,gerrit.confg是默认配置文件。
5)此步完成后,gerrit同时启动,在后台监听端口。可以通过~/code_review/bin/gerrit.sh restart/stop/start/status等命令来运维gerrit,并且可以将gerrit.sh拷贝到/etc/init.d做开机启动脚本:
ln -snf home/gerrit2/code_review/bin/gerrit.sh /etc/init.d/gerrit
ln -snf /etc/init.d/gerrit /etc/rc3.d/S90gerrit
6)gerrit的默认sign out功能不好使,需要设置SSO logout URL :http://10.1.80.128或者通过配置~/code_review/etc/gerrit.config文件:
type = HTTP
logoutUrl = http://10.1.80.128
4.&&&&& 配置apache服务器,启动gerrit的Web前端
1)创建httpd的gerrit2的配置文件/etc/httpd/conf.d/gerrit2.conf,填入下列内容:
&VirtualHost *&
& ServerName 10.1.80.128
& ProxyRequests Off
& ProxyVia Off
& ProxyPreserveHost On
&&&&&&& Order deny,allow
&&&&&&& Allow from all
& ProxyPass /gerrit2/ http://10.1.80.128:8080/
&Location /gerrit2/&
&&&& AuthType Basic
&&&& AuthName "Gerrit Code Review"
&&&& AuthBasicProvider file
&&&& AuthUserFile /home/gerrit2/code_review/etc/passwords
&&&& Require valid-user
&/Location&
&/VirtualHost&
1)AuthUserFile路径为/home/gerrit2/code_review/etc/passwords,但是apache无权访问此路径,需要对/home/gerrit2进行赋权:
setfacl -m g:apache:rx /home/gerrit2/
2)ProxyPass /gerrit2/ http://10.1.80.128:8080/反向代理地址需要与/home/gerrit2/code_review/etc/gerrit.conf中的listenUrl设置一致。
3)接着创建gerrit所需的passwords文件:
htpasswd -c /home/gerrit2/code_review/etc/passwords xiaochun.li
htpasswd /home/gerrit2/code_review/etc/passwords yan.lu
htpasswd /home/gerrit2/code_review/etc/passwords shujin.li
其中第一个创建的用户为管理员,即xiaochun.li。
4)重启httpd服务,访问http://10.1.80.128/gerrit2/,输入刚才建立的用户名和密码:
5.&&&&& 用户上传公钥
为了方便为gerrit创建和导入git库,需要将用户的公钥提交给gerrit站点,因为如果需要对git进行push一类的操作,git默认使用ssh的方式,而ssh需要服务器存储客户端的公钥;如果没有公钥,首先是生成密钥对:
[root@localhost ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory ‘/root/.ssh‘.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
b4:49:84:55:9c:1b:15:3e:12:93:c9:93:aa:0a:2c:ba root@localhost.localdomain
The key‘s randomart image is:
+--[ RSA 2048]----+
| oo++*o. |
| o.o.. . |
+-----------------+
[root@localhost ~]# cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAsUhqu8135ikZK4/i2OisfHNIY6Bme46RRuZ2iug2Xva7cQGcdJPTv3nwIR6L/RfQa57b5uGQt+AX65AFzsKe4JoqIlA5IxsbZKz+tZ1CpEOcD37Rp78ovjef6lOx1Af2c+Yg+F9gwtKDw/UPZYMaID24RIwul290HOGOTH9hii3yuKliRmsHjy2dJ1ZFpb/fPBKXDnY0vAylJlPL3fCFyEOM40WgV5sIPZDW7ykhvvubcW/n4UA2JZrDvmQFPgM/QYmHrUw6OxZtBt5aGKPNomxLEdq0PsfQMj1d/WAggic/P4sbt0ATciY+nGvd8cYlW5G3jV1WQ1aD8RW2PqHakQ== root@localhost.localdomain
使用xiaochun.li登录,点击右侧Setting,再点击左侧SSH Public Keys并将公钥上传:
一个用户可以对应多个公钥,用户也可以使用windows系统提交代码,只要上传公钥。
6.&&&&& 配置gerrit Web前端,添加git仓库
首先为gerrit创建一个空的仓库:
ssh -p 29418 xiaochun.li@localhost gerrit create-project --name loongson-kernel
或者使用Web界面创建git仓库:
此时即可在http://10.1.80.128/gerrit2/上查看project-&list中就存在loongson-32这个仓库:
其次,在gerrit web前端中为新添加的仓库赋权,点击Projects-&List-&loongson-32-&Access-&Edit,将所有能够添加的权限添加上(Reference填写&refs/*&)。
有时会报错:
You don‘t have permissions to modify the access rights for the following refs:
You may propose these modifications to the project owners by clicking on ‘Save for Review‘.
但是能够成功:
最后,将已有的git仓库导入到gerrit的仓库中(用root):
[root@localhost ~]# cd /var/lib/git/loongson-32
[root@localhost loongson-32]# git push ssh://xiaochun.li@localhost:29418/loongson-kernel *:*
Counting objects: 34101, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (), done.
Writing objects: 100% (), 96.24 MiB | 13.12 MiB/s, done.
Total 34101 (delta 3868), reused 34029 (delta 3825)
remote: Resolving deltas: 100% ()
remote: Processing changes: refs: 1, done
To ssh://xiaochun.li@localhost:29418/loongson-32
* [new branch] loongson-32 -& loongson-32
7.&&&&& 为git仓库添加gitweb
为了能够在gerrit上显示gitweb,需要在gerrit.conf文件中添加配置:
cgi =/var/www/git/gitweb.cgi
此处需要gerrit2对/var/www/git/gitweb.cgi文件具备访问权限,需要setfacl添加权限:
setfacl -m g:gerrit2:rwx /var/www/git/gitweb.cgi
8.&&&&& 为gerrit配置iptbales:
iptables -I INPUT -p tcp --dport 29418 -j ACCEPT
四、&&&&&&&&&&& Gerrit使用手册
普通用户只有提交权限,管理员具备代码审查权限,可以临时指定代码审查人员。
1. 登陆http://10.1.80.85/gerrit2,上传公钥
输入用户名密码,例如xiaochun.li,qwer1234
此处有可能出现下面的错误:
The requested URL /login/null was not found on this server.
Apache/2.2.15 (CentOS) Server at 10.1.80.85 Port 80
再次在浏览器中输入http://10.1.80.85/gerrit2即可登陆。登陆后,点击右上方Settings-&SSH Public Keys-&Add SSH Public Key ,通常使用10.1.83.183进行git commit等操作,因此上传10.1.83.183的公钥,例如:
[xiaochun.li@kernenl-001 worktree]$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEArBT7GSYGIX7nx7q1l/FubdJxMcS1zFk28T/rynFIX0vMPXYTEKubYCw83GaNdOVAdGtRqafW1oAwR/W8qyXifDKmeKberfj5bhiofGPBvrM24/yj5iM8Ry2MYv4qaP4u5XnrXBlumTPobmnxtIPYStwiBeKS40TNAvWwjmjmsy5LecIXWH2wsvUvIAO+bkDY/syCS6lAu1XY2wrnhN18PB28ADrkXTSTnA65eMUKArUwSBWwMiVKJsGEnm7KQ/CKP71gMw9aJoRCGAisOji76x5K8DDZLkTBaYGWbORA6IF9FzilMFoda0P8TJT1VnInkzUxmo1iAHQvpqiVzJ6+iw== xiaochun.li@kernenl-001
将cat内容粘贴至 Add SSH Public Key文本框中,点击&Add&按钮完成上传工作。
可以多次上传不同机器的公钥,用于通过不同的机器提交代码。Windows也可以上传公钥,只要使用openssl生成公钥即可。
2.& 注册邮箱、用户名
登陆后,点Settings-〉Contact Information ,填写Full name和Preferred Email ,填完后点&Save Changes&按钮。
3.& 下载最新git库、编辑代码、提交gerrit审查
首先,下载具备代码审查功能的git仓库:
[xiaochun.li@kernenl-001 aa]$ git clone ssh://xiaochun.li@10.1.80.85:29418/loongson-kernel.git
[xiaochun.li@kernenl-001 aa]$ cd loongson-kernel/
[xiaochun.li@kernenl-001 loongson-kernel]$ touch xiaochun.li-test
[xiaochun.li@kernenl-001 loongson-kernel]$ vimxiaochun.li-test
[xiaochun.li@kernenl-001 loongson-kernel]$ git add xiaochun.li-test
[xiaochun.li@kernenl-001 loongson-kernel]$ git commit -m "a test for gerrit,xiaochun.li"
[loongson-32 827412f] a test for gerrit,xiaochun.li
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 xiaochun.li-test
[xiaochun.li@kernenl-001 loongson-kernel]$ git log
commit fd581ce24c9bdfe4e44d
Author: xiaochun.li&lei..cn&
Date:&& Thu Feb 21 15:26:05
a test for gerrit,xiaochun.li
[xiaochun.li@kernenl-001 loongson-kernel]$ git push origin HEAD:refs/for/loongson-32
Counting objects: 4, done.
Delta compression using up to 32 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 304 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1)
remote: Processing changes: new: 1, refs: 1, done&&&
To ssh://xiaochun.li@10.1.80.85:29418/loongson-kernel.git
* [new branch]&&&&& HEAD -& refs/for/loongson-32
注意,此处push必须这么写!!!
4.& 登陆gerrit,设置代码审查者
登陆gerrit,点击My-&Changes,点击具体Changes后,点&Add Reviewer&按钮,增加代码审查者:
5.& 登陆gerrit,审查代码
代码审查包括两部分,一部分是功能验证、一部分是代码自身优规范程度和优雅程度。
登陆gerrit,点击My-&Changes,点击具体Changes后,可以分别点击=Commit Message和具体提交的文件名查看内容:
具体查看的时候可以写评语:
如果代码审查包括两部分Verified(功能验证)、Code Review(代码规范程度),进行评分,正分通过,负分不通过,不通过给予原因,点击&Push Comments&按钮提交评审结果:
对于最后进行代码审查的人,评分以后,点击&Push Comments&按钮后,代码审查结果就出现在页面上:
在所有Code Reviewer的Verified置1、Code Review置2时,可以点击&Push and Submit&按钮,提交此commit。
另外,对于不合适的Changes,可以点击&Abandan Change&按钮,放弃。
6.&&&&& gerrit已经&Push and Submit&,就提交到git上
五、&&&&&&&&&&& ftp安装和配置
1、安装vsftpd的rpm包,客户端可以使用lftp操作
2、安装后的根目录为/var/ftp/,此目录为要上传的文件,可以chmod更改目录和文件权限
3、配置文件为/etc/vsftpd/vsftpd.conf
4、启动服务service vsftpd restart
6、上传和下载get ,wget,put ,mirror
六、&&&&&&&&&&& SVN配置
服务器端:
1、去85的/var/svn下创建一个你需要的svn目录,创建方法为:svnadmin create 名字XXX
2、修改你创建名字下面的XXX/conf/svnserve.conf,把anon-access = none和auth-access = write打开,是用户能够写。
1、svn checkout svn://10.1.80.85/名字/
2、svn add 文件或目录名
3、svn ci -m &日志&
如果是本地可以
1、svnadmin create 名字XXX
2、第一次添加也可以用 svn import file:///名字/文件 -m &日志&
3、svn checkout file:///名字/ /目录名字(在哪个目录下)
4、svn ci -m &日志&
七、&&&&&&&&&&& 搭建环境过程中问题总结
1、git add ./arch/mips/kernel& 把某一个目录中的更改全部提交到
2、每次ssh连接要输入那么长命令,很烦人,可以配置~/.ssh/config文件来为ssh连接设置别名,如下所示:
HostName 10.1.80.128
User xiaochun.li
Port 29418
IdentityFile ~/.ssh/xiaochun.li
刷新gerrit :ssh gt gerrit flush-caches
3、更改gerrit中的表的操作
select * from ACCOUNT_EXTERNAL_IDS;
update ACCOUNTS set PREFERRED_EMAIL = NULL where ACCOUNT_ID = ‘1000001‘;
select * from ACCOUNTS;
ssh gt gerrit flush-caches
ssh gt gerrit set-account --add-email
delete from ACCOUNT_EXTERNAL_IDS where EMAIL_ADDRESS& like ‘xiaochun..cn‘;
delete from ACCOUNT_EXTERNAL_IDS where ACCOUNT_ID = ‘1000001‘;
delete from ACCOUNTS where ACCOUNT_ID = ‘1000001‘;
ssh gt gerrit flush-caches
4、git提交的邮箱设置在~/.gitconfig中
name = lixiaochun
email = xiaochun..cn
5、gerrit项目设置的时候一定要在reference中选择refs/*才能用gitweb中查看git代码。
而且必须把项目设置成某一个组,并修改相应组员的privileges,才能正确查看到。
6、在gerrit总进入某个项目的gitweb后,点击下面的heads,如果不能显示出来,则要进行软连接
&&&&&& ln -s /home/gerrit2/code_review/git/loongson-32.git /var/www/git/loongson-32.git
注意:上面两个链接的名字必须一样才能起到作用。
7、生成密钥对 ssh-keygen -t rsa -C "xiaochun" -f ~/.ssh/xiaochun.li
8、ssh -p 29418 -i ~/.ssh/xiaochun.li 10.1.80.85 -l xiaochun.li
9、进入gerrit的web界面后需要注册自己的全名,那样在数据库表ACCOUNTS中才能有相应的记录。
10、在做好软连接
ln -snf /home/gerrit2/code_review/bin/gerrit.sh /etc/init.d/gerrit
ln -snf /etc/init.d/gerrit /etc/rc3.d/S90gerrit
如果用service gerrit restart出现
** ERROR: GERRIT_SITE not set的时候,打开/home/gerrit2/code_review/bin/gerrit.sh
在GERRIT_SITE赋值以后覆盖其赋值为GERRIT_SITE=/home/gerrit2/code_review
11、新建/检出 GIT仓库
&&&& 1. 新建git仓库:
ssh gt gerrit create-project -n project1
ssh -p 29418 【-i ~/.ssh/xiaochun.li】 10.1.80.85 -l xiaochun.li gerrit create-project -n project1
&&&& 2. 察看本人仓库权限:
ssh gt gerrit ls-projects
ssh -p 29418 【-i ~/.ssh/xiaochun.li】 10.1.80.85 -l xiaochun.li gerrit ls-projects
&&&& 3. 检出仓库test/project1
git clone gt:project1
ssh -p 29418 【-i ~/.ssh/xiaochun.li】 10.1.80.85 -l xiaochun.li
12、如果出现如下错误
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
那么生成.publickey的时候需要用命令
ssh-keygen -t rsa而不是ssh-keygen -t rsa -C "xiaochun" -f ~/.ssh/xiaochun.li,这种方法生成的需要指定key。
然后cat ~/.ssh/id_rsa.pub,把内容复制到gerrit中。
12、git diff用法
diff里面a表示前面那个变量,b表示第二个变量
HEAD&&&& commit版本
Index&&&& staged版本
a、查看尚未暂存的文件更新了哪些部分,不加参数直接输入
此命令比较的是工作目录(Working tree)和暂存区域快照(index)之间的差异
也就是修改之后还没有暂存起来的变化内容。
b、查看已经暂存起来的文件(staged)和上次提交时的快照之间(HEAD)的差异
git diff --cached
git diff --staged
显示的是下一次commit时会提交到HEAD的内容(不带-a情况下)
c、显示工作版本(Working tree)和HEAD的差别
git diff HEAD
d、直接将两个分支上最新的提交做diff
&&& git diff topic master 或 git diff topic..master
e、输出自topic和master分别开发以来,master分支上的changed。
git diff topic...master
Changes that occurred on the master branch since when the topic
branch was started off it
f、查看简单的diff结果,可以加上--stat参数
git diff --stat
g、查看当前目录和另外一个分支的差别
git diff test
显示当前目录和另一个叫‘test‘分支的差别
git diff HEAD -- ./lib
显示当前目录下的lib目录和上次提交之间的差别(更准确的说是在当前分支下)
h、比较上次提交commit和上上次提交
git diff HEAD^ HEAD
i、比较两个历史版本之间的差异
git diff SHA1 SHA2标签:&&&&&&&&&&&&&&&&&&&&&&&&&&&原文:http://www.cnblogs.com/kevingrace/p/5621226.html
教程昨日排行
&&国之画&&&& &&&&&&
&& &&&&&&&&&&&&&&
鲁ICP备号-4
打开技术之扣,分享程序人生!

我要回帖

更多关于 www.144hu.com 的文章

 

随机推荐