参考 http://www.linuxidc.com/Linux/2016-09/134907.htm

安装依赖

openssl zlib pcre gcc

下载安装包

[root@localhost src]# wget http://nginx.org/download/nginx-1.8.1.tar.gz
解压缩安装包

[root@localhost src]# tar -zxvf nginx-1.8.1.tar.gz -C /usr/local

安装 gcc

安装 nginx 需要先将官网下载的源码进行编译,编译依赖 gcc 环境,如果没有 gcc 环境,则需要安装

[root@localhost nginx-1.8.1]# yum -y install gcc-c++

安装 pcre  pcre-devel

PCRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使用 pcre 来解析正则表达式,所以需要在 linux 上安装 pcre 库,pcre-devel 是使用 pcre 开发的一个二次开发库。nginx也需要此库。命令:

[root@localhost nginx-1.8.1]# yum -y install pcre-devel

安装 zlib-devel

zlib 库提供了很多种压缩和解压缩的方式, nginx 使用 zlib 对 http 包的内容进行 gzip ,所以需要在 Centos 上安装 zlib 库。

[root@localhost nginx-1.8.1]# yum -y install zlib-devel

OpenSSL 安装

OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应用程序供测试或其它目的使用。
nginx 不仅支持 http 协议,还支持 https(即在ssl协议上传输http),所以需要在 Centos 安装 OpenSSL 库。

[root@localhost nginx-1.8.1]# yum install -y openssl openssl-devel

安装nginx

[root@localhost nginx-1.8.1]# ./configure    #默认安装到/usr/local/nginx目录下

[root@localhost nginx-1.8.1]# make    #编译

[root@localhost nginx-1.8.1]# make install    #安装

启动ngnix

[root@localhost local]# cd /usr/local/nginx/sbin
[root@localhost sbin]# ./nginx  #启动命令注意输入的 点和斜杠,如果直接输入 nginx会提示  "bash: nginx: 未找到命令..."
查看nginx进程

[root@localhost sbin]# ps -ef|grep nginx
root      5455     1  0 06:24 ?        00:00:00 nginx: master process ./nginx
nobody    5456  5455  0 06:24 ?        00:00:00 nginx: worker process
root      5500  4179  0 06:26 pts/1    00:00:00 grep --color=auto nginx

从容停止-杀死进程

kill -QUIT 5455

快速停止-杀死进程

kill -TERM 5455

强制停止-杀死进程

kill -9 5455

在浏览器访问 http://localhost

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at
nginx.com.

Thank you for using nginx.

nginx目录下内容

[root@localhost nginx]# ll
总用量 4
drwx------. 2 nobody root    6 3月  27 23:02 client_body_temp
drwxr-xr-x. 2 root   root 4096 3月  27 23:04 conf
drwx------. 2 nobody root    6 3月  27 23:02 fastcgi_temp
drwxr-xr-x. 2 root   root   40 3月  27 22:57 html
drwxr-xr-x. 2 root   root   58 3月  28 06:24 logs
drwx------. 2 nobody root    6 3月  27 23:02 proxy_temp
drwxr-xr-x. 2 root   root   19 3月  27 22:57 sbin
drwx------. 2 nobody root    6 3月  27 23:02 scgi_temp
drwx------. 2 nobody root    6 3月  27 23:02 uwsgi_temp
[root@localhost nginx]#

nginx常用命令

nginx -t:检查配置文件是否正确。这个命令可以检查nginx.conf配置文件其格式、语法是否正确。如果配置文件存在错误,则会出现相应提示;如果nginx.conf文件正确,也会出现相应的成功提示。

