Operating system: CentOS release 6.8 (Final)
Web application Server Software:nginx-1.10.1.tar.gz
Combat task: Compile and install Nignx
Download: #wget http://nginx.org/download/nginx-1.10.1.tar.gz
#wgetftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre2-10.20.tar.gz
# tar ZXVF pcre2-10.20.tar.gz
#cd pcre2-10.20
#./configure
# Make && make install
#useradd nginx-s/sbin/nologin-m
# wget http://nginx.org/download/nginx-1.10.1.tar.gz
#tar ZXF nginx-1.10.1.tar.gz
#cd nginx-1.10.1
[email protected] nginx-1.10.1]#./configure--user=nginx \
--group=nginx \
--prefix=/application/nginx-1.10.1\
--with-http_stub_status_module \
--with-http_ssl_module
./configure:error:thehttp Rewrite module requires the PCRE library.
You can either disable the module by Using--without-http_rewrite_module
option, or install the PCRE library intothe system, or build the PCRE library
Statically from the source with Nginx byusing--with-pcre=<path> option.
[Email protected]]# yum-y Install pcre-devel # Fix the above problem:
[[email protected] nginx-1.10.1] #make && make install
[[email protected] nginx-1.10.1] #ln-S/application/nginx-1.10.1/application/nginx
[Email protected] Nginx-1.10.1]#/application/nginx/sbin/nginx-t
Nginx:the configuration File/application/nginx-1.10.1/conf/nginx.confsyntax is ok
Nginx:configuration File/application/nginx-1.10.1/conf/nginx.conftest is successful
[[email protected] nginx-1.10.1] #lsof-I: 80
COMMAND PID USER FD TYPE DEVICE size/off NODE NAME
httpd 1732 Root 4u IPv6 10810 0t0 TCP *:http (LISTEN)
SDSVRD 1899 Root 15u IPv4 8828354 0t0 TCP Bbs.jxatei.net:9965->110.86.5.94:http (established)
httpd 5506 Apache 4u IPv6 10810 0t0 TCP *:http (LISTEN)
httpd 5526 Apache 4u IPv6 10810 0t0 TCP *:http (LISTEN)
httpd 5529 Apache 4u IPv6 10810 0t0 TCP *:http (LISTEN)
httpd 5543 Apache 4u IPv6 10810 0t0 TCP *:http (LISTEN)
httpd 5544 Apache 4u IPv6 10810 0t0 TCP *:http (LISTEN)
httpd 5545 Apache 4u IPv6 10810 0t0 TCP *:http (LISTEN)
httpd 5546 Apache 4u IPv6 10810 0t0 TCP *:http (LISTEN)
httpd 5547 Apache 4u IPv6 10810 0t0 TCP *:http (LISTEN)
httpd 5548 Apache 4u IPv6 10810 0t0 TCP *:http (LISTEN)
httpd 5549 Apache 4u IPv6 10810 0t0 TCP *:http (LISTEN)
httpd 5550 Apache 4u IPv6 10810 0t0 TCP *:http (LISTEN)
httpd 17445 Apache 4u IPv6 10810 0t0 TCP *:http (LISTEN)
httpd 30642 Apache 4u IPv6 10810 0t0 TCP *:http (LISTEN)
httpd 30643 Apache 4u IPv6 10810 0t0 TCP *:http (LISTEN)
httpd 30644 Apache 4u IPv6 10810 0t0 TCP *:http (LISTEN)
httpd 30647 Apache 4u IPv6 10810 0t0 TCP *:http (LISTEN)
httpd 30648 Apache 4u IPv6 10810 0t0 TCP *:http (LISTEN)
httpd 30649 Apache 4u IPv6 10810 0t0 TCP *:http (LISTEN)
httpd 30650 Apache 4u IPv6 10810 0t0 TCP *:http (LISTEN)
httpd 30651 Apache 4u IPv6 10810 0t0 TCP *:http (LISTEN)
[[email protected] nginx-1.10.1] #netstat-lnt|grep 80
TCP 0 0::ffff:127.0.0.1:8005:::* LISTEN
TCP 0 0::: 8009:::* LISTEN
TCP 0 0::: 8080:::* LISTEN
TCP 0 0::: +:::* LISTEN
[[email protected] nginx-1.10.1] #ps-ef|grep nginx
Root 6862 16136 0 09:17 pts/0 00:00:00 grep nginx
# through the above operation check, the description nginx does not work properly, the analysis is due to the Apache causes a port conflict.
[Email protected]]# VI nginx.conf
Listen 80; # Change to listen 9090
[[email protected]]#./nginx-s Reload # lost nginx.pid After restarting Nginx, how to restart Nginx
Nginx: [error]invalid PID Number "" In "/application/nginx-1.10.1/logs/nginx.pid"
[Email protected]]#. /sbin/nginx–c/application/nginx/conf/nginx.conf
[Email protected]]#. /sbin/nginx-s Reload
[[Email protected]]# netstat-lnt|grep 9090
TCP 0 0 0.0.0.0:9090 0.0.0.0:* LISTEN
[Email protected]]# ps-ef|grep Nginx
Root 10400 16136 0 09:24 pts/0 00:00:00./nginx
Root 14560 1 0 09:32? 00:00:00 Nginx:master process. /sbin/nginx-c/application/nginx/conf/nginx.conf
Nginx 14646 14560 0 09:33? 00:00:00 Nginx:worker Process
Nginx 14647 14560 0 09:33? 00:00:00 Nginx:worker Process
Nginx 14648 14560 0 09:33? 00:00:00 Nginx:worker Process
Nginx 14649 14560 0 09:33? 00:00:00 Nginx:worker Process
Nginx 14650 14560 0 09:33? 00:00:00 Nginx:worker Process
Nginx 14651 14560 0 09:33? 00:00:00 Nginx:worker Process
Nginx 14653 14560 0 09:33? 00:00:00 nginx:workerprocess
Nginx 14654 14560 0 09:33? 00:00:00 Nginx:worker Process
Root 15061 16136 0 09:34 pts/0 00:00:00 grep nginx
[[Email protected]]# vi/etc/sysconfig/iptables
-A input-p tcp-m state--state new-m TCP--dport 9090-j ACCEPT #9090端口通过防火强
[[Email protected]]# vi/etc/rc.local
/applicaction/nginx/sbin/nginx # Add the statement at the end to start the service with the system
Summary, the configuration port does not conflict, each restart of the service will also cause Nginx.pid lost, unable to open normally, it is estimated that the main reason is to configure multiple Web services on a single server, including Apache, Tomcat and Nginx, run conflict caused. Finally, the following two statements are placed in the/rc.local file to resolve the nginx.pid problem.
/applicaction/nginx/sbin/nginx
/application/nginx/sbin/nginx–c/application/nginx/conf/nginx.conf
This article is from the "sky9890" blog, make sure to keep this source http://sky9896.blog.51cto.com/2330653/1793531
Compile and install Ngnix on the server