在群晖网络存储服务器(DSM)上安装git和网页浏览

配置SSH

  • 通过 控制面板 > 终端机和 SNMP > 终端机 启用ssh功能
  • 修改端口,减少受攻击的可能
  • SSH 仅支持属于 administrators 群组的帐户登录系统
  • 修改/etc/ssh/sshd_config文件关闭使用密码登陆 PasswordAuthentication no
  • 通过 控制面板 > 安全性 > 账户 启用自动封锁,可封锁登陆尝试失败次数过多的IP

安装git

  • 通过 套件中心 安装Git Server

安装 gitlist 实现网页浏览

  • 通过 套件中心 安装Web Station
  • 通过 Web Station > PHP设置 启用phar扩展
  • ssh login,执行以下命令从源码安装gitlist
cd /var/services/web  # root folder of web station

# clone gitlist
git clone https://github.com/klaussilveira/gitlist.git

# install pho composer
cd gitlist
curl -s https://getcomposer.org/installer | php

# install dependecy
php composer.phar install
  • 修改gitlist/config.ini 配置
  • 创建访问密码文件目录(不需要root权限,并且http用户能够访问,但不能通过网页访问)
mkdir /volume1/web/passwd/
  • 创建 passwd/.htaccess 文件
AuthName "Title"
AuthType "Digest"
AuthUserFile "/volume1/web/passwd/file_not_exists"
Require valid-user
  • 创建 gitlist/.htaccess 文件 设定访问权限
<IfModule mod_rewrite.c>
    Options -MultiViews +SymLinksIfOwnerMatch

    RewriteEngine On
    #RewriteBase /path/to/gitlist/

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php/$1 [L,NC]
</IfModule>
<Files config.ini>
    order allow,deny
    deny from all
</Files>

AuthName "Title"
AuthType "Basic"
AuthUserFile "/volume1/web/passwd/gitlist.pw"
Require valid-user
  • 创建访问用户和密码
htpasswd -c /volume1/web/passwd/gitlist.pw username
  • 修改缓存目录权限
chmod 777 cache

打开浏览器,访问 http://example.synology.me/gitlist,效果图如下

小技巧

  • 修改git仓库目录下的description文件内容,可以给项目加上简短的描述

 

One Reply to “在群晖网络存储服务器(DSM)上安装git和网页浏览”

  1. 我用你的了,测试好多次不行呢,不知道哪里原因,#RewriteBase /path/to/gitlist/到底打开还是关闭

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.