linux下nginx稳定版1.6.2安装

nginx安装
准备工作:
1)pcre安装,支持正则表达式  
http://www.pcre.org/  
  
# tar zxvf pcre-8.34.tar.gz  
  
# cd pcre-8.34  
  
#./configure  
  
# make && make install   

2)openssl安装(可选),支持安全协议的站点  
  
http://www.openssl.org/  
  
# tar zxvf openssl-1.0.1j.tar.gz  
  
# cd openssl-1.0.1j  
  
#./config  
  
# make && make install   


3)nginx的安装  
  
# tar zxvf nginx-1.6.2.tar.gz  
  
# cd nginx-1.6.2

# ./configure  
  
# make && make install  

安装完后 默认路径在/usr/local/nginx

备注:也可以指定参数配置  指定安装路径等 示例如下:
(# ./configure --prefix=/usr/local/nginx/nginx8011 --with-openssl=/usr/include/openssl --with-http_stub_status_module  )

查看版本信息:

/usr/local/nginx/sbin/nginx -v
>/usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

解决办法:

     如果是32位系统

    [root@lee ~]#  ln -s /usr/local/lib/libpcre.so.1 /lib

    如果是64位系统

    [root@lee ~]#  ln -s /usr/local/lib/libpcre.so.1 /lib64

    然后在启动nginx就OK了

    [root@lee ~]# /usr/local/webserver/nginx/sbin/nginx -v
        >nginx version: nginx/1.6.2
    OK  问题解决
    备注:启动默认使用配置文件:/usr/local/nginx/conf/nginx.conf
    


------------------------------------------------------------------------
nginx启动、停止、平滑重启操作,以下操作均以默认安装路径/usr/local/nginx 为例
启动:
>/usr/local/nginx/sbin/nginx
访问路径,看到欢迎页面表示启动成功

停止:
查看nginx进程看
方式1:ps -ef | grep nginx
[root@iZ94wmbxqzyZ logs]# ps -ef |grep nginx
root      2314     1  0 15:09 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody    2315  2314  0 15:09 ?        00:00:00 nginx: worker process      
root      2444  2263  0 15:18 pts/1    00:00:00 grep nginx

方式二:

[root@iZ94wmbxqzyZ logs]# cat /usr/local/nginx/logs/nginx.pid 
2314
说明:nginx默认的进程号存储在logs下的nginx.pid

停止操作的集中方式:
停止操作是通过向nginx进程发送信号(什么是信号请参阅linux文 章)来进行的
步骤1:查询nginx主进程号
ps -ef | grep nginx
在进程列表里 面找master进程,它的编号就是主进程号了。
步骤2:发送信号
从容停止Nginx:
kill -QUIT 主进程号
快速停止Nginx:
kill -TERM 主进程号
强制停止Nginx:
pkill -9 nginx

nginx这里有点特殊,不要用kill -9 强制杀死进程,因为nginx有很多子进程,建议用kill 进程号 也是正常的关闭进程的方式

另外可以用
kill '/usr/local/nginx/logs/nginx.pid'方式停止进程

[root@iZ94wmbxqzyZ nginx]# ps -ef |grep nginx
root      2729     1  0 16:00 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody    2730  2729  0 16:00 ?        00:00:00 nginx: worker process      
root      2732  2263  0 16:00 pts/1    00:00:00 grep nginx
[root@iZ94wmbxqzyZ nginx]# kill -HUP 2729
[root@iZ94wmbxqzyZ nginx]# 
[root@iZ94wmbxqzyZ nginx]# 
[root@iZ94wmbxqzyZ nginx]# ps -ef |grep nginx
root      2729     1  0 16:00 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody    2733  2729  0 16:02 ?        00:00:00 nginx: worker process      
root      2735  2263  0 16:02 pts/1    00:00:00 grep nginx
[root@iZ94wmbxqzyZ nginx]# 
[root@iZ94wmbxqzyZ nginx]# 
[root@iZ94wmbxqzyZ nginx]# /usr/local/nginx/sbin/nginx -s reload
[root@iZ94wmbxqzyZ nginx]# 
[root@iZ94wmbxqzyZ nginx]# 

 注意,修改了配置文件后最好先检查一下修改过的配置文件是否正 确,以免重启后Nginx出现错误影响服务器稳定运行。判断Nginx配置是否正确命令如下:
nginx -t -c /usr/local/nginx/conf/nginx.conf

或者
/usr/nginx/sbin/nginx -t

[root@iZ94wmbxqzyZ nginx]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@iZ94wmbxqzyZ nginx]# 
[root@iZ94wmbxqzyZ nginx]# 


猜你喜欢

转载自wuzhaohuixy-qq-com.iteye.com/blog/2163589