Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7344967
  • 博文数量: 1763
  • 博客积分: 18684
  • 博客等级: 上将
  • 技术积分: 16217
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-02 10:28
个人简介

啥也没写

文章分类

全部博文(1763)

文章存档

2023年(44)

2022年(39)

2021年(46)

2020年(43)

2019年(27)

2018年(44)

2017年(50)

2016年(47)

2015年(15)

2014年(21)

2013年(43)

2012年(143)

2011年(228)

2010年(263)

2009年(384)

2008年(246)

2007年(30)

2006年(38)

2005年(2)

2004年(1)

分类: 系统运维

2020-05-21 23:52:56

需要安装qrencode和libpng
yum install libpng-devel lua lua-devel -y

wget
tar -zxvf qrencode-4.0.2.tar.gz
cd qrencode-4.0.2
./configure
make
make install
cd ..

git clone
cd qrencode
make    #可能会出问题
//mac下面可以用gcc编译
gcc -bundle -undefined dynamic_lookup -lpng -lqrencode -I/usr/local/openresty/luajit/include/luajit-2.1/ qrencode.c -o qrencode.so
cp qrencode.so  /usr/local/openresty/lualib/

vi nginx.conf
....
    location = /qrcode {
        content_by_lua_block {
            local qr = require("qrencode")
            local args = ngx.req.get_uri_args()
            local url = args.url


            if url == nil or url== "" then
                ngx.print('')
                ngx.exit(201)
            end


            ngx.header.content_type = 'image/png'
            ngx.say(qr {
                text=url,
                level="L",
                kanji=false,
                ansi=false,
                size=4,
                margin=2,
                symversion=0,
                dpi=78,
                casesensitive=true,
                foreground="000000",
                background="FFFFFF"
            })
        }
        add_header Pragma "no-cache";
        add_header Cache-Control "no-cache, max-age=0, must-revalidate";
    }
    ....

打开网站
http://localhost:8080/qrcode?url=http://badb0y.blog.chinaunix.net

阅读(1767) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~