Skip to content
This repository was archived by the owner on Nov 10, 2018. It is now read-only.

Commit 155b080

Browse files
committed
readme.md
1 parent 8bc0090 commit 155b080

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ OpenResty (nginx+lua) + ceph + GraphicsMagick ,一个类似于 zimg, 动态生
66

77
整个架构类似于zimg, 在http层加了redis缓存,处理后的保存为文件也算是个缓存,可以写个crontab脚本定期清理不常访问的缓存图片。
88

9-
### 图片存储路径的规划方案。
9+
### 图片存储路径的规划方案。
1010

1111
借鉴 zimg 的方案,存储路径采用2级子目录的方案。由于 Linux 同目录下的子目录数最好不要超过2000个,再加上 MD5 的值本身就是32位十六进制数,zimg就采取了一种非常取巧的方式:根据 MD5 的前六位进行哈希,1-3位转换为十六进制数后除以4,范围正好落在1024以内,以这个数作为第一级子目录;4-6位同样处理,作为第二级子目录;二级子目录下是以 MD5 命名的文件夹,每个MD5文件夹内存储图片的原图和其他根据需要存储的版本,假设一个图片平均占用空间200KB,一台服务器支持的总容量就可以计算出来了:
1212

@@ -53,8 +53,18 @@ add "include conf.d/*.conf;" into nginx.conf
5353
5454
bash deploy.sh
5555
56+
# and add images folder, change it at config.lua if you need.
57+
58+
mkdir /home/files/images/
59+
chown -R {nginx_user}/home/fiels/images
5660
```
5761

62+
#### 上传图片
63+
64+
http://localhost:8000/static/image-upload/
65+
66+
上传成功。
67+
5868
如果没有错误,就可以访问了。
5969

6070
```
@@ -78,10 +88,10 @@ http://localhost:8000/get_info?md5=fffc929444a9fb7eb754217cfd7b0d58
7888
See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project.
7989

8090
## Benchmark
81-
see the [Benchmark.md](benchmark.md) file for details
91+
see the [Benchmark.md](Benchmark.md) file for details
8292
## License
8393

84-
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
94+
This project is licensed under the MIT License
8595

8696
## Acknowledgments
8797

ngx-lua-images/lua/config.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
local prefix = '/home/files/'
22

33
config = {
4-
images_dir = prefix .. "images/", -- where images come from
5-
caches_dir = prefix .. "caches/", -- where images are cached
4+
images_dir = prefix .. "images/", -- where images and caches
65
timeout = 300, -- * 24 * 3600 -- redis timeout (sec)
76
ceph_mode = true,
87
host = 'http://192.168.2.99',

0 commit comments

Comments
 (0)