linux下nginx稳定版1.6.2安装

[code="java"]
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位系统

# ln -s /usr/local/lib/libpcre.so.1 /lib

如果是64位系统

# ln -s /usr/local/lib/libpcre.so.1 /lib64

然后在启动nginx就OK了

# /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
# 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

方式二:

# 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'方式停止进程

# 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
# kill -HUP 2729
#
#
# 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
#
#
# /usr/local/nginx/sbin/nginx -s reload
#
#

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

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

# /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
#
#


[/code]
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值