Prashant Gaur
Prashant Gaur

Reputation: 9828

OpenResty : configure lua with already given /etc/nginx/nginx.conf file

I am having a website which is working on nginx already .
nginx conf file is in /etc/nginx.conf folder.
Now i want to integrate lua into that project so i installed Openresty . I created a folder with name "work" as per instruction in doc .And website is working fine at port 8080 as per instructions.
Now i want to use same code into my /etc/nginx/nginx.conf file. like i can use statements like 'content_by_lua ' there . I am not able to configure this . I am getting below error.

Starting nginx: nginx: [emerg] unknown directive "content_by_lua" in /etc/nginx/nginx.conf:25
nginx: configuration file /etc/nginx/nginx.conf test failed

Let me know what i am doing wrong

Upvotes: 3

Views: 4207

Answers (2)

ncarmona
ncarmona

Reputation: 297

I started from the same point. Had nginx, had lua, installed openresty and went from there. I was getting the exact same error. After spending considerable time, trying to make the openresty packages play nice with my nginx installation, I found it easiest to uninstall nginx and move forward just with openresty's nginx. Just make backups of your current nginx.conf and any vhost files.

When installing openresty I was sure to include the --with-luajit option. Set up a "hello, world" test, and everything worked wonderfully. My biggest complaint was not being able to start and stop nginx as a service anymore. The issue is a lack of init.d file in the openresty installation. Luckily I ran across this:

https://groups.google.com/forum/#!topic/openresty-en/7UOz-y77CY4

just change the name to openresty (instead of openresty.init.d) and place in /etc/init.d/ (assumed for Ubuntu). and start/stop/reload as sudo service openresty start

Upvotes: 2

akawhy
akawhy

Reputation: 1608

The error shows that your nginx don't compiled with the right module.

try type nginx -V to see if your nginx configured with nginx_lua_module

Maybe you should find out where the openresty nginx is and use this nginx instead of the default one.

Upvotes: 1

Related Questions