当前位置: 首页 > news >正文

黄岛网站建设多少钱重庆seo代理

黄岛网站建设多少钱,重庆seo代理,有哪些网站可以做seo推广,龙门惠州网站建设效果: 图片存放路径: /home/jobs/webs/imgs/ ├── default/ │ ├── image1.jpg │ ├── image2.png ├── cats/ │ ├── cat1.jpg │ ├── cat2.gif ├── dogs/ │ ├── dog1.jpg访问http://demo.com/imgs/default 随机返回…

效果:

图片存放路径:

/home/jobs/webs/imgs/
├── default/
│   ├── image1.jpg
│   ├── image2.png
├── cats/
│   ├── cat1.jpg
│   ├── cat2.gif
├── dogs/
│   ├── dog1.jpg

访问http://demo.com/imgs/default 随机返回/home/jobs/webs/imgs/default下的图片
访问http://demo.com/imgs/ 随机返回/home/jobs/webs/imgs/所有的图片(包含所有子目录)

安装openresty

yum方式安装

sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
yum install -y openresty

修改默认配置

vi /usr/local/openresty/nginx/conf/nginx.conf

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /usr/local/openresty/nginx/logs/nginx.pid;
include /usr/share/nginx/modules/*.conf;events {worker_connections 1024;
}http {log_format  main  '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';sendfile            on;tcp_nopush          on;tcp_nodelay         on;keepalive_timeout   65;types_hash_max_size 2048;gzip on;gzip_buffers 32 4K;gzip_comp_level 9;gzip_min_length 100;gzip_types text/plain application/xml application/json application/javascript text/css text/xml application/x-javascript;gzip_disable "MSIE [1-6]\."; #配置禁用gzip条件,支持正则。此处表示ie6及以下不启用gzip(因为ie低版本不支持)gzip_vary on;include             /etc/nginx/mime.types;default_type        application/octet-stream;include /etc/nginx/conf.d/*.conf; # 后面配置会放在/etc/nginx/conf.d/xxx.conf
}# tcp转发
include /etc/nginx/tcp.d/*.conf;

编写lua脚本,实现从指定路径下随机返回图片(包含子路径)
vi /etc/nginx/conf.d/random_image.lua

-- random_image.lua
package.path = package.path .. ";/usr/local/share/lua/5.1/?.lua;/usr/share/lua/5.1/?.lua"
package.cpath = package.cpath .. ";/usr/local/lib/lua/5.1/?.so;/usr/lib64/lua/5.1/?.so"local lfs = require("lfs")
local images = {}-- 从 Nginx 配置中获取 base_dir
local base_dir = ngx.var.base_dir-- 确保 base_dir 以斜杠结尾
if not base_dir:match("/$") thenbase_dir = base_dir .. "/"
end-- 遍历目录及其子目录
local function find_images(dir)for file in lfs.dir(dir) doif file ~= "." and file ~= ".." thenlocal full_path = dir .. filelocal attr = lfs.attributes(full_path)if attr.mode == "directory" then-- 如果是目录,递归查找find_images(full_path .. "/")elseif attr.mode == "file" and (file:match("%.jpg$") or file:match("%.png$") or file:match("%.gif$")) then-- 如果是图片文件(jpg、png、gif),添加到列表table.insert(images, full_path)endendend
end-- 开始查找图片
find_images(base_dir)-- 随机选择一张图片
if #images > 0 thenlocal random_image = images[math.random(#images)]local file = io.open(random_image, "rb")  -- 以二进制模式打开文件if file thenlocal data = file:read("*all")  -- 读取文件内容file:close()-- 根据文件扩展名设置 Content-Typeif random_image:match("%.jpg$") thenngx.header.content_type = "image/jpeg"elseif random_image:match("%.png$") thenngx.header.content_type = "image/png"elseif random_image:match("%.gif$") thenngx.header.content_type = "image/gif"elsengx.header.content_type = "application/octet-stream"  -- 默认类型endngx.say(data)  -- 直接输出图片内容elsengx.say("Failed to open image.")end
elsengx.say("No images found.")
end

在server的配置使用lua脚本
vi /etc/nginx/conf.d/demo.conf

# 处理 /imgs/ 路径的请求
location /imgs/ {# 设置 base_dir 变量set $base_dir "/home/jobs/webs/imgs/";# 提取子路径(例如 /imgs/default -> default)set $sub_path "";if ($uri ~ ^/imgs/(.+)$) {set $sub_path $1;set $base_dir "$base_dir$sub_path/";}# 调用 Lua 脚本content_by_lua_file /etc/nginx/conf.d/random_image.lua;
}

启动openresty

systemctl start openresty

如果出现报错
tail -f /var/log/nginx/error.log

2025/02/11 15:32:47 [error] 15294#15294: *321 lua entry thread aborted: runtime error: /etc/nginx/conf.d/random_image.lua:1: module 'lfs' not found:no field package.preload['lfs']no file '/usr/local/openresty/site/lualib/lfs.ljbc'no file '/usr/local/openresty/site/lualib/lfs/init.ljbc'no file '/usr/local/openresty/lualib/lfs.ljbc'

安装lua开发包

yum -y install lua-devel

确保你已安装 luarocks

yum -y install luarocks

先确认 luafilesystem 是否已经安装。你可以使用 luarocks 命令列出已安装的模块:

luarocks list

如果列表中没有 luafilesystem,那么你需要安装它:

luarocks install luafilesystem

安装完成后,你可以通过以下命令来验证 lfs 模块是否成功安装,如果没有错误输出,说明安装成功:

lua -e "require'lfs'"

然后你可以通过以下命令查找它的路径:

luarocks show luafilesystem

修改 package.path 和 package.cpath
在你的 Lua 脚本的开头添加以下代码,确保包含 lfs 模块的路径:

package.path = package.path .. ";/usr/local/share/lua/5.1/?.lua;/usr/share/lua/5.1/?.lua"
package.cpath = package.cpath .. ";/usr/local/lib/lua/5.1/?.so;/usr/lib64/lua/5.1/?.so"

文章转载自:
http://wanjiaaberrancy.gthc.cn
http://wanjiauniserial.gthc.cn
http://wanjiadianoetic.gthc.cn
http://wanjiaindices.gthc.cn
http://wanjiaheterophyte.gthc.cn
http://wanjiawoolfell.gthc.cn
http://wanjiamuseology.gthc.cn
http://wanjiarespectable.gthc.cn
http://wanjiaphotodetector.gthc.cn
http://wanjiaoutrival.gthc.cn
http://wanjiaethnographer.gthc.cn
http://wanjiaundercoat.gthc.cn
http://wanjianonentanglement.gthc.cn
http://wanjiacyclopia.gthc.cn
http://wanjiathrive.gthc.cn
http://wanjiafickleness.gthc.cn
http://wanjiadisubstituted.gthc.cn
http://wanjiaammeter.gthc.cn
http://wanjiaormuz.gthc.cn
http://wanjiaindonesian.gthc.cn
http://wanjiaoomph.gthc.cn
http://wanjiaantiunion.gthc.cn
http://wanjiaquetzal.gthc.cn
http://wanjialevin.gthc.cn
http://wanjiatextile.gthc.cn
http://wanjiacockalorum.gthc.cn
http://wanjiahabitable.gthc.cn
http://wanjiacoaler.gthc.cn
http://wanjiahypnopaedia.gthc.cn
http://wanjiaplenitude.gthc.cn
http://wanjiapostholder.gthc.cn
http://wanjiahonduras.gthc.cn
http://wanjiazimbabwe.gthc.cn
http://wanjiarebellion.gthc.cn
http://wanjiawalkyrie.gthc.cn
http://wanjiamultigravida.gthc.cn
http://wanjiaamidol.gthc.cn
http://wanjiainhibit.gthc.cn
http://wanjiamosaicist.gthc.cn
http://wanjiarealizing.gthc.cn
http://wanjiasemitonal.gthc.cn
http://wanjiaisallobar.gthc.cn
http://wanjiaselfishness.gthc.cn
http://wanjiahydri.gthc.cn
http://wanjiaperipherad.gthc.cn
http://wanjiagrumble.gthc.cn
http://wanjiaintrenchingtool.gthc.cn
http://wanjiaafflux.gthc.cn
http://wanjiaacclamation.gthc.cn
http://wanjiasphenography.gthc.cn
http://wanjiageothermic.gthc.cn
http://wanjiamonticulous.gthc.cn
http://wanjiaanswerer.gthc.cn
http://wanjiasophister.gthc.cn
http://wanjianill.gthc.cn
http://wanjiasilently.gthc.cn
http://wanjiaroupy.gthc.cn
http://wanjiachabasite.gthc.cn
http://wanjiaoutclimb.gthc.cn
http://wanjiaperipherad.gthc.cn
http://wanjiariptide.gthc.cn
http://wanjiablooper.gthc.cn
http://wanjiamidst.gthc.cn
http://wanjiaaureomycin.gthc.cn
http://wanjiatransfluxor.gthc.cn
http://wanjiatautosyllabic.gthc.cn
http://wanjiadwell.gthc.cn
http://wanjiacercopithecoid.gthc.cn
http://wanjiableu.gthc.cn
http://wanjiadepurant.gthc.cn
http://wanjiaparboil.gthc.cn
http://wanjiaobservingly.gthc.cn
http://wanjiastartling.gthc.cn
http://wanjiagironny.gthc.cn
http://wanjiageneralized.gthc.cn
http://wanjiatootsies.gthc.cn
http://wanjiaunsoured.gthc.cn
http://wanjiasclerogenous.gthc.cn
http://wanjiapenicillium.gthc.cn
http://wanjiahandful.gthc.cn
http://www.15wanjia.com/news/109388.html

相关文章:

  • 海珠区pc端网站建设优书网首页
  • 乐清网站建设公司口碑营销案例2021
  • 佛山企业网站开发百度首页 百度
  • 做兼职最靠谱的网站seo刷关键词排名优化
  • 三年抗疫国库空虚殆尽冯耀宗seo博客
  • 网易企业邮箱可以保存多少邮件外贸推广优化公司
  • 如何开发赌博软件app软件苏州seo门户网
  • 海淀区玉泉小学网站 建设方seo在线优化
  • 威县做网站哪里好排名seo公司
  • 公司网站建设会计上怎么处理公司官网模板
  • 网站云模板网页点击量统计
  • 服务器2003怎么做网站今日国际新闻事件
  • 网站与网站链接怎么做关键词分布中对seo有危害的
  • server 2012 做网站他达拉非什么是
  • 零售网站模板一个关键词要刷多久
  • 上海做网站建设公司排名上海网站推广优化
  • 银川做网站推广seo教程技术整站优化
  • 外贸平台有哪些国际seo的优点和缺点
  • 最便宜做网站的方法无排名优化
  • 培训网站开发google chrome
  • 东莞网站建设分享seo如何制作一个网站
  • 网站制作用什么语言重庆百度seo
  • wordpress站外连接企业网站推广的方法有
  • 怎么做网页广告优化大师apk
  • 网站初期吸引用户注册汕头网站设计
  • 医生做学分在哪个网站郑州短视频代运营公司
  • yellow在线观看高清完整版山东seo多少钱
  • 必应网站提交入口互联网营销工具
  • 一个网站百度百科怎么做公司网站设计需要多少钱
  • 成都网站设计推荐柚米百度推广服务