<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>服务器安全维护工作室 &#187; 在亚马逊AWS上建立Git服务器</title>
	<atom:link href="https://www.fuwuqiok.com/tag/%e5%9c%a8%e4%ba%9a%e9%a9%ac%e9%80%8aaws%e4%b8%8a%e5%bb%ba%e7%ab%8bgit%e6%9c%8d%e5%8a%a1%e5%99%a8/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.fuwuqiok.com</link>
	<description></description>
	<lastBuildDate>Sun, 01 Mar 2020 07:28:40 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.2.26</generator>
	<item>
		<title>在亚马逊AWS上建立Git服务器</title>
		<link>https://www.fuwuqiok.com/%e5%9c%a8%e4%ba%9a%e9%a9%ac%e9%80%8aaws%e4%b8%8a%e5%bb%ba%e7%ab%8bgit%e6%9c%8d%e5%8a%a1%e5%99%a8/</link>
		<comments>https://www.fuwuqiok.com/%e5%9c%a8%e4%ba%9a%e9%a9%ac%e9%80%8aaws%e4%b8%8a%e5%bb%ba%e7%ab%8bgit%e6%9c%8d%e5%8a%a1%e5%99%a8/#comments</comments>
		<pubDate>Sat, 22 Aug 2015 16:27:35 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[未分类]]></category>
		<category><![CDATA[在亚马逊AWS上建立Git服务器]]></category>

		<guid isPermaLink="false">https://www.fuwuqiok.com/?p=2675</guid>
		<description><![CDATA[<p>本文可以算是前文用亚马逊的云(AWS)免费建立wordpress blog的 一个延续，在上文的基础上我们可以 [&#8230;]</p>
<p><a rel="nofollow" href="https://www.fuwuqiok.com/%e5%9c%a8%e4%ba%9a%e9%a9%ac%e9%80%8aaws%e4%b8%8a%e5%bb%ba%e7%ab%8bgit%e6%9c%8d%e5%8a%a1%e5%99%a8/">在亚马逊AWS上建立Git服务器</a>，首发于<a rel="nofollow" href="https://www.fuwuqiok.com">服务器安全维护工作室</a>。</p>
]]></description>
				<content:encoded><![CDATA[<p>本文可以算是前文用亚马逊的云(AWS)免费建立wordpress blog的 一个延续，在上文的基础上我们可以建立一个属于自己的git服务器。这里介绍的方法会用到gitolite和gitlist，gitolite是一个 git的用户管理层，方便的管理用户和git repository，而gitlist是一个方便从网页查看git reposito的工具。本文假设你对git有基本的了解，并且基于提到的前文已经假设好了环境<br />
<span id="more-205"></span></p>
<h2>在EC2上安装配置gitolite (<code>sudo su</code>)</h2>
<pre><code>cd /tmp
# 准备key文件,或者使用你现有的key文件
ssh-keygen -t rsa
cp id_rsa.pub /tmp/your-name.pub

# install packages 安装工具
sudo apt-get install git gitolite git-daemon-run
# create git user 创建git用户
sudo adduser --system --shell /bin/bash --gecos 'git version control' --group --disabled-password --home /home/git git
sudo su - git
cd /home/git
echo "PATH=$HOME/bin:$PATH" &gt; .bashrc
# gl-setup gitolite初始化
gl-setup /tmp/your-name.pub
# 执行上面命令后gitolite会让选择熟悉的编辑器你修改配置文件，打开配置后座如下修改
	$REPO_UMASK = 0022;</code></pre>
<p>至此gitolite安装完毕，建议</p>
<h2>配置你工作机上的<code>~/.ssh/config</code>文件</h2>
<p>以方便连接<br />
config文件如下</p>
<pre><code>Host 你喜欢的名字，如gs
Hostname 亚马逊PUBLIC DNS
User git
IdentityFile C:/Users/test/.ssh/id_rsa #你的私钥路径
#PreferredAuthentications publickey
</code></pre>
<h2>在工作机上管理gitolite</h2>
<p>这样你就可以在你的工作机上进行连接了，现在clone管理目录<br />
<code>git clone git@gs:gitolite-admin.git</code><br />
编辑conf/gitolite.conf可以添加repository如</p>
<pre><code>repo    anothertest
        RW+     =   @all</code></pre>
<p>添加用户只需将的公钥添加到keydir就可以了，如果用户有多个公钥，如工作机一个，笔记本一个，可以在keydir下添加目录然后添加key如为tom添加 laptop/tom.pub和workspace/tom.pub即可<br />
修改完成之后commit并push回主机相应的repositoy和user了</p>
<h2>在EC2上配置gitlist</h2>
<p>用git来管理repository和user很方便，但如果你的老板要查看git上的提交就不那么方便了(:P),通过安装gitlist网页查看就会方便很多<br />
从<a href="http://gitlist.org/" target="_blank">gitlist.org</a> 上下载最新版并完成配置</p>
<pre><code>cd /tmp
wget https://s3.amazonaws.com/gitlist/gitlist-0.4.0.tar.gz
tar -zxf gitlist-0.4.0.tar.gz
mv gitlist /sites/
cd /sites/gitlist
mv config.ini-example config.ini
edit config.ini
    repositories[] = '/data/git/repositories/'
    hidden[] = '/data/git/repositories/gitolite-admin.git' #建议添加，管理目录不必被网页查看
mkdir cache #必须手动添加
chown -Rh www-data:www-data /sites/gitlist</code></pre>
<p>创建site的nginx配置<code>/etc/nginx/sites-available/gitlist</code></p>
<pre><code>server {
	listen 80;
	server_name gitlist;
	keepalive_timeout 70;

	access_log /var/log/nginx/gitlist-access.log;
	error_log /var/log/nginx/gitlist-error.log;

	root /sites/gitlist;
	index index.php;
	location ~ /include {
	deny all;
	return 403;
	}

	location ~ ^/api/(tickets|tasks)(.*)$ {
	try_files $uri $uri/ /api/http.php;
	}

	location ~ ^/scp/ajax.php/(.*)$ {
	try_files $uri $uri/ /scp/ajax.php;
	}

	location / {
	index index.php;
	try_files $uri $uri/ /index.php?$args;
	}

	location ~ .php$ {
	fastcgi_split_path_info ^(.+.php)(/.+)$;
	include fastcgi_params;
	fastcgi_pass unix:/var/run/php5-admin.sock;
	#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
	}
}</code></pre>
<p>如果你此处用的fastcgi_pass是之前用过的那不需要额外的设置，如果没有那需要建立</p>
<pre><code>cd /etc/php5/fpm/pool.d/
cp www.conf gitlist.conf
edit gitlist.conf
    name -&gt;gitlist
    listen -&gt;nginx config 中的</code></pre>
<p>然后重启php5-fpm 和nginx访问你的地址就可以见到gitlist页面了<br />
如果你在第一步设置配置是没有问题，那网页应该就可以正常显示了，如果那时设置的不对那么<br />
编辑 <code>/home/git/.gitolite.rc</code>找到<code>$REPO_UMASK</code>改成0022然后手动设置已有的文件权限 <code>chmod -R 755 /home/git</code>应该就可以了</p>
<p><a rel="nofollow" href="https://www.fuwuqiok.com/%e5%9c%a8%e4%ba%9a%e9%a9%ac%e9%80%8aaws%e4%b8%8a%e5%bb%ba%e7%ab%8bgit%e6%9c%8d%e5%8a%a1%e5%99%a8/">在亚马逊AWS上建立Git服务器</a>，首发于<a rel="nofollow" href="https://www.fuwuqiok.com">服务器安全维护工作室</a>。</p>
]]></content:encoded>
			<wfw:commentRss>https://www.fuwuqiok.com/%e5%9c%a8%e4%ba%9a%e9%a9%ac%e9%80%8aaws%e4%b8%8a%e5%bb%ba%e7%ab%8bgit%e6%9c%8d%e5%8a%a1%e5%99%a8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
