一、下载

  地址:http://nginx.org/en/download.html

  或者在linux上使用wget命令下载:

  wget http://124.202.164.5/files/40950000082BD3BE/nginx.org/download/nginx-1.8.1.tar.gz

二、编译安装

[root@root3 soft]# tar -zxvf nginx-1.8..tar.gz
nginx-1.8./
nginx-1.8./auto/
nginx-1.8./conf/
nginx-1.8./contrib/
nginx-1.8./src/
nginx-1.8./configure
nginx-1.8./LICENSE
nginx-1.8./README
...
[root@root3 soft]# cd nginx-1.8.
nginx-1.8.]# ./configure
checking for OS
+ Linux 2.6.-.el6.i686 i686
checking for C compiler ... found
+ using GNU C compiler
...
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

  Nginx的一些模块需要其他第三方库的支持,比如gzip模块需要zlib库,rewrite模块需要pcre库,ssl需要openssl库等。  

  上述error说明,没有安装pcre库。

  安装zlib、zlib-devel、openssl、openssl-devel、pcrepcre-devel

[root@root3 ~]# yum install zlib zlib-devle openssl openssl-devel pcre pcre-devel

  重新./configure

[root@root3 nginx-1.8.]# ./configure
checking for OS
+ Linux 2.6.-.el6.i686 i686
checking for C compiler ... found
+ using GNU C compiler
+ gcc version: 4.4. (Red Hat 4.4.-) (GCC)
...
Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ md5: using system crypto library
+ sha1: using system crypto library
+ using system zlib library nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
[root@root3 nginx-1.8.]# make
[root@root3 nginx-1.8.]# make install

  安装成功!。

  按照以上命令,Nginx默认被安装到/usr/local/nginx下。另外您可以通过./configure --help命令查看Nginx可选择编译项目。可参考《Nginx手动编译的编译选项解析》。

三、启动、停止、平滑重启

  a)启动

    Nginx的安装目录是/usr/local/nginx,那么Nginx的启动命令就是:

    /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

    其中参数“-c”指定了配置文件的路径,如果不加"-c'参数,Nginx会默认加载其安装目录的的conf子目录的nginx.conf文件。在本例中是/usr/local/nginx/conf/nginx.conf。

    如果配置文件正确,则显示以下信息:

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@mch conf]# ps -ef|grep nginx
root : ? :: nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
oracle : ? :: nginx: worker process
oracle : ? :: nginx: worker process
oracle : ? :: nginx: worker process
oracle : ? :: nginx: worker process
oracle : ? :: nginx: worker process
oracle : ? :: nginx: worker process
oracle : ? :: nginx: worker process
oracle : ? :: nginx: worker process
root : pts/ :: grep nginx

   通过浏览器访问:IP地址:Nginx端口号(端口号是在nginx.conf中server模块中配置的),我的是:http://192.168.159.129:80/

  b) 停止

    Nginx的停止的方法有很多种,一般是通过发送系统信号给Nginx主进程的方式来停止Nginx。

    我们通过ps命令查看Nginx的主进程号:

[root@mch ~]# ps -ef | grep nginx
root : ? :: nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
oracle : ? :: nginx: worker process
oracle : ? :: nginx: worker process
oracle : ? :: nginx: worker process
oracle : ? :: nginx: worker process
oracle : ? :: nginx: worker process
oracle : ? :: nginx: worker process
oracle : ? :: nginx: worker process
oracle : ? :: nginx: worker process
root : pts/ :: grep nginx

    从上边可以看到:其中备注为master process的进程,表示他是主进程,另外8个“worker process”,表示是子进程,其中2439是主进程号。

    

    a)从容停止Nginx

      kill - QUIT Nginx主进程号。

      或:

      kill -QUTI /usr/local/nginx/nginx.pid

    b)快速停止Nginx

      kill - TERM Nginx主进程号

      kill - TERM /usr/local/nginx/nginx.pid

      或:

      kill - INT Nginx主进程号

      kill - INT /usr/local/nginx/nginx.pid

     c)强制停止所有nginx进程

        kill -9 nginx

  c)平滑重启

      重启之前要确认配置文件nginx.conf的语法是否正确,否则nginx不会加载新的配置文件。通过以下命令判断neginx配置文件是否正确:

      /usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf

      控制台出现如下结果说明配置文件正确:

     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

     查看nginx主进程号:    

[root@mch /]# ps -ef|grep nginx
root Oct13 ? :: nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
oracle : ? :: nginx: worker process
oracle : ? :: nginx: worker process
oracle : ? :: nginx: worker process
oracle : ? :: nginx: worker process
oracle : ? :: nginx: worker process
oracle : ? :: nginx: worker process
oracle : ? :: nginx: worker process
oracle : ? :: nginx: worker process
root : pts/ :: grep nginx

    重启Nginx:

     kill -HUP Nginx主进程号

     kill -HUP /usr/local/nginx/nginx.pid

  参考文档:

      《实战Nginx:取代Apache的高性能Web服务器》

