> For the complete documentation index, see [llms.txt](https://kribakarans.gitbook.io/howto/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kribakarans.gitbook.io/howto/gitweb/setup_gitweb.md).

# setup\_gitweb

## Setup Gitweb server

1. Install `git` `gitweb` and `highlight`
2. Enable apache CGI modules and restart web server

   ```
   sudo a2enmod cgi
   sudo systemctl restart apache2
   ```
3. Update the Gitweb configs `/etc/gitweb.conf`
   * Added Project root to scan repositories\
     `$projectroot = "/home/git/projects";`
   * Enable syntax highlighting\
     `$feature{'highlight'}{'default'} = [1];`
   * Set project root\
     `$projectroot = "/home/git/projects/";`
   * Set project list\
     `$projects_list = "/home/git/projects.list";`
   * Take a look [here](https://raw.githubusercontent.com/kribakarans/howto/master/gitweb/gitweb_projects.list) for project list and save it in home directory
   * Visit [here](https://git-scm.com/docs/gitweb.conf) for more config details
4. Run the below command in project source root directory to explore your repository instantly in web-browser without adding to the config files\
   `git instaweb --httpd=apache2 --browser=firefox --local`\
   If you want to run in multiple session, randomize the port number as below\
   `git instaweb --httpd=apache2 --browser=firefox --local --port $[ $RANDOM % 1000 + 9000 ]'`
5. Explore your git repositories at <http://localhost/gitweb>

## Troubleshooting:

* Exec permission issue: `chmod +x /usr/share/gitweb/gitweb.cgi`
* Apache modules issues: Run `a2enmod cgi` and `a2enmod perl`
* CGIT not linked properly `sudo ln -s /etc/apache2/mods-available/cgi.load /etc/apache2/mods-enabled/`
* Sometimes noted that `/usr/share/gitweb` directory is not created on reinstall
