安装

 
  
  1. [plain] view plaincopyprint?  
  2. # yum install pcre* -y    
  3. # tar xf nginx-1.2.1.tar.gz    
  4. # cd nginx-1.2.1    
  5. # ./configure --with-http_stub_status_module --prefix=/usr/local/nginx --with-http_gzip_static_module    
  6. # make && make install    
  7.  
  8. # yum install pcre* -y  
  9. # tar xf nginx-1.2.1.tar.gz  
  10. # cd nginx-1.2.1  
  11. # ./configure --with-http_stub_status_module --prefix=/usr/local/nginx --with-http_gzip_static_module  
  12. # make && make install  
  13. [plain] view plaincopyprint?  
  14. [root@server ~]# cd /usr/local/nginx/    
  15. [root@server nginx]# ls    
  16. conf html logs sbin    
  17. [root@server nginx]# ./sbin/nginx -V //-V查看编译时候的参数    
  18. nginx version: nginx/1.2.1    
  19. configure arguments: --with-http_stub_status_module --prefix=/usr/local/nginx --with-http_gzip_static_module    
  20. //--with-http_stub_status_module --> 启用NginxStatus,以监控Nginx的当前状态    
  21. //--with-http_gzip_static_module --> 这个模块支持在线实时输出数据压缩    
  22. [root@server nginx]#     
  23.  
  24. [root@server ~]# cd /usr/local/nginx/  
  25. [root@server nginx]# ls  
  26. conf html logs sbin  
  27. [root@server nginx]# ./sbin/nginx -V //-V查看编译时候的参数  
  28. nginx version: nginx/1.2.1  
  29. configure arguments: --with-http_stub_status_module --prefix=/usr/local/nginx --with-http_gzip_static_module  
  30. //--with-http_stub_status_module --> 启用NginxStatus,以监控Nginx的当前状态  
  31. //--with-http_gzip_static_module --> 这个模块支持在线实时输出数据压缩  
  32. [root@server nginx]#   
  33. [plain] view plaincopyprint?  
  34. [root@server nginx]# ./sbin/nginx -t //检测配置文件是否正常    
  35. nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok    
  36. nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful    
  37. [root@server nginx]#  

启动、关闭、重启
启动
 

 
  
  1. [plain] view plaincopyprint?  
  2. [root@server nginx]# ./sbin/nginx    
  3. [root@server nginx]# ps -e | grep nginx    
  4. 7531 ? 00:00:00 nginx    
  5. 7532 ? 00:00:00 nginx 

参考如下命令:
 

关闭

--> kill -XXX pid

 
  
  1. [plain] view plaincopyprint?  
  2. [root@server nginx]# ps -ef | grep "nginx: master process" | grep -v "grep" | awk -F' ' '{print $2}'    
  3. 7531    
  4. [root@server nginx]# cat /usr/local/nginx/logs/nginx.pid    
  5. 7531    
  6. [root@server nginx]# 

使用kill即可
重启

 
  
  1. [plain] view plaincopyprint?  
  2. [root@server nginx]# kill -HUP `cat /usr/local/nginx/logs/nginx.pid ` 

Nginx相关

Nginx安装配置:点击打开链接

Nginx虚拟主机配置:点击打开链接