1. 安装nginx依赖

首先安装nginx的依赖

yum install gcc gcc-c++ openssl openssl-devel cyrus-sasl-md5

2,创建nginx用户

如果没有nginx,启动nginx时会报错

[root@localhost nginx-1.11.]# /usr/local/nginx/sbin/nginx
nginx: [emerg] getpwnam("nginx") failed
因此执行
groupadd nginx
useradd -s /sbin/nologin -g nigix -M nginx

3,下载最新版nginx安装包

wget -C http://nginx.org/download/nginx-1.12.0.tar.gz

4,解压

tar zxvf nginx-1.12..tar.gz

5,进入nginx目录

cd nginx-1.12.

6,编译设置

./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module

因此要顺利的通过nginx编译安装必须安装的依赖关系有:

yum install gc gcc gcc-c++ pcre-devel zlib-devel openssl-devel

如果有错误提示:./configure: error: C compiler cc is not found

解决方法:

yum install gcc gcc-c++

如果有错误提示:./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.

解决方法:

yum install pcre-devel

如果有错误提示:./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using –with-openssl=<path> option.

解决方法:

yum install openssl-devel
7,编译&安装
make & make install
8,nginx直接启动方法
/usr/local/nginx/sbin/nginx

 9,现在我们将nginx加入到环境变量中

vi /etc/profile 

随后我们更新环境变量 并使用命令再次重启nginx

写在结尾:可能会出现没有pid文件的情况

 ps -ef|grep nginx
过滤出nginx的进程号,然后在配置文件中 pid配置目录创建一个pid文件,里面填写nginx的进程号就可以了。

[emerg]: getpwnam(“nginx”) failed

 
1
2
[root@localhost nginx-1.11.2]# /usr/local/nginx/sbin/nginx
nginx: [emerg] getpwnam("nginx") failed

CentOs7.2编译安装Nginx服务器的更多相关文章

  1. Windows 编译安装 nginx 服务器 + rtmp 模块

    有关博客: <Windows 编译安装 nginx 服务器 + rtmp 模块>.<Ubuntu 编译安装 nginx>.<Arm-Linux 移植 Nginx> ...

  2. linux软件管理之------编译安装nginx服务器并手动编写自动化运行脚本

    红帽系列的 linux软件管理分为三类:1. rpm 安装软件.2. yum 安装软件.3. 源码包编译安装.前面两种会在相关专题给出详细讲解.源码包的编译安装是非常关键的,我们知道linux的相关版 ...

  3. CentOS7.6编译安装nginx

    配置阿里云yum源 cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak wget -O /etc/yu ...

  4. centos7下快速安装Nginx服务器

    1.添加源 默认情况Centos7中无Nginx的源,最近发现Nginx官网提供了Centos的源地址.因此可以如下执行命令添加源: sudo rpm -Uvh http://nginx.org/pa ...

  5. CentOS7.3编译安装Nginx设置开机启动

    起因 最近想玩nginx了,本来用yum -y install nginx安装也启动好了,但是买了本<Nginx高性能Web服务器详解>,我咋能辜负我的书费呢?于是我就直接ps -ef | ...

  6. 在centos7上编译安装nginx

    题前,先放一个有图有真相的博客链接:https://www.cnblogs.com/zhang-shijie/p/5294162.html 虽然别人说的很详细,但还是记录一下 1.VMWare Wor ...

  7. CentOS7.x编译安装nginx,实现HTTP2

    网站使用HTTP2有助于网站加速及更安全,要配置HTTP2必须满足两个条件:①openssl的版本必须在1.0.2e及以上.②nginx的版本必须在1.9.5以上 一.准备工作  配置HTTP2之前需 ...

  8. Ubuntu 编译安装 nginx

    有关博客: <Windows 编译安装 nginx 服务器 + rtmp 模块>.<Ubuntu 编译安装 nginx>.<Arm-Linux 移植 Nginx> ...

  9. Centos7 编译安装 Nginx PHP Mariadb Memcached 扩展 ZendOpcache扩展 (实测 笔记 Centos 7.3 + Mariadb 10.1.20 + Nginx 1.10.2 + PHP 7.1.0 + Laravel 5.3 )

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7-x86_64-Minimal-1611.iso 安装步骤: 1.准备 1.0 查看硬 ...

随机推荐

  1. FacebookFriendAdderPro

    Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\Fe ...

  2. 深入分析 Java 中的中文编码问题【转】

    转:https://www.ibm.com/developerworks/cn/java/j-lo-chinesecoding/ 几种常见的编码格式 为什么要编码 不知道大家有没有想过一个问题,那就是 ...

  3. SpringBoot(六) Web Applications: Embedded Containers(嵌入式容器)

    参考 文档: 28.4 Embedded Servlet Container Support

  4. Packet for query is too large (5,145 > 1,024). You can change this value on the server by setting the 'max_allowed_packet' variable.

    错误 在使用Mybatis generator时提示MySQL写入过大 Packet for query is too large (5,145 > 1,024). You can change ...

  5. golang chan 发送接收测试数据

    测试代码: package main import (     "fmt"     "time" ) const (     num = 10000000  / ...

  6. Intellij IDEA run coverage之覆盖率测试

    Intellij IDEA run coverage之覆盖率测试 idea 的coverage + 我们自己写的测试用例.最后看一下,我们要测的代码有没有测试到,这是一个不错的提高代码质量的方法. i ...

  7. Yii中文乱码 解决

    需要将config/main.php改成utf-8编码即可

  8. Elixir木蚂蚁支付服务器验签名方法

    官方范例为java public boolean verify(String sign , String appKey , String orderId) throws UnsupportedEnco ...

  9. JAVA 分布式 - 分布式介绍

    什么是分布式系统? 要理解分布式系统,主要需要明白一下2个方面: 1.分布式系统一定是由多个节点组成的系统. 其中,节点指的是计算机服务器,而且这些节点一般不是孤立的,而是互通的. 2.这些连通的节点 ...

  10. 大O表示法

    概念 大O表示法是和数据项的个数相关联的粗略度量算法时间复杂度的快捷方法. 常数一个无序可重复数组插入一个数据项的时间T是常数K,常数K表示一次插入所花费的时间,包含cpu.编译器等工作时间.可表示为 ...