1   下载nginx

从nginx官网 http://nginx.org/ 下载新的稳定版本nginx 并上传到linux服务器

 2  安装nginx 所需要的扩展

            yum -y install pcre openssl  openssl-devel

3  安装nginx

                useradd -s /sbin/nologin www
tar zxvf nginx-1.8.0.tar.gz
cd nginx-1.8.0
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --without-http-cache --with-http_ssl_module  --with-pcre=/home/www/pcre-8.31 (源文件的解压路径不是安装路径) --with-http_gzip_static_module
make
make install

配置nginx开机启动文件

vi  /etc/init.d/nginx 写入如下内容 根据实际情况修改

#!/bin/sh
#
# nginx - this script start and stop the nginx daemon
#
# chkconfig: 2345 55 25
# description: Startup script for nginx
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /var/run/nginx.pid
#
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/local/nginx/sbin/nginx
CONFIGFILE=/usr/local/nginx/conf/nginx.conf
PIDFILE=/var/run/nginx.pid
SCRIPTNAME=/etc/init.d/nginx
LOCKFILE=/var/lock/nginx.lock set -e
[[ -x "$DAEMON" ]] || exit 0 start() {
echo "Startting Nginx......"
[[ -x $DAEMON ]] || exit 5
[[ -f $CONFIGFILE ]] || exit 6
$DAEMON -c $CONFIGFILE || echo -n "Nginx already running!"
[[ $? -eq 0 ]] && touch $LOCKFILE
} stop() {
echo "Stopping Nginx......"
MPID=`ps aux | grep nginx | awk '/master/{print $2}'` if [[ "${MPID}X" != "X" ]]; then
kill -QUIT $MPID
[[ $? -eq 0 ]] && rm -f $LOCKFILE
else
echo "Nginx server is not running!"
fi
} reload() {
echo "Reloading Nginx......"
MPID=`ps aux | grep nginx | awk '/master/{print $2}'` if [[ "${MPID}X" != "X" ]]; then
kill -HUP $MPID
else
echo "Nginx can't reload!"
fi
} case "$1" in
start)
start
;; stop)
stop
;; reload)
reload
;; restart)
stop
sleep 1
start
;; *)
echo "Usage: $SCRIPTNAME {start|stop|reload|restart}"
exit 3
;;
esac exit 0

4 设置开机启动

              chmod 755 /etc/init.d/nginx
chkconfig --add nginx
chkconfig nginx on
/etc/init.d/nginx start

5 测试

用浏览器访问实际的域名 看看是否正常

重启服务器 看nginx 是否随机启动

6 配置相关

######## 查看nginx状态配置
location =/nginx_status {
stub_status on;
access_log off;
#allow 127.0.0.1;
#deny all;
}

active connections – 活跃的连接数量
server accepts handled requests — 总共处理了11989个连接 , 成功创建11989次握手, 总共处理了11991个请求
reading — 读取客户端的连接数.
writing — 响应数据到客户端的数量
waiting — 开启 keep-alive 的情况下,这个值等于 active – (reading+writing), 意思就是 Nginx 已经处理完正在等候下一次请求指令的驻留连接.

最新文章

  1. asp.net 验证码(一)Session
  2. Android Gradle Build Error:Some file crunching failed, see logs for details解决办法
  3. 字符串流stringstream(头文件sstream)
  4. 离线安装redis集群
  5. React笔记_(5)_react语法4
  6. read 判定用户输入的状态后运行相应的结果
  7. 基于python的二元霍夫曼编码译码详细设计
  8. [Usaco2015 Jan]Grass Cownoisseur Tarjan缩点+SPFA
  9. 一年iOS工作经验,如何一举拿下百度、美团、快手等Offer面经(附面试题)
  10. Python 进程(一)理论部分
  11. CSS定位概述
  12. 软工网络15团队作业4——Alpha阶段敏捷冲刺2.0
  13. 如何在 sublime text 中以当前文件目录打开 cmd
  14. <frameset>框架集中不同<frame>之间的调用【js代码中】
  15. COM 学习
  16. winform FormBordStyle=none 及 wpf FormBordStyle=none 的鼠标点击移动问题
  17. Apache mahout 源码阅读笔记--DataModel之FileDataModel
  18. dubbo forbid 注意的几种方式
  19. Loj 6432. 「PKUSC2018」真实排名 (组合数)
  20. 兼容ie6,ie7,ie8,firefox,chrome浏览器的代码片段

热门文章

  1. hMailServer搭建
  2. 微信小程序搜索排名权重!
  3. 百题计划-2 codeforces1185D Extra Element 暴力
  4. Oversampling Techniques
  5. CSS 多栏布局 固定布局 流动布局
  6. GSON 特殊类型支持序列化和反序列化,如LocalDateTime
  7. 【C++复习】第八章 多态性(2)(虚函数,纯虚函数)
  8. centos linux 忘记密码
  9. 剪裁正方形图片cropper
  10. 记录php遇到的那些坑