nginx module with json-c undefined symbol: json_object_to_json_string - nginx

for install nginx with hello module(this module use #include )
i use yum -y install json-c json-c-devel before install nginx
make && make install is successful. but when i run nginx test
/usr/sbin/nginx -t
error message is show up :
nginx: [emerg] dlopen() "/etc/nginx/modules/ngx_http_hello_module.so" failed (/etc/nginx/modules/ngx_http_hello_module.so: undefined symbol: json_object_to_json_string) in /etc/nginx/nginx.conf:5
nginx: configuration file /etc/nginx/nginx.conf test failed
ldd /usr/sbin/nginx
json-c library is not loadded! what can i do?

solve this problem ;)
method is : ./configure ... --with-ld-opt="-ljson"
after success install(make && make install), type ldd /usr/sbin/ngin then you will show loaded library file(.so)

Related

No nginx folders after installing on Amazon Linux 2 EC2 instance

I'm trying to install Nginx on an EC2 instance running Amazon Linux 2. After running the commands as listed here on: https://stackoverflow.com/a/61256478/11309912.
Checking the version shows that is installed.
nginx -v
nginx version: nginx/1.22.0
But either under /etc or /local there is no nginx folder being created.
nginx -t does run but fails:
nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
2022/11/13 13:33:46 [emerg] 16016#16016: open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)
nginx: configuration file /etc/nginx/nginx.conf test failed
I tried running sudo yum remove nginx and sudo yum install nginx/sudo amazon-linux-extras install -y nginx1 but both to no avail.
Is there a way to (re)install nginx that places these folders and configs?

add Nginx 1.20.1 GeoIP2 module

I'm trying to configure nginx to build the GeoIP2 module, by following this installation:
https://github.com/leev/ngx_http_geoip2_module
first I still didn't understand what is defrences between static and dynamic modules,
and why can't I just apt install that module..
The problemm is that I want to build/create it on a diffrent machine, so I had to copy the configure flags from the destination machine by copy the output of this command:
nginx -V
and then I ran this command on the test machine:
PKG_CONFIG_PATH="/usr/lib/x86_64-linux-gnu/pkgconfig/" ./configure --without-http_rewrite_module --without-http_gzip_module --add-module=/path/ngx_http_geoip2_module-3.3 (PASTE DESTINATION NGINX -V OUTPUT)
make
make install
Then after succession I copied the file name: ngx_http_geoip2_module.so to destination machine
and ran nginx -t
I got this error:
nginx: [emerg] module "/etc/nginx/modules/ngx_http_geoip2_module.so" is not binary compatible in /etc/nginx/nginx.conf
nginx: configuration file /etc/nginx/nginx.conf test failed
My destination machine:
Ubuntu 20
Nginx 1.20.1
--with-compat --add-module=/path/to/ngx_http_geoip2_module
or
--with-compat --add-dynamic-module=/path/to/ngx_http_geoip2_module

undefined symbol: lua_rotate

I had done below steps,
downloaded lua-cjson-2.1.0.7 from this repo, Not really know what went wrong. can anybody know whats going on and how to resolve this?
make install
mkdir -p /usr/local/lib/lua/5.1
rm -f /usr/local/lib/lua/5.1/cjson.so
cp cjson.so /usr/local/lib/lua/5.1
chmod 755 /usr/local/lib/lua/5.1/cjson.so
Then,
sudo systemctl restart nginx.service
Error:
2020/02/19 06:59:52 [error] 29524#29524: *1 lua entry thread aborted: runtime error: error loading module 'cjson' from file '/usr/local/lib/lua/5.1/cjson.so':
/usr/local/lib/lua/5.1/cjson.so: undefined symbol: lua_rotate
stack traceback:
coroutine 0:
[C]: in function 'require'
nginx.conf has below :
lua_package_path "/usr/local/lib/lua/?.lua;;";
And
/usr/bin/lua
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio

Command failed when running ghost start

Fresh install, trying to run ghost start I get the following error:
Debug Information:
OS: Raspbian, v8.0
Node Version: v6.13.0
Ghost-CLI Version: 1.5.2
Environment: production
Command: 'ghost start'
An error occurred.
Message: 'Command failed: /bin/sh -c systemctl is-active ghost_blog-dev
unknown
'
Stack: Error: Command failed: /bin/sh -c systemctl is-active ghost_blog-dev
unknown
at makeError (/usr/lib/node_modules/ghost-cli/node_modules/execa/index.js:169:9)
at module.exports.sync (/usr/lib/node_modules/ghost-cli/node_modules/execa/index.js:338:15)
at handleShell (/usr/lib/node_modules/ghost-cli/node_modules/execa/index.js:116:9)
at Function.module.exports.shellSync (/usr/lib/node_modules/ghost-cli/node_modules/execa/index.js:361:43)
at SystemdProcessManager.isRunning (/usr/lib/node_modules/ghost-cli/extensions/systemd/systemd.js:88:19)
at Instance.running (/usr/lib/node_modules/ghost-cli/lib/instance.js:120:34)
at StartCommand.run (/usr/lib/node_modules/ghost-cli/lib/commands/start.js:28:22)
at precheck.then (/usr/lib/node_modules/ghost-cli/lib/command.js:159:52)
at process._tickCallback (internal/process/next_tick.js:109:7)
at Module.runMain (module.js:613:11)
at run (bootstrap_node.js:387:7)
at startup (bootstrap_node.js:153:9)
at bootstrap_node.js:500:3
Code: 3
If I manually run the command that is says failed it seems to execute without error though I am not sure what it does. I assume it has something to do with checking with nginx if ghost has actually started or not.
Any suggestions would be very helpful! Thank you!
I faced with the same problem. You should add your service file to etc directory also as symbolic link using the following command:
sudo ln -sf /var/www/html/your-blog/system/files/ghost_blog-yourblog.service /etc/systemd/system/ghost_blog-yourblog.service
After adding this, you should execute the following commands:
sudo systemctl stop ghost_blog-yourblog.service
sudo systemctl start ghost_blog-yourblog.service
Then, I hope you'll see 'active' result for is-active command.

"configuration file /etc/nginx/nginx.conf test failed": How do I know why this happened?

I'm an nginx noob trying out this this tutorial on nginx 1.1.19 on ubuntu 12.04. I have this nginx config file.
When I run this command the test fails:
$ sudo service nginx restart
Restarting nginx: nginx: [crit] pread() "/etc/nginx/sites-enabled/csv" failed (21: Is a directory)
nginx: configuration file /etc/nginx/nginx.conf test failed
How do I know why the nginx.conf test failed?
sudo nginx -t should test all files and return errors and warnings locations
This particular commands worked for me.
sudo apt-get remove --purge nginx nginx-full nginx-common
and
sudo apt-get install nginx
credit to this answer on stackexchnage
The first solution is to test nginx conf using the basic
sudo nginx -t
Secondly, if you've changed the file yourself, copy/pasted json from one to another, there's a high chance that there's an encoding issue.
For example: " is not the same as
``
Try to write configurations by yourself. Check commas, colon and braces. Don't forget to reload the nginx.
sudo systemctl reload nginx
If you want to check syntax error for any nginx files, you can use the -c option.
[root#server ~]# sudo nginx -t -c /etc/nginx/my-server.conf
nginx: the configuration file /etc/nginx/my-server.conf syntax is ok
nginx: configuration file /etc/nginx/my-server.conf test is successful
[root#server ~]#
Show file and track error
systemctl status nginx.service

Resources