ngx-fastdfs是nginx+lua+fastdfs实现分布式图片实时动态压缩。
install进入docker目录docker build -t fastdfs:dev .使用docker -idt -p 80:80 fastdfs:dev /bin/bash进入容器执行/etc/rc.local测试进入容器执行test目录下的./test.sh或者直接执行下面脚本fdfs_test /etc/fdfs/client.conf upload /home/steven/01.jpg...group_name=group1, ip_addr=192.168.1.181, port=23000storage_upload_by_filenamegroup_name=group1, remote_filename=M00/00/00/wKgdhFTV0ZmAP3AZAPk-Io7D4w8580.jpg...example file url: https://192.168.1.181/group1/M00/00/00/wKgdhFTV0ZmAP3AZAPk-Io7D4w8580.jpgstorage_upload_slave_by_filenamegroup_name=group1, remote_filename=M00/00/00/wKgdhFTV0ZmAP3AZAPk-Io7D4w8580_big.jpg...example file url: https://192.168.1.181/group1/M00/00/00/wKgdhFTV0ZmAP3AZAPk-Io7D4w8580_big.jpgphp调用首先进入php_client./configure --with-php-config=/usr/local/php/bin/php-configmake&&make install在php.ini里添加extension=fastdfs_client.so[fastdfs_client]fastdfs_client.base_path = /home/fastdfs/fastdfsfastdfs_client.connect_timeout = 2fastdfs_client.network_timeout = 60fastdfs_client.log_level = infofastdfs_client.log_filename =fastdfs_client.tracker_group_count = 1fastdfs_client.tracker_group0 = /etc/fdfs/client.conffastdfs_client.use_connection_pool = truefastdfs_client.connection_pool_max_idle_time = 3600根据自己的情况做相应的修改重启php-fpm执行test目录下的fastdfs.php就可以看到效果了使用效果自动压缩自动压缩采用减少图片质量来达到减小图片体积的效果使用方法是把nginx里的nginxauto.conf替换原有的或者自己按着该文件修改把lua里的thumbnailauto.lua文件替换原有的或者自己按着该文件修改注意:fastdfs的storage的配置/etc/fdfs/storage.conf中run_by_group和run_by_user,最好跟nginx的用户组配置一样项目地址github地址:https://github.com/qieangel2013/ngx-fastdfs欢迎star点击空白处退出提示
评论