105 lines
4.0 KiB
Markdown
105 lines
4.0 KiB
Markdown
# Installing simple-gitv
|
|
|
|
These instructions will setup an Apache server which will serve pages from /var/www/git/ showing information about Git repositories stored in /srv/git/. If you want to use different paths, change those whenever they are shown.
|
|
|
|
I have only tested this on Fedora. If you're installing on a different distribution like Debian or Arch, you may need different packages (such as apache2 instead of httpd) or put settings in different places. I also assume SystemD. If you're using a different init system, you'll have a different command to run the webserver.
|
|
|
|
## 0. Do this stuff first
|
|
1. Register your domain name.
|
|
2. Set up DNS to point your domain to your IP address.
|
|
3. Set up port forwarding to forward incoming TCP connections on ports 80 and 443 to your server.
|
|
4. Install dependencies:
|
|
|
|
### Mandatory Dependencies
|
|
- A webserver (httpd)[^1]
|
|
- PHP
|
|
- Git
|
|
|
|
### Optional Dependencies
|
|
- pandoc[^2]
|
|
|
|
## 1. Download Project
|
|
Clone the repository using Git and switch to that directory (for later steps).
|
|
|
|
## 2. Configure Webserver
|
|
A default configuration file has been included. Copy it to /etc/httpd/conf.d/ so you can use it as a virtualhost:
|
|
|
|
`sudo cp templates/httpd-git.conf.template /etc/httpd/conf.d/git.conf`
|
|
|
|
Edit /etc/httpd/conf.d/git.conf so it shows your domain name instead of example.com.
|
|
|
|
This file also assumes that you are using a LetsEncrypt certificate stored in /etc/letsencrypt/live/example.com/ and redirects all HTTP traffic to HTTPS. If this is not the desired behavior for you, change it.
|
|
|
|
To enable caching, create a directory called "cache" in the root directory of the project:
|
|
|
|
`mkdir cache`
|
|
|
|
Set the permissions to 777 to enable httpd to write to the cache directory:
|
|
|
|
`sudo chmod 777 cache`
|
|
|
|
## 3. Run Webserver
|
|
If you're using SystemD as your init system, run:
|
|
|
|
`sudo systemctl start httpd`
|
|
|
|
to start the server, and:
|
|
|
|
`sudo systemctl enable httpd`
|
|
|
|
to enable the server to run at startup.
|
|
|
|
## 4. Add Git Repositories
|
|
Create the directory /srv/git/ if it doesn't already exist:
|
|
|
|
`sudo mkdir -p /srv/git`
|
|
|
|
You may want to change the owner of /srv/git/ to you so you can more easily modify your repos:
|
|
|
|
`sudo chown -R myusername:myusername /srv/git`
|
|
|
|
replacing "myusername" with your username.
|
|
|
|
Now `cd /srv/git` and put your Git repositories there. If you want to create a new repo:
|
|
|
|
`git init --bare newrepo`
|
|
|
|
If you want to clone a repo from somewhere else, you can do so with:
|
|
|
|
`git clone --bare https://example.com/path/to/project.git`
|
|
|
|
replacing the URL above with the repo you want to clone.
|
|
|
|
## 5. Configure SELinux (if you use it)
|
|
SELinux will prevent httpd from reading /srv/git/ to view your repositories. If you use SELinux (e.g., if you're on Fedora, CentOS, or RHEL), add an exception for this:
|
|
|
|
- `semanage fcontext -a -t httpd_sys_content_t "/srv/git(/.*)?"`
|
|
- `restorecon -Rv /srv/git`
|
|
|
|
Note, we are only giving Apache **read** permission, but not **write** permission on /srv/git. If you want users to be able to git push over HTTP, you will need to also allow write permission.
|
|
|
|
To enable caching, you will need to enable httpd to read and write to cache:
|
|
|
|
- `semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/git/cache/*"`
|
|
- `restorecon -Rv /var/www/git/cache/`
|
|
|
|
## 6. Configure
|
|
Go back to the project code:
|
|
|
|
`cd /var/www/git/`
|
|
|
|
Copy the config.ini template to the root directory of the project:
|
|
|
|
`cp templates/config.ini.template config.ini`
|
|
|
|
Edit config.ini to your needs. Lines beginning with a semicolon (;) are comments are will not affect anything.
|
|
|
|
Set the title of your page. For example, you can use the domain or a name like "Suzan's Code".
|
|
|
|
If you used a different path for your repositories, change the value of repositories.
|
|
|
|
If the default theme is not to your liking, you're welcome to change it.
|
|
|
|
[^1]: Currently I only have a config file for Apache. I hope to add nginx and lighttpd support soon. If you want to write your own configurations for those, please do and let me know how you did it!
|
|
[^2]: Pandoc is used to interpret Markdown files as HTML. If pandoc is missing, Markdown files will be previewed as plaintext.
|