# 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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kribakarans.gitbook.io/howto/gitweb/setup_gitweb.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