[root@localhost 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

nginx -s reload:重加载/重启nginx——以新的nginx.conf配置文件中的定义。

nginx -s stop:停止nginx。必须有-s参数

centos7下安装ngnix1.8.1的更多相关文章

  1. CentOS7 下 安装 supervisor以及使用

    CentOS7 下 安装 supervisor 以及使用 手动安装 [注] linux环境必须安装 python 1.获取supervisor包:[https://pypi.python.org/py ...

  2. Linux CentOs7 下安装 redis

    Linux CentOs7 下安装 redis 请将以下命令放入linux命令行中运行 如果安装过程前没有安装GCC请先安装  命令如下 $ yum install gcc-c++ $ wget ht ...

  3. Centos7下安装配置Redsocks

    Redsocks是一个开源的网络程序,代码依赖开源的libevent网络库.Redsocks允许你将所有TCP连接重定向到SOCKS或HTTPS代理,比如Shadowsocks(Centos7下安装配 ...

  4. CentOS7下安装SVN服务端

    CentOS7下安装SVN服务 1. yum命令即可方便的完成安装# sudo yum install subversion 测试安装是否成功:# svnserve --version 更改svn的默 ...

  5. centOS7下安装GUI图形界面

    1.如何在centOS7下安装GUI图形界面 当你安装centOS7服务器版本的时候,系统默认是不会安装GUI的图形界面程序,这个需要手动安装CentOS7 Gnome GUI包. 2.在系统下使用命 ...

  6. CentOS7下安装MySQL并配置远程连接

    一.CentOS7下安装MySQL数据库 CentOS7默认的安装包里面已经没有 MySQL-Server安装包了,远程镜像中也没有了. 默认的是MariaDB (MySQL的一个分支,开发这个分支的 ...

  7. Docker学习笔记3:CentOS7下安装Docker-Compose

    Docker-Compose是一个部署多个容器的简单但是非常必要的工具. 安装Docker-Compose之前,请先安装 python-pip,请参考我的另一篇博文CentOS7下安装python-p ...

  8. docker(一) Centos7下安装docker

    docker(一) Centos7下安装dockerdocker(二) windows10下安装dockerdocker(三) 镜像和容器常用命令 docker(四) 使用Dockerfile构建镜像 ...

  9. centos7 下 安装部署nginx

    centos7 下 安装部署nginx 1.nginx安装依赖于三个包,注意安装顺序 a.SSL功能需要openssl库,直接通过yum安装: #yum install openssl b.gzip模 ...

随机推荐

  1. bat脚本中timeStamp解决方案

    之前做了个工具包,用了timeStamp做文件名. 一般来说最简单的代码类似于: set timeStamp=%date:/=-%_%time% echo %timeStamp% >2018-0 ...

  2. rabbitmq 3.6.11 centos 7 安装

    http://www.rabbitmq.com/releases/erlang/erlang-19.0.4-1.el7.centos.x86_64.rpm http://www.rabbitmq.co ...

  3. poj1691

    Painting A Board Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3642   Accepted: 1808 ...

  4. 巨蟒python全栈开发-第3天

    1 今日作业 1.有变量name = "aleX leNb" 完成如下操作: # 1)移除 name 变量对应的值两边的空格,并输出处理结果 '''''' ''' # name = ...

  5. 数值和字符串相互转换(C++ 数据类型转换技巧)

    类型转换是将一种类型的值映射为另一种类型的值.进行数据类型的转换. 是在实际代码编写中经常遇到的问题,特别是字符串和其他类型的转换. 1.将字符串转换为整数 (1).转换函数// 双精度函数doubl ...

  6. 模块 - hashlib/subprocess

    hashlib 模块 加密算法: hash (152位)散列 哈希 不可逆得 密码背后就是 hash 程序退出hash 值就变了 ,hash值得结果有可能重复 MD5 (128位) 讯息摘要演算法 基 ...

  7. Set 接口常用子类及其特点

    Set 集合中元素不可重复,是无序的(存入和取出的顺序是不一样的), Set 接口中的方法和 Collection 接口一致. 常用子类: HashSet : 内部数据结构是哈希表, 是不同步的 Li ...

  8. 转!java产生不重复随机数

    private static void testC(int sz) { long startTime = System.currentTimeMillis(); //开始测试时间 Random rd ...

  9. caffe杂

    一.finetune命令: mpirun /home/zhangsuosheng/caffe_mpi/build/tools/caffe train -solver solver.prototxt - ...

  10. pycharm调试scrapy

    pycharm调试scrapy 创建一个run.py文件作为调试入口 run.py中,name是要调试的爬虫的名字(注意,是爬虫类中的name,而不是爬虫类所在文件的名字) 拼接爬虫运行的命令,然后用 ...