Linux Centos 6.5_x86安装Nginx的更多相关文章

  1. Linux Centos平台下安装Nginx

    以home下安装为例,切换到home目录下 cd /home 安装依赖 nginx相关依赖 yum -y install make gcc gcc-c++ openssl openssl-devel ...

  2. Linux : centOS 与 Ubuntu 安装 Nginx

    源码下载: wget http://nginx.org/download/nginx-1.14.0.tar.gz 解压:tar –zxvf xxx 安装依赖: yum -y install  open ...

  3. Linux系统运维笔记(四),CentOS 6.4安装Nginx

    Linux系统运维笔记(四),CentOS 6.4安装Nginx 1,安装编译工具及库文件 yum -y install make zlib zlib-devel gcc-c++ libtool op ...

  4. Centos 7下安装nginx,使用yum install nginx,提示没有可用的软件包

    Centos 7下安装nginx,使用yum install nginx,提示没有可用的软件包. 18 (flaskApi) [root@67 flaskDemo]# yum -y install n ...

  5. Linux CentOS 6.6安装JDK1.7

    Linux CentOS 6.6安装JDK1.7 目录 1.下载JDK 2.卸载JDK 3.安装JDK 3.1..rpm后缀格式JDK安装方式 3.2..tar.gz后缀格式JDK安装方式 4.验证安 ...

  6. 在CentOS 7中安装nginx服务器

    简要地介绍一下,如何在CentOS 7中安装nginx服务器  下载对应当前系统版本的nginx包(package) # wget  http://nginx.org/packages/centos/ ...

  7. Linux CentOS 编绎安装Python 3.5

    Linux CentOS 编绎安装Python 3.5 先决条件(若无安装,则不能编绎使用idle3):yum install tk-devel xz -d Python-3.5.0.tar.xzta ...

  8. Red hat Linux(Centos 5/6)安装R语言

    Red hat Linux(Centos 5/6)安装R语言1 wget http://cran.rstudio.com/src/base/R-3/R-3.0.2.tar.gz2 tar xzvf R ...

  9. Linux Centos 系统上安装BT客户端 Transmission

    Linux Centos 系统上安装BT客户端 Transmission   Transmission是一种BitTorrent客户端,特点是一个跨平台的后端和其上的简洁的用户界面,以MIT许可证和G ...

随机推荐

  1. Java面向对象核心技能

    1.封装 封装是面向对象的三大特性之一,就是将类的状态信息隐藏在类内部,不允许外部程序直接访问,而通过该类提供的方法来实现对隐藏信息的操作和访问. 封装的好处:隐藏类的实现细节:让使用者只能通过程序规 ...

  2. CSS3学习笔记(2)-CSS盒子模型

    p{ font-size: 15px; text-indent: 2em; } .alexrootdiv>div{ background: #eeeeee; border: 1px solid ...

  3. poptest老李谈动态口令原理

    poptest老李谈动态口令原理     poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课程感兴趣,请大家咨询qq:908 ...

  4. css实现超出部分用...代替

    如果是一行的话 css为 white-space: nowrap: 保证文本内容不会自动换行,如果多余的内容会在水平方向撑破单元格. overflow: hidden: 隐藏超出单元格的部分. tex ...

  5. python 日期 & 时间

    1. Python 提供了一个 time 和 calendar 模块可以用于格式化日期和时间. 2. 时间间隔是以秒为单位的浮点小数. 3. 每个时间戳都以自从1970年1月1日午夜(历元)经过了多长 ...

  6. macOS平台下虚拟摄像头的研发总结

    一.背景介绍 虚拟摄像头,顾名思义,就是利用软件技术虚拟出一个摄像头硬件设备供用户使用.当我们需要对视频图像进行处理再输出时,虚拟摄像头就具备非常大的价值了.关于如何在Windwos上实现一个虚拟设备 ...

  7. JSON的数据类型

    数据类型简介 在计算机中,我们需要知道正在处理什么类型的数据,因为不同类型的数据有着不同的操作途径.可以让两个阿拉伯数字相乘,但是不能让两个单词相乘. 在计算机科学中,有一种数据类型被称为原始数据类型 ...

  8. selenium实例:unittest框架+PO开发模式

    这是<selenium2+python学习总结>的升级版. 1.         项目结构 2.         项目代码 1)         globalparameter.py # ...

  9. Azure Messaging-ServiceBus Messaging消息队列技术系列8-服务总线配额

    上篇博文中我们介绍了Azure ServiceBus Messaging的消息事务机制: Azure Messaging-ServiceBus Messaging消息队列技术系列7-消息事务(2017 ...

  10. 【Linux Tips】登陆,提示符,别名

    1.Linux 的tty界面下的登陆界面设置 看了半天发现,原来每次ctrl+alt+F1进入的tty1刚开始显示的就是初始化的登陆界面,顿时有种想装扮下他的冲动,因为实在是太简单了点,不过我是个喜欢 ...