$sudo apt-get install mysql-client-5.5 mysql-server-5.5 git-core apache2.2-bin apache2.2-common apache2-utils apache2-mpm-worker
$sudo apt-get install mysql-client-5.5 mysql-server-5.5
#mysql -u root -p
mysql>CREATE USER 'project'@'localhost' IDENTIFIED BY 'secret'; 注意:可能会有这个错误的: mysql> CREATE USER 'project'@'localhost' IDENTIFIED BY 'secret'; ERROR 1227 (42000): Access denied; you need (at least one of) the CREATE USER privilege(s) for this operation是因为直接mysql登陆进去的,请用mysql -u root -p 登录!!!
mysql>CREATE DATABASE reviewdb_project;
mysql>GRANT ALL ON reviewdb_project.* TO 'project'@'localhost';
mysql>FLUSH PRIVILEGES; 注:Linux mysql安装无法启动 /etc下无mysql配置文件,mysql 无法启动,/var/run/mysqld/mysqld.sock or /temple/mysqld.sock找不到
需确认 并手动安装下 下列软件包:
libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18 libnet-daemon-perl libplrpc-perl libterm-readkey-perl mysql-client-5.5 mysql-client-core-5.5 mysql-common mysql-server-5.5 mysql-server-core-5.5
mysql-cmmon 这个软件包是配置/etc/mysql/ 下的配置信息的
mysql 无法启动,/var/run/mysqld/mysqld.sock找不到:
也可能配置文件/etc/mysql/my.cnf中:
添加 修改:
# Remember to edit /etc/mysql/debian.cnf when changing the socket location. [client] port = 3306 socket = /var/run/mysqld/mysqld.sock
mysqld.sock 则会自动生成
Ubantu 安装mysql-server-5.5软件包时报错
Sub-process /usr/bin/dpkg returned an error code (1)解决办法 :Sub-process /usr/bin/dpkg returned an error code (1)
解决方法是:$cd /var/lib/dpkg/info
$sudo rm -rf mysql-*
$sudo apt-get autoremove mysql-client-5.5 mysql-client-core-5.5 mysql-common mysql-server-5.5 mysql-server-core-5.5 libnet-daemon-perl libplrpc-perl libterm-readkey-perl libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18
$sudo apt-get install mysql-client-5.5 mysql-client-core-5.5 mysql-common mysql-server-5.5 mysql-server-core-5.5 libnet-daemon-perl libplrpc-perl libterm-readkey-perl libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18
$mysql
mysql> exit
ByeOK了
$sudo adduser project
以新用户身份操作
$sudo su - project
$mkdir -p review_site_project
http://code.google.com/p/gerrit/
java -jar gerrit-full-2.5.2.war init -d review_site_project/
Create '/home/gerrit2/review-site' [Y/n]? *** Git Repositories *** Location of Git repositories [git]: *** SQL Database *** Database server type [H2/?]: MYSQL
Server hostname [localhost]: Server port [(MYSQL default)]: Database name [reviewdb]:reviewdb_project Database username [git]:project
*** User Authentication***Authentication method [OPENID/?]: HTTP //注意这个不要按回车跳过去了,否则不是HTTP认证,是需要用google的OPENIDGet username from custom HTTP header [y/N]? :SSO logout URL : *** Email Delivery***SMTP server hostname [localhost]: smtp.company.com //自己改成自己的邮箱smtpSMTP server port [(default)]:SMTP encryption [NONE/?]:SMTP username [?]: [email protected] //自己改成自己的邮箱
fatal: DbInjector failed[email protected]'s password : confirm password : *** Container Process *** Run as [project]: Java runtime [/usr/lib/jvm/java-6-sun-1.6.0.24/jre]: Copy gerrit.war to /home/gerrit2/review-site/bin/gerrit.war [Y/n]? Copying gerrit.war to /home/gerrit2/review-site/bin/gerrit.war *** SSH Daemon *** Listen on address [*]: Listen on port [29418]: //如果同一个用户下建多个gerrit,请不用都公用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 Generating SSH host key ... rsa... dsa... done *** HTTP Daemon *** Behind reverse proxy [y/N]? y Proxy uses SSL (https://) [y/N]? n Subdirectory on proxy server [/]: Listen on address [*]: Listen on port [8081]: //切记,此端口号一定不要和apache2占用相同的端口号, //否则就会Starting Gerrit Code Review:Failed Canonical URL [http://*/]:http://192.168.11.73:80/ //填自己的ip和端口号,勿完全抄 Initialized /home/gerrit2/review-site Executing /home/gerrit2/review-site/bin/gerrit.sh start Starting Gerrit Code Review: OK =========================================QA=======================================================================================Q:
A:
mysql -u root -p Enter password: <enter password> mysql>GRANT ALL ON *.* to root@'123.123.123.123' IDENTIFIED BY 'put-your-password'; mysql>FLUSH PRIVILEGES; mysql>exit
Q:Configuration ErrorCheck the HTTP server's authentication settings.The HTTP server did not provide the username in the Authorizationheader when it forwarded the request to Gerrit Code Review.If the HTTP server is Apache HTTPd, check the proxy configurationincludes an authorization directive with the proper location, ensuringit ends with '/':In error_log:ERROR com.google.gerrit.httpd.auth.container.HttpLoginServlet : Unableto authenticate user by Authorization request header. Check containeror server configuration.
A:You cannot run these on the same port. Your Apache NameVirtualHostshould be on a different port than the internal Jetty web sever thatGerrit is using.
例如:即gerrit和apache2占用相同的端口号
cat review_site_project/etc/gerrit.config:
[httpd] listenUrl = http://x.x.x.x:8081/
cat /etc/apache2/apache2.conf :
NameVirtualHost x.x.x.x:8081
<VirtualHost x.x.x.x:8081>
[gerrit] basePath = git //指定被gerrit管理的所有git库存放位置,即review_site_project/git/ canonicalWebUrl = http://192.168.11.73:80/ //指定web访问gerrit的网址//填自己的ip和端口号,勿完全抄 [database] type = MYSQL //指定gerrit所用数据库类型,这里选用mysql hostname = localhost //指定数据库主机名 database = reviewdb_project //指定数据库名,这里便是之前第三步仅限的数据库reviewdb username = project //指定登录数据库用户名,这里跟每三步对应一致
[auth] type = HTTP //指定浏览器登录gerrit时的认证方式 [sendemail] smtpServer = smtp.company.com //指定smtp服务器地址 smtpUser = [email protected] [container] user = project //指定gerrit所在机器的用户身份与上文创建的用户对应一致 javaHome = /usr/lib/jvm/java-6-sun-1.6.0.24/jre //系统本身自带 [sshd] listenAddress = *:29418 //指定sshd服务监听的端口号 [httpd] listenUrl = proxy-http://127.0.0.1:8081/ //指定http代理地址 [cache] directory = cache //缓存位置
$sudo apt-get install apache2.2-bin apache2.2-common apache2-utils apache2-mpm-worker
1.创建编辑apache配置文件,添加如下内容(下面以Ubuntu系统为例请注意不同操作系统apache配置文件的区别)也可配置 apache2.conf httpd.conf,我们这里配置的是/etc/apache2/sites-available/gerrit
$sudo vi /etc/apache2/sites-available/gerrit NameVirtualHost 192.168.11.73:80 //填自己的ip和端口号,勿完全抄 <VirtualHost 192.168.11.73:80> //填自己的ip和端口号,勿完全抄 ServerName 192.168.11.73 ProxyRequests Off ProxyVia Off ProxyPreserveHost On <Proxy *> Order deny,allow Allow from all </Proxy> <Location /login/> AuthType Basic AuthName "Gerrit Code Review" Require valid-user AuthUserFile /etc/apache2/passwords //指定http登录认证的的paassword文件所在位置,放哪都行,根据后来 //sudo htpasswd -cb /etc/apache2/passwords scm scm </Location> AllowEncodedSlashes On ProxyPass / http://127.0.0.1:8081/ ProxyPassReverse / http://127.0.0.1:8081/ </VirtualHost> 保存退出 $cd /etc/apache2/sites-enabled/ $sudo ln ../sites-available/gerrit .
$sudo htpasswd -cb /etc/apache2/passwords scm scm
3继续配置apache2
ServerName localhost
$cd /etc/apache2/mods-enabled$sudo ln -s /etc/apache2/mods-available/proxy.conf proxy.conf$sudo ln -s /etc/apache2/mods-available/proxy.load proxy.load$sudo ln -s /etc/apache2/mods-available/proxy_http.load proxy_http.load /etc/apache2$sudo vi ports.confNameVirtualHost *:80 Listen 80 Listen 8080 //不要给gerrit! Listen 8000 //不要给gerrit!
添加apache2的tcp端口号,切记不要把gerrit的,即Listen on port [8081]: 不要输入上面配置给apache2的端口号,新手切记!!! 否则gerrit 起不来的 搭建多个gerrit 时Listen on port [8081]:可以用8082 8083 8084 等
Syntax error on line 300 of /etc/apache2/apache2.conf:Invalid command 'ProxyPass', perhaps misspelled or defined by a module not included in the server configuration ...fail!
cd /etc/apache2/mods-enabled ln -s /etc/apache2/mods-available/proxy.conf proxy.conf ln -s /etc/apache2/mods-available/proxy.load proxy.load ln -s /etc/apache2/mods-available/proxy_http.load proxy_http.load
No apache MPM package installed
$sudo apt-get install apache2-mpm-worker
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
ServerName localhost
Q:(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80 A:需要用ROOT用户执行 直接 sudo /etc/init.d/apache2 restart 就OK了
sudo /etc/init.d/apache2 restart
$review_site_project/bin/gerrit.sh start
在浏览器地址栏中输入http://192.168.11.73:80/
在显示的登录框中输入用户名/密码,
即之前配置passwords
$sudo htpasswd -cb /etc/apache2/passwords scm scmscm
scm