Nginx Openresty内容按文件
我正在尝试在OpenResty中创建基本的hello word页面。如果我使用content_by_lua,它可以正常工作,但是当我尝试使用content_by_lua_文件时,我遇到以下错误:Nginx Openresty内容按文件,nginx,lua,openresty,Nginx,Lua,Openresty,我正在尝试在OpenResty中创建基本的hello word页面。如果我使用content_by_lua,它可以正常工作,但是当我尝试使用content_by_lua_文件时,我遇到以下错误: 2015/01/22 13:52:35 [alert] 2183#0: lua_code_cache is off; this will hurt performance in /Users/lobster/documents/web_server/conf/nginx.conf:10 2015/01/
2015/01/22 13:52:35 [alert] 2183#0: lua_code_cache is off; this will hurt performance in /Users/lobster/documents/web_server/conf/nginx.conf:10
2015/01/22 13:52:38 [error] 2223#0: *4 failed to load external Lua file "/Users/lobster/documents/web_server/./lua/main.lua": cannot open /Users/lobster/documents/web_server/./lua/main.lua: Permission denied, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", host: "localhost:8080"
但它没有意义,因为我可以轻松地更改/Users/lobster/documents/web_server/lua/main.lua文件。这是我的配置:
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
lua_package_path '/lua/main.lua;';
server {
lua_code_cache off;
listen 8080;
location / {
default_type 'text/plain';
content_by_lua_file ./lua/main.lua;
}
}
}
我从根目录启动nginx,这样nginx就可以访问我计算机上的任何文件。我做错了什么
UPD:
我使用content\u by\u lua修复了它,其中包含require我也遇到了这个问题,我通过添加以下内容解决了它:
user root root;
在我的nginx.conf
中,因为我的lua脚本文件的用户和组是root
您还可以更改lua脚本文件的所有者。我也遇到了这个问题,我通过添加以下内容解决了这个问题:
user root root;
在我的nginx.conf
中,因为我的lua脚本文件的用户和组是root
您还可以更改lua脚本文件的所有者。nginx通常有两个进程,一个是主进程,另一个是工作进程。主进程由
root
用户运行,工作进程由nobody
用户运行,因此您应该确保nobody
用户可以读取/Users/lobster/documents/web\u server//lua/main.lua
文件
顺便说一句:
rensike添加
用户根目录
在nginx.conf中,工作进程将由root用户运行,因此他用另一种方式解决了您的问题。nginx通常有两个进程,一个是主进程,另一个是工作进程。主进程由root
用户运行,工作进程由nobody
用户运行,因此您应该确保nobody
用户可以读取/Users/lobster/documents/web\u server//lua/main.lua
文件
顺便说一句:
rensike添加
用户根目录
在nginx.conf中,工作进程将由root用户运行,因此他用另一种方式解决了您的问题。错误消息是否足够明确?它说它没有权限打开/读取有问题的文件。修复文件的权限。请注意,以root身份登录时启动Nginx与以root.Tye绝对路径运行的Nginx不同。错误消息是否足够明确?它说它没有权限打开/读取有问题的文件。修复文件的权限。请注意,以root身份登录时启动Nginx与以root.Tye绝对路径运行Nginx不同?