LINUX

[CentOS7] yum installs Nginx to add third-party modules echo-nginx-module

Remoted remoted 2021. 8. 13. 11:56

Hahaha, jump directly to nginx this, the tomcat learned before, and tomcat+nginx have not said, I installed nginx, in the use of variables in the nginx configuration file, see the use of the echo command Variable output, I also wrote in my configuration file, a test, and then gave an error, a check to know that this command is a third-party module, and then began to go to Baidu how to add third-party modules, this problem is also I got I took a lot of blogs to solve it one day, and I quickly recorded it.

Tip: All operations are inrootCompleted by the user.

The first step is to download echo-nginx-module.

download link:https://github.com/openresty/echo-nginx-module/releases

In the second step, enter the command nginx -V to view the nginx version information installed by yum, and output the corresponding version number and compilation information.

Then download the tar.gz tarball for the corresponding version of nginx

download link:http://nginx.org/en/download.html

The third step is to pass the downloaded nginx and echo-nginx-module modules.Tool uploadGo to the virtual machine, then cp to /usr/local/src directory, extract

After decompression is completed, enter the decompression directory of nginx.

Before proceeding to the next step, it is best to back up your /usr/sbin/nginx

The fourth step, configuration parameters

Enter the command: ./configure --prefix=/usr/local/nginx --add-module=/usr/local/src/echo-nginx-module-0.61Then add configuration parameters later

Is the nginx -V outputconfigure argumentsAfter the addition, add to the back, the final command is as follows:

./configure --prefix=/usr/local/nginx --add-module=/usr/local/src/echo-nginx-module-0.61 --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_auth_request_module --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E'

The red is to be changed, this is the data on my virtual machine, the following is the error resolution, you can install the following error database before configuring the parameters, of course, if you want to solve the problem one by one until the installation Success, of course, is fine.

Error resolution

1, missing libxml2/libxslt:

  1.  
  2. ./configure: error: the HTTP XSLT module requires the libxml2/libxslt
  3.  
  4. libraries. You can either do not enable the module or install the libraries.
  5.  
  6.  
  7.  
  8. solution:
  9.  
  10. yum -y install libxml2 libxml2-dev
  11.  
  12. yum -y install libxslt-devel

2, the lack of gd-devel

  1.  
  2. ./configure: error: the HTTP image filter module requires the GD library.
  3.  
  4. You can either do not enable the module or install the libraries.
  5.  
  6.  
  7.  
  8. solution:
  9.  
  10. yum -y install gd-devel

3, the lack of ExtUtils

  1.  
  2. ./configure: error: perl module ExtUtils::Embed is required
  3.  
  4.  
  5.  
  6. solution:
  7.  
  8. yum -y install perl-devel perl-ExtUtils-Embed

4, lack of GeoIP

  1.  
  2. ./configure: error: the GeoIP module requires the GeoIP library.
  3.  
  4. You can either do not enable the module or install the library.
  5.  
  6.  
  7.  
  8. solution:
  9.  
  10. yum -y install GeoIP GeoIP-devel GeoIP-data

5, the lack of Google perftools

  1.  
  2. ./configure: error: the Google perftools module requires the Google perftools
  3.  
  4. library. You can either do not enable the module or install the library.
  5.  
  6.  
  7.  
  8. The translation is: Google perftools module needs Google perftools library, you can choose not to start or install the library
  9.  
  10. I will not enable it here, remove the --with-google_perftools_module from the parameters.

Fifth, compile

Enter: make -j2

After compiling, an nginx file will be generated in the unz directory of the nginx decompression directory. Test this file first, enter objs/nginx -t, and see the result.

The display is successful, then use this file instead of /usr/sbin/nginx this file, and then test it, it is still successful, hahaha, basically got it.

Then start nginx, if the following situation occurs, the nginx service process may be stuck, causing port 80 to be occupied.

  1.  
  2. nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
  3.  
  4. nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
  5.  
  6. nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
  7.  
  8. nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
  9.  
  10. nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
  11.  
  12. nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
  13.  
  14. nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
  15.  
  16. nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
  17.  
  18. nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
  19.  
  20. nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
  21.  
  22. nginx: [emerg] still could not bind()

Solved:

Nginx -s stop or

First check the process information: ps -aux | grep nginx and then kill the process kill process number, then restart nginx.

At this point, this third-party module is ready.

 

 

 

https://www.programmersought.com/article/8968116526/