首页 轻量级开源目录浏览

轻量级开源目录浏览

°只为大大 2018-04-14 目录浏览 16768 6

Kerwin Directory 是一个轻量级开源目录浏览  演示地址 : http://dir.kerwin.cn/

功能 

  • 支持当前页面二维码扫描
  • 支持远程登陆设置密码
  • 配置文件由ini读写
  • 输入密码之后获取的下载地址,分享别人可直接下载,无需密码,有效期配置文件中可设置。


image.png


Windows-IIS部署

  • 安装IIS

  • 开始-->windows系统-->控制面板-->程序-->启用或关闭windows功能,勾选Internet Information Services下的所有,点击确认开始安装IIS

http://img.zhanghuanglong.com//image/2018/04/14/20180414205418280261.png

  • IIS站点搭建

  • 下载源码 https://git.kerwin.cn/Kerwin/Kerwin.Directory 下载之后下一步物理路径指向Kerwin.Directory.Web目录

  • 修改配置

  • 配置文件在`Kerwin.Direcrory/Kerwin.Direcrory.Web/config/config.ini`中

  • 主要注意的是,首次运行之后,则配置文件位置移动到了 配置文件在co/Kerwin.Directory/Kerwin.Directory.Web/bin/Release/config/config.ini 中

  • 配置站点:右击我的电脑-->管理-->服务和应用程序-->IIS管理器 新建站点,如下图

http://img.zhanghuanglong.com//image/2018/04/14/20180414204545110958.png

  • 设置设置应用程序池为无托管 第2步骤图中网站上一个有一个应用程序池,,点击应用程序池-->双击网站名称对应的-->.net clr版本选择无托管

  • 重启iis服务 cmd下输入以下

net stop was /y
net start w3svc

Linux-Nginx部署

这个部署方法不管Windows下还是Linux都可以使用,唯一区别就是操作系统命令不同的区别

以Ubuntu为例

  • 安装.net core sdk

root@ubuntu:~# curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
root@ubuntu:~# sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
root@ubuntu:~# sudo sh -c 'echo "deb [arch=amd64] root@ubuntu:~# https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list'

root@ubuntu:~# sudo apt-get install apt-transport-https
root@ubuntu:~# sudo apt-get update
root@ubuntu:~# sudo apt-get install dotnet-sdk-2.1.104

以下为安装成功 安装之前也可以输入查看是否安装过

root@ubuntu:~# dotnet --version
2.1.104
root@ubuntu:~#

  • 安装git

root@ubuntu:~# sudo apt-get install git

以下为安装成功 安装之前也可以输入查看是否安装过

root@ubuntu:~# git --version
git version 2.7.4
root@ubuntu:~#

  • clone下源码

root@ubuntu:~# git clone https://git.kerwin.cn:4443/Kerwin/Kerwin.Directory.git
root@ubuntu:~# cd Kerwin.Directory/
root@ubuntu:~/Kerwin.Directory# ls
Kerwin.Directory.sln  Kerwin.Directory.Web
root@ubuntu:~/Kerwin.Directory#

  • 安装Nginx

root@ubuntu:~/# sudo apt-get install nginx
root@ubuntu:~/# sudo service nginx start

  • 修改Nginx配置

root@ubuntu:~/Kerwin.Directory# sudo nano /etc/nginx/sites-available/default

没有安装过Nginx也不会的直接把下面内容替换为整个default

server {
    listen        80;
    server_name   example.com *.example.com; #域名
    location / {
        proxy_pass         http://localhost:5000;  #本地监听的地址 这个端口暂时默认5000 下面会修改也可以不修改
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection keep-alive;
        proxy_set_header   Host $http_host;
        proxy_cache_bypass $http_upgrade;
    }
}
  • Nginx重新加载配置
root@ubuntu:~/Kerwin.Directory# sudo nginx -s reload修改配置文件

  • 修改站点配置文件

  • 这个是配置文件所有配置都在里面 有些配置被注释,代表未实现

  • 主要注意的是,首次运行之后,则配置文件位置移动到了 /Kerwin.Directory/Kerwin.Directory.Web/bin/Release/config/config.ini 中

root@ubuntu:~/Kerwin.Directory# cd Kerwin.Directory.Web/Models/
root@ubuntu:~/Kerwin.Directory/Kerwin.Directory.Web/Models# nano ConfigSettings.cs

其他可以不修改,也可以按照注释修改,文件中的这个必须要修改把 h:\修改为想要监听的根目录即可 例如 /root/

/// <summary>
/// Root dir
/// 根目录 实际文件所在的目录
/// </summary>
public static string RootDir { get; set; } = @"h:\";
  • 运行
//下面第一步这个是由于上面修改了配置所在的目录不正确,,向上两个
root@ubuntu:~/Kerwin.Directory/Kerwin.Directory.Web/Models# cd ../../ 
root@ubuntu:~/Kerwin.Directory# dotnet run -p Kerwin.Directory.Web -c Release --no-launch-profile
Hosting environment: Production
Content root path: /root/Kerwin.Directory/Kerwin.Directory.Web
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.

现在访问域名或者Linux所在的局域网机器即可访问了..

  • 修改默认端口

  • 如果5000端口被占用或者想换个端口
root@ubuntu:~/Kerwin.Directory# ASPNETCORE_URLS="http://localhost:52521" dotnet run -p Kerwin.Directory.Web -c Release --no-launch-profile

除另有声明外,本文章轻量级开源目录浏览采用 知识共享(Creative Commons) 署名-非商业性使用-相同方式共享 3.0 中国大陆许可协议 进行许可。

评论
目录