飞牛os在笔记本合盖不休眠设置

1.sudo nano /etc/systemd/logind.conf
2.找到以下内容:

HandleLidSwitch=suspend

复制
将其修改为:

HandleLidSwitch=ignore
复制
注意:需要去掉前面的 # 注释符号。
3.步骤 重启服务

执行以下命令以重启相关服务,使更改生效:

sudo systemctl restart systemd-logind.service
复制
验证设置

合上笔记本盖子,检查是否保持正常运行(屏幕可能会关闭,但系统不会休眠)。

如果未生效,请确保配置文件中没有其他冲突设置,并重新检查修改是否正确。

Luaossl 编译支持 openssl1.1.1版本

根据这个issue
当系统内openssl版本是1.1.1或更低版本时,编译Luaossl,需要将这个参数打开

位置:src/openssl.c
#define EVP_KDF_HKDF_MODE_EXTRACT_AND_EXPAND 1
然后
 make all5.1 includedir=/usr/local/openresty/luajit/include/luajit-2.1/

nginx1.28 添加lua支持

一、软件版本
操作系统 almalinux9.

  1. nginx-1.28.0
  2. lua-cjson-2.1.0.9
  3. headers-more-nginx
  4. luajit2-2.1-20250117
  5. lua-resty-core-0.1.31
  6. lua-resty-lrucache-0.15
  7. lua-nginx-module-0.10.28
  8. nginx_sticky_module_ng-0.0.2
  9. ngx_devel_kit-0.3.3
  10. ngx_healthcheck_module
  11. openssl-3.5.0
  12. pcre-8.42
  13. zlib 1.3.1
    libxml2 libxslt 采用系统自带版本使用yum install libxslt-devel libxml2-devel 安装。
    系统需要有 gcc gcc-c++编译器。
    系统需要安装的依赖:
    yum install perl-FindBinperl-IPC-Cmd perl-ExtUtils-MM-Utils perl-I18N-LangTags,perl-Locale-Maketext perl-Locale-Maketext-Simple perl-Module-CoreList perl-Module-Load perl-Module-Load-Conditional perl-Module-Metadata perl-Params-Check perl-Time-HiRes perl-locale perl-version perl-File-Compare perl-File-Copy

二、过程

  1. 安装 luajit2
cd luajit2-2.1-20250117/
make
make install
export LUAJIT_LIB=/usr/local/lib/
export LUAJIT_INC=/usr/local/include/luajit-2.1/
  1. 安装lua-resty-core 和 lua-resty-lrucache
cd lua-resty-core-0.1.31/
make install
cd lua-resty-lrucache-0.15/
make install
  1. 安装lua-cjson
cd lua-cjson-2.1.0.9/
make会报错
cc -c -O3 -Wall -pedantic -DNDEBUG -g  -I/usr/local/include -fpic -o lua_cjson.o lua_cjson.c

lua_cjson.c:44:10: fatal error: lua.h: No such file or directory
44 | #include <lua.h>

  |          ^~~~~~~

需要指定include路径
直接使用

 cc -c -O3 -Wall -pedantic -DNDEBUG -g  -I/usr/local/include/luajit-2.1 -fpic -o lua_cjson.o lua_cjson.c

编译成功后
执行 make install

  1. 安装nginx1.28,默认安装路径 /usr/local/nginx

    cd nginx-1.28.0

./configure --user=www --group=www --with-stream_realip_module --with-http_mp4_module --with-http_ssl_module --with-http_xslt_module --with-stream --with-http_sub_module --with-threads --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_v3_module --with-http_mp4_module --with-http_secure_link_module --add-module=../ngx_devel_kit-0.3.3/ --add-module=../lua-nginx-module-0.10.28/ --with-http_realip_module --with-openssl=../openssl-3.5.0 --add-module=../ngx_healthcheck_module/ --add-module=../headers-more-nginx-module --with-pcre=../pcre-8.42 --add-module=../nginx_sticky_module_ng-0.0.2/

make

`make install`
  1. 配置nginx
    修改/usr/local/nginx/conf/nginx.conf
    2025-06-18T08:31:04.png2025-06-18T08:31:04.png

    在http段落添加 lua_package_path "/usr/local/lib/lua/?.lua;;";
    运行 /usr/local/nginx/sbin/nginx -t测试
    如不报错,即可运行
    /usr/local/nginx/sbin/nginx

linux 调整时区以及时间显示为24小时制

一、 指令:timedatectl

   用法:
  1. 列出所有时区 timedatectl list-timezones
  2. 调整到所需时区 timedatectl set-timezone "Asia/Shanghai"

二、 也可以暴力方法: (未验证,想来可行)

  1. 指令: sudo rm /etc/localtime
  2. 指令: sudo ln -s /usr/share/zoneinfo/Region/City /etc/localtime

三、显示时间为24小时制

  1. 指令:sudo timedatectl set-24hour true

nginx lua log request and response

使用lua模块可以进行request和reponse的记录。
以下摘自:serverfault.com
worker_processes 1;
error_log logs/error.log;
events {

worker_connections 1024;

}
http {

log_format log_req_resp '$remote_addr - $remote_user [$time_local] '
    '"$request" $status $body_bytes_sent '
    '"$http_referer" "$http_user_agent" $request_time req_body:"$request_body" resp_body:"$resp_body"';

server {
    listen 8082;
    access_log logs/access.log log_req_resp;

    lua_need_request_body on;

    set $resp_body "";
    body_filter_by_lua '
        local resp_body = string.sub(ngx.arg[1], 1, 1000)
        ngx.ctx.buffered = (ngx.ctx.buffered or "") .. resp_body
        if ngx.arg[2] then
            ngx.var.resp_body = ngx.ctx.buffered
        end
    ';

    location / {
        echo "Hello World!";
    }
}

}