码迷,mamicode.com
首页 > Web开发 > 详细

Ubuntu Nginx搭建Gitweb服务器

时间:2014-07-03 12:49:23      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:http   文件   os   html   for   io   

安装Nginx 和 Gitweb
 
simba@simba-laptop:~$ sudo apt-get install nginx gitweb
 
修改Gitweb配置文件
simba@simba-laptop:~/git-repo$ vim /etc/gitweb.conf 
修改或添加以下:
[plain] 
 #Git库所处路径  
$projectroot = "/home/simba/git-repo";  
  
#启用追溯  
$feature {‘blame‘}{‘default‘} = [1];  
$feature {‘blame‘}{‘override‘} = 1;  
  
#启用快照(snapshot)下载  
$feature {‘snapshot‘}{‘default‘} = [‘zip‘, ‘tgz‘];  
$feature {‘snapshot‘}{‘override‘} = 1;  
 
帮助Nginx执行CGI
 
将Gitweb安装目录链接到web主目录下
simba@simba-laptop:~$ sudo ln -s /usr/share/gitweb/ /var/www/
 
修改Nginx配置文件
...
server {
set $web_root  /var/www/;
#设置变量 web_root
listen   80 default;
server_name  localhost;
 
access_log  /var/log/nginx/localhost.access.log;
 
location / {
root   $web_root;
index  index.html index.htm index.cgi;
}
 
...
 
location ~ .*\.cgi$ {
gzip off; #gzip makes scripts feel slower since they have to complete before getting gzipped
fastcgi_pass  unix:/var/run/nginx/cgiwrap-dispatch.sock;
 
 
fastcgi_index index.cgi;
fastcgi_param SCRIPT_FILENAME  $web_root$fastcgi_script_name;
fastcgi_param QUERY_STRING     $query_string;
fastcgi_param REQUEST_METHOD   $request_method;
fastcgi_param CONTENT_TYPE     $content_type;
fastcgi_param CONTENT_LENGTH   $content_length;
fastcgi_param GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param SERVER_SOFTWARE    nginx;
fastcgi_param SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param REQUEST_URI        $request_uri;
fastcgi_param DOCUMENT_URI       $document_uri;
fastcgi_param DOCUMENT_ROOT      $web_root;
fastcgi_param SERVER_PROTOCOL    $server_protocol;
fastcgi_param REMOTE_ADDR        $remote_addr;
fastcgi_param REMOTE_PORT        $remote_port;
fastcgi_param SERVER_ADDR        $server_addr;
fastcgi_param SERVER_PORT        $server_port;
fastcgi_param SERVER_NAME        $server_name;
}
 
...
}
 
重启Nginx
sudo nginx -s reload

Ubuntu Nginx搭建Gitweb服务器,布布扣,bubuko.com

Ubuntu Nginx搭建Gitweb服务器

标签:http   文件   os   html   for   io   

原文地址:http://www.cnblogs.com/zhepama/p/3821540.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!