Tag Archives: Nginx Error

Nginx Error: nginx: [emerg] the “ssl“ parameter requires ngx_http_ssl_module in /project/api/nginx.conf:

Error reporting reason:

NGX is not installed_http_ssl_Module module

Solution:

    1. check which modules are installed in Nginx
/usr/local/ngxin/sbin/nginx -V

nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
configure arguments:

No parameters after configure arguments indicates that no modules are installed
install NGX_http_ssl_Module the module is in the installation directory ofngxin, note the installation directory, find configure and execute:

./configure --prefix=/usr/local/nginx 
./configure --with-http_ssl_module

After installation, execute make and make install

make
...
make install

Back up the original nginx, and overwrite the compiled nginx with the original nginx

cp /usr/local/nginx/sbin/nginx  /usr/local/nginx/sbin/nginx.bak
cp ./objs/nginx /usr/local/nginx/sbin/

Check whether the installation is successful

/usr/local/nginx/sbin/nginx -V

nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --with-http_ssl_module

[UNK] enable nginx

/usr/local/nginx/sbin/nginx -s reload

Nginx error: nginx: [error] invalid PID number ““ in “/run/nginx.pid“

Error: after modifying the configuration file, reload it, and then report an error. nginx: [error] invalid PID number “” in “/usr/local/var/run/nginx.pid”

Solution restart nginx

nginx -c /usr/local/etc/nginx/nginx.conf
nginx -s reload

View port occupancy

lsof -i:8080

Delete port 8080 process

kill -9:834

To install nginx on MAC, use nginx - V to view the installation path

configure arguments: --prefix=/usr/local/Cellar/nginx/1.19.6 --sbin-path=/usr/local/Cellar/nginx/1.19.6/bin/nginx    --conf-path=/usr/local/etc/nginx/nginx.conf

-- prefix =/usr/local/cellular/nginx/1.19.6 represents the installation path -- SBIN path represents the executable path -- conf path represents the configuration file path

Nginx Error: [emerg] bind() to [::]:80 failed (98: Address already in use)

Problem description

When starting the nginx service, the following error occurred:

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
...

Cause of the problem

There are many reasons for this problem. We will list our scenarios and solutions here.

First, the port is occupied

This is the most common reason. Port 80 is occupied, which leads to binding of nginx service.

Solution 1

Find the process occupying port 80 and end it.

Second, dual stack sockets for IPv6

This is a common problem in the transition period from IPv4 to IPv6. The following configuration will also cause the above error:

server {
    listen [::]:80 ipv6only=off;        
    server_name dual-stack.example.com;
}
server {
    listen 0.0.0.0:80;
    server_name ipv4.example.com;
}

With the IPv6 only = off option, the currently created socket is dual stack, and IPv4 will be mapped to IPv6. At this time, only one monitor can be created, and IPv4 can no longer be monitored.

Solution 2

Since we can’t monitor IPv4, and now it’s a dual stack, we can monitor IPv6 address safely (and ensure IPv4 access at the same time)

server {
    listen [::]:80 ipv6only=off;        
    server_name dual-stack.example.com;
}
server {
    listen [::]:80;
    server_name ipv4.example.com;
}
# Because of the specific scenario, we cannot modify the configuration of the first Server
# Of course, it is also possible to turn off the double stack.