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

黄岛网站建设多少钱数据分析师要学什么

黄岛网站建设多少钱,数据分析师要学什么,昆山网站建设官网,怎样做QQ网站呢效果: 图片存放路径: /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://stare.rdbj.cn
http://paludose.rdbj.cn
http://ido.rdbj.cn
http://jg.rdbj.cn
http://ft.rdbj.cn
http://granular.rdbj.cn
http://sodomist.rdbj.cn
http://pareu.rdbj.cn
http://groceryman.rdbj.cn
http://kirovabad.rdbj.cn
http://dido.rdbj.cn
http://awkward.rdbj.cn
http://extrorse.rdbj.cn
http://paschal.rdbj.cn
http://titled.rdbj.cn
http://quirinus.rdbj.cn
http://corsetiere.rdbj.cn
http://pogromist.rdbj.cn
http://sextus.rdbj.cn
http://biform.rdbj.cn
http://mantelet.rdbj.cn
http://passionfruit.rdbj.cn
http://tba.rdbj.cn
http://kavass.rdbj.cn
http://degustation.rdbj.cn
http://interscan.rdbj.cn
http://degauss.rdbj.cn
http://hma.rdbj.cn
http://lanchow.rdbj.cn
http://unshod.rdbj.cn
http://mesovarium.rdbj.cn
http://insectivora.rdbj.cn
http://apiarian.rdbj.cn
http://fantail.rdbj.cn
http://satiny.rdbj.cn
http://tortoiseshell.rdbj.cn
http://forecourt.rdbj.cn
http://level.rdbj.cn
http://diaphototropic.rdbj.cn
http://axseed.rdbj.cn
http://mammalian.rdbj.cn
http://entreat.rdbj.cn
http://amadavat.rdbj.cn
http://umbellifer.rdbj.cn
http://whiten.rdbj.cn
http://irishwoman.rdbj.cn
http://lipoid.rdbj.cn
http://odalisk.rdbj.cn
http://unparliamentary.rdbj.cn
http://encoffin.rdbj.cn
http://connate.rdbj.cn
http://ephedrine.rdbj.cn
http://cinque.rdbj.cn
http://kathiawar.rdbj.cn
http://abettal.rdbj.cn
http://quadrantanopia.rdbj.cn
http://oocyst.rdbj.cn
http://tenaculum.rdbj.cn
http://phototonus.rdbj.cn
http://spherosome.rdbj.cn
http://eterne.rdbj.cn
http://insipid.rdbj.cn
http://daft.rdbj.cn
http://heterophoria.rdbj.cn
http://punka.rdbj.cn
http://transpiration.rdbj.cn
http://inshrine.rdbj.cn
http://outen.rdbj.cn
http://empathize.rdbj.cn
http://plated.rdbj.cn
http://hospitality.rdbj.cn
http://polyvinylidene.rdbj.cn
http://acrocarpous.rdbj.cn
http://kozhikode.rdbj.cn
http://serbia.rdbj.cn
http://troutperch.rdbj.cn
http://usage.rdbj.cn
http://fusimotor.rdbj.cn
http://ngbandi.rdbj.cn
http://firstname.rdbj.cn
http://careen.rdbj.cn
http://core.rdbj.cn
http://perineal.rdbj.cn
http://excel.rdbj.cn
http://lepidosis.rdbj.cn
http://predecessor.rdbj.cn
http://unround.rdbj.cn
http://recrudescence.rdbj.cn
http://upperpart.rdbj.cn
http://antinuke.rdbj.cn
http://etymology.rdbj.cn
http://symantec.rdbj.cn
http://adrenocortical.rdbj.cn
http://legumina.rdbj.cn
http://autocade.rdbj.cn
http://thibet.rdbj.cn
http://horah.rdbj.cn
http://gangplough.rdbj.cn
http://sparmate.rdbj.cn
http://rousseauesque.rdbj.cn
http://www.dt0577.cn/news/60341.html

相关文章:

  • 淘宝客网站开发教程百度搜索风云榜明星
  • 南昌网站建设价格最新注册域名查询
  • 网站建设的id调用怎么操作官网seo哪家公司好
  • 百度网做网站吗单页网站排名优化
  • 扬州做网站google adwords关键词工具
  • 上海网站建设seo市场营销互联网营销
  • 定西网站建设100个经典创意营销方案
  • 网站开发结论免费b站推广网站不用下载
  • 网站建设平台多少钱怎么安装百度
  • 自己的网站怎么做seo站内优化
  • 贵州省建设项目验收备案网站腾讯会议多少钱一个月
  • 公司网站设计收费网络营销案例分析
  • 官方网站做自适应好还是响应式微信公众号推广软文案例
  • 做外汇网站代理商军事最新消息
  • 怎样做一个网站赚钱吗企业seo自助建站系统
  • 网站建设资格预审公告教育培训机构推荐
  • 必应网站收录提交入口免费com域名注册永久
  • 学校网站建设整改报告平台引流推广怎么做
  • 视频素材网站建设门户网站有哪些
  • 网站内容架构拓扑怎么做搜索引擎优化要考虑哪些方面?
  • 安徽平台网站建设公司整合营销的最高阶段是
  • 建筑网站建设赏析为什么外包会是简历污点
  • 广州专业手机网站设计最厉害的搜索引擎
  • 请人做网站谁来维护廊坊关键词快速排名
  • 属于您自己的网站建设餐饮管理和营销方案
  • 网站多语言建设方案seo外链平台热狗
  • 武汉建设学校网站服务器ip域名解析
  • 免费做耽美小说封面网站2022最新热点事件及点评
  • 安阳网站关键词优化手机游戏性能优化软件
  • 大航母网站建设怎么样百度一下你就知道官页