RHEL/Centos7.x Build Nginx1.12.2 and test,rhelcentos7.x


Official version check 

yum install/Centos nginx/1.12.2 


[lake@LongchangHost git]$ nginx -v 
nginx version: nginx/1.12.2
[lake@LongchangHost git]$ nginx -V
nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --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_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-google_perftools_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'
[lake@LongchangHost git]$ 






1. Openssl 


[root@localhost Packages]# ls  |grep ssl 
docbook-style-dsssl-1.79-18.el7.noarch.rpm
mod_ssl-2.4.6-40.el7.x86_64.rpm
nss_compat_ossl-0.9.6-8.el7.i686.rpm
nss_compat_ossl-0.9.6-8.el7.x86_64.rpm
openssl098e-0.9.8e-29.el7_0.2.i686.rpm
openssl098e-0.9.8e-29.el7_0.2.x86_64.rpm
openssl-1.0.1e-42.el7_1.9.x86_64.rpm
openssl-devel-1.0.1e-42.el7_1.9.i686.rpm
openssl-devel-1.0.1e-42.el7_1.9.x86_64.rpm
openssl-libs-1.0.1e-42.el7_1.9.i686.rpm
openssl-libs-1.0.1e-42.el7_1.9.x86_64.rpm
python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch.rpm
qca-ossl-2.0.0-0.19.beta3.el7.i686.rpm
qca-ossl-2.0.0-0.19.beta3.el7.x86_64.rpm
xmlsec1-openssl-1.2.20-5.el7.i686.rpm
xmlsec1-openssl-1.2.20-5.el7.x86_64.rpm
[root@localhost Packages]# rpm  -ivh    openssl-devel-1.0.1e-42.el7_1.9.x86_64.rpm  
warning: openssl-devel-1.0.1e-42.el7_1.9.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                          ################################# [100%]
package openssl-devel-1:1.0.1e-42.el7_1.9.x86_64 is already installed
[root@localhost Packages]# 




2.  Configurate with http_ssl 


lake@localhost:~/Cloud/nginx/nginx-1.12.2$ ./configure   --prefix=/usr   --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module   


creating objs/Makefile


Configuration summary
  + using system PCRE library
  + using system OpenSSL library
  + using system zlib library


  nginx path prefix: "/usr"
  nginx binary file: "/usr/sbin/nginx"
  nginx modules path: "/usr/modules"
  nginx configuration prefix: "/usr/conf"
  nginx configuration file: "/usr/conf/nginx.conf"
  nginx pid file: "/usr/logs/nginx.pid"
  nginx error log file: "/usr/logs/error.log"
  nginx http access log file: "/usr/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"




lake@localhost:~/Cloud/nginx/nginx-1.12.2$ make -j32 
.............
.....
objs/ngx_modules.o \
-ldl -lpthread -lcrypt -lpcre -lssl -lcrypto -ldl -lz \
-Wl,-E
make[1]: Leaving directory `/home/lake/Cloud/nginx/nginx-1.12.2'
lake@localhost:~/Cloud/nginx/nginx-1.12.2$ ./objs/nginx -V
nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC) 
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module
lake@localhost:~/Cloud/nginx/nginx-1.12.2$ 


lake@localhost:~/Cloud/nginx/nginx-1.12.2$ which nginx 
/usr/sbin/nginx
lake@localhost:~/Cloud/nginx/nginx-1.12.2$ /usr/sbin/nginx  -V
nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC) 
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module
lake@localhost:~/Cloud/nginx/nginx-1.12.2$ 


3.  Start nginx web server 
## Stop apache web server 
[root@localhost Packages]#  systemctl  stop    httpd.service  
[root@localhost Packages]# 


lake@localhost:~/Cloud/nginx/nginx-1.12.2$ sudo /usr/sbin/nginx 
lake@localhost:~/Cloud/nginx/nginx-1.12.2$ 


Browser visits http://localhost


#default conf 
/usr/conf/nginx.conf


#default log  /usr/logs
lake@localhost:~/Cloud/nginx/nginx-1.12.2$ ls -l /usr/logs
total 12
-rw-r--r-- 1 root root 451 Mar 20 05:21 access.log
-rw-r--r-- 1 root root 938 Mar 20 05:21 error.log
-rw-r--r-- 1 root root   6 Mar 20 05:21 nginx.pid
lake@localhost:~/Cloud/nginx/nginx-1.12.2$ 


############# Stop nginx web server   
nginx -s signal
Where signal may be one of the following:


1) stop — fast shutdown
2) quit — graceful shutdown
3) reload — reloading the configuration file
4) reopen — reopening the log files
Now for example, stopping the server:


nginx -s stop


lake@localhost:~/Cloud/nginx/nginx-1.12.2$ nginx  -s  stop  
nginx: [alert] could not open error log file: open() "/usr/logs/error.log" failed (13: Permission denied)
2018/03/21 01:29:24 [notice] 14630#0: signal process started
2018/03/21 01:29:24 [alert] 14630#0: kill(31698, 15) failed (1: Operation not permitted)
lake@localhost:~/Cloud/nginx/nginx-1.12.2$ sudo  nginx  -s  stop  
[sudo] password for lake: 
lake@localhost:~/Cloud/nginx/nginx-1.12.2$ 
lake@localhost:~/Cloud/nginx/nginx-1.12.2$ tail  -n 1  /usr/logs/error.log   
2018/03/21 01:29:33 [notice] 14634#0: signal process started
lake@localhost:~/Cloud/nginx/nginx-1.12.2$ date
Wed Mar 21 01:29:53 EDT 2018 

相关内容

    暂无相关文章