设为首页 收藏本站
查看: 783|回复: 0

[经验分享] Gitweb and apache server in ubuntu 10.04-The Way ...

[复制链接]

尚未签到

发表于 2018-11-27 10:45:11 | 显示全部楼层 |阅读模式
  Hi this is a simple problem that I had with Ubuntu 10.04 , git 1.7.1.1, gitweb and apache http server 2.2.16. las week.
  The main problema was that I couldn't implement a local server for and internal project in a LAN network and then public the Git repositories in a gitweb template and that any one inside the LAN could clone them by http .
  Well there are many pages of how to do this and they were very helpful you will find them in the end of this comment but I hope this detailed guide could help someone else if you follow this steps
  first you should have installed in your computer the latest version of git ( http://git-scm.com/ ) or tipe
  $sudo apt-get install git-core
  Install the apache server 2
  $sudo apt-get install apache2-utils apache2-common
  Then after doing this you should be able to type in your browser http://localhost/ and it should appear
  It works!
  This is the default web page for this server.
  The web server software is running but no content has been added, yet.
  Well done you have a local server on your LAN wasn't so hard really ? So try it type your IP in the web browser
  $ifconfig
  will show your IP
  NOW THE HARDEST PART FOR ME sorry if it isn't for some one else. But I am new in linux and was hard.
  VIRTUAL HOST
  imagine that this is not a computer instead a server, as you want well it should have the capability to handle different web pages or hosts
  Virtual Hosting allow web servers to host more than one website on a single machine. This is how sharing hosting works. It will allow you to access to your local repository using addresses such as http://dev.mysite.com instead of http://localhost/~myuser/myproject/ DSC0000.gif .
  First of all, you need an apache server ready to run on your machine (like we said before), if it is not yet install, open a terminal and type
  Once the server is installed, it is time to get into apache 2 configuration.
  Let's open apache's main configuration file, name /etc/apache2/apache2.conf. A search for the word virtual bring us to the following line:
  Include /etc/apache2/sites-enabled/[^.#]*
  This mean that when starting apache, it will look for files in /etc/apache2/sites-enabled/.
  Let’s go there and see what is in.
$cd /etc/apache2/sites-enabled/
  
$ls -l
  
total 1
  
lrwxrwxrwx 1 root root 36 2005-12-27 01:42 000-default -> /etc/apache2/sites-available/default
Well, this only links to the file in directory /etc/apache2/sites-available/ . You might wonder what is the point in doing such. Well, this simply allows you, mainly when you are using your box as a web server, to:   

  • Have a simple main configuration file   
  • Do be able to edit or create a new host by creating/editing a file from /etc/apache2/sites-available/   
  • In case your web server doesn't restart because of misconfiguration, you can simply remove the link from the file in /etc/apache2/sites-enabled/ pointing to the malformed file in /etc/apache2/sites-available/
Now let say you want to be able to map the domain name dev.example.com to you local machine, using the code file in/home/myuser/public_html/example.com/.  While in /etc/apache2/sites-available, create a new file (let say example.com.conf)
$sudo vi example.com.conf
Now add the following lines:   
  ServerAdmin webmaster@localhost
  #We want to be able to access the web site using www.dev.example.com or dev.example.com
  ServerAlias www.dev.example.com
  DocumentRoot /home/myuser/public_html/example.com
  #if using awstats
  ScriptAlias /awstats/ /usr/lib/cgi-bin/
  #we want specific log file for this server
  CustomLog /var/log/apache2/example.com-access.log combined
  
Now, we specified a new host to apache but it is not yet linked to the repertory where apache actually look for virtual hosts. Let go to:   
$cd /etc/apache2/sites-enabled/
and create a link to the file we just created:   
$sudo ln -s /etc/apache2/sites-available/example.com.conf example.com.conf
Now apache is almost ready to restart, but before doing so, we must inform our linux system that dev.example.com and www.dev.example.com are not to be looked for on the net, but on the local machine instead.  To do so, simply edit /etc/hosts and add the new host names at the end of the line beginning by 127.0.0.1, which is localhost.
  In the end, your file should look like:
127.0.0.1 localhost.localdomain localhost dev.example.com www.dev.example.com
And now we are done, simply>sudo /etc/init.d/apache2>  Open your web browser and enter the following address dev.example.com. And will bring your web page.
  CLONING YOUR PROJECT BY YOUR VIRTUAL HOST
  If it works well there are just one single thing to do in order to work with static IP addresses
  if your IP is FOR EXAMPLE 197.12.2.0
  
  ServerAdmin webmaster@localhost
  #We want to be able to access the web site using www.dev.example.com or dev.example.com
  ServerAlias www.dev.example.com
  DocumentRoot /home/myuser/public_html/example.com
  #if using awstats
  ScriptAlias /awstats/ /usr/lib/cgi-bin/
  #we want specific log file for this server
  CustomLog /var/log/apache2/example.com-access.log combined
  
  and that’s all, try to put your IP address in other computer and it will work with out touching the /etc/hosts file.
  Now let’s check if this work in git repositories, that is what we want.
  Imagine that you have a Git project like project1, we need to clone it with --bare option in order to put it like public, this topic is well described in the progit book (http://progit.org/book/) on the public server chapter (http://progit.org/book/ch4-5.html) when you have your git repositories like project1.git in the example directory /home/yourname/yourrepos/ and you can clone it successfully with the instruction
  git clone /home/yourname/yourrepos/project1.git
  in any place of your computer, it means that you just need to do this
  $ cd project1.git
  $ mv hooks/post-update.sample hooks/post-update
  $ chmod a+x hooks/post-update
$ git update-server-info
  Next, you need to add a VirtualHost entry to your Apache configuration with the document root as the root directory of your Git projects. ( This was the part that I was stook for a week )
  We already have a virtual host working ( that was why I decided to first implement the Visrtual Host in apache )
  
  ServerAdmin webmaster@localhost
  ServerName git.example.com
  ServerAlias www.git.example.com
  DocumentRoot /home/yourname/yourrepos
  ScriptAlias /awstats/ /usr/lib/cgi-bin/
  CustomLog /var/log/apache2/example.com-access.log combined
  
  You’ll also need to set the Unix user group of the drectories to www-data so your web server can read-access the repositories, because the Apache instance running the CGI script will (by default) be running as that user:
  $ chgrp -R www-data /home/yourname/yourrepos/

  Now>  Try to clone your project
  $git clone http://197.12.2.0/project1.git
  If it works, perfect you can keep on this tutorial.
  GITWEB
  Install gitweb
  $ sudo apt-get install gitweb
  clone the git project
  $ git clone git://git.kernel.org/pub/scm/git/git.git
  generate the custom CGI script
  $ cd git/
  $ make GITWEB_PROJECTROOT=" /home/yourname/yourrepos/" prefix=/usr gitweb/gitweb.cgi
  $ sudo cp -Rf gitweb /var/www/
  now check the /etc/gitweb.conf file , it shoul be something like this
  # path to git projects (.git) #### CHANGE TO YOUR PROJECTROOT###
  $projectroot = "/home/yourname/yourrepos/";
  # directory to use for temp files
  $git_temp = "/tmp";
  # target of the home link on top of all pages
  #$home_link = $my_uri || "/";
  # html text to include at home page
  $home_text = "indextext.html";
  ########CHANGE TO YOUR LAST VIRTUAL HOST ####        
  @git_base_url_list = ('http://git.example.com');
  # file with project list; by default, simply scan the projectroot dir.
  $projects_list = $projectroot;
  # stylesheet to use
  $stylesheet = "/gitweb/gitweb.css";
  # logo to use
  $logo = "/gitweb/git-logo.png";
  # the 'favicon'
  $favicon = "/gitweb/git-favicon.png";
  Now we should make another Virtual Host like we did above in the VIRTUAL HOST section
  but it should be like this
  
  ServerName dev.example.com
  ServerAlias www.dev.example.com
  DocumentRoot /var/www/gitweb
  
  Options ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch
  AllowOverride All
  order allow,deny
  Allow from all
  AddHandler cgi-script cgi
  DirectoryIndex gitweb.cgi
  
  #if using awstats
  ScriptAlias /awstats/ /usr/lib/cgi-bin/
  #we want specific log file for this server
  CustomLog /var/log/apache2/example.com-access.log combined
  

  If you>  The next thing to do is to enable virtual hosts in your Apache configuration. The simplest way to do this is to create a file called /etc/apache2/conf.d/virtual.conf and include the following content in it:
#  # We're running multiple virtual hosts.
  #
  NameVirtualHost *
  (When Apache starts up it reads the contents of all files included in /etc/apache2/conf.d, and files you create here won't get trashed on package upgrades.)
  To enable the sites that we have created simply run as root :
  # a2ensite git.example.com
  and the same for all the sites enabled
  At finally thats all, it wasn't soo difficult but take some time to fix this problem now when you load your web page it should look like http://git.kernel.org/ and you should be able to clone like your web page said.
  #################IMPORTANT #################
  IF YOU HAVE A PROXY IN YOUR NETWORK YOU SHOULD DESEABLE COMPLETELY IF NOT SOME ERRORS LIKE 504 OR 500 WILL APEAR IN YOUR TERMINAL WHEN YOU TRIE TO CLONE THE PROJECTS
  TRY WITH unset http_proxy
  it could work it depends how you had configure your proxy
  if some one else find another way to do this please feel free to contribute whit this long post
  Hope it could help someone trying to do implement gitweb in ubuntu 10.04 and apache 2
  Thanks for all
  Sincerely yours
  Victor Rodriguez


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-640219-1-1.html 上篇帖子: Apache日志分割 下篇帖子: linux下Apache安装(转)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表