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. CentOS7安装后连不上网络无法使用yum

    更新日期:2018年5月31日 笔者今天在本地VMware中安装了CentOS7后,使用yum安装wget的时候发现不能下载,并有下图所示的提示: 于是,笔者就去问度娘,然后就找到了如下各种回复: 1 ...

  2. Java基础教程(13)--包

      为了使类型更易于查找,避免命名冲突和访问控制,我们应该使用包来对自己定义的类型进行管理.这里说的类型可以是类.接口.枚举和注解(枚举和注解的内容会在后续教程中介绍).使用包来管理我们的代码,有以下 ...

  3. SpringBoot+JPA+cache入门

    在pom.xml中加入如下依赖 <dependency> <groupId>org.springframework.boot</groupId> <artif ...

  4. Supervisord安装和配置

    http://zhangweide.cn/archive/2013/supervisor-note.html Supervisord supervisord的出现,结束了我这苦恼的问题,它可以帮你守护 ...

  5. styled-components 弃用 injectGlobal

    styled-components 最新版本是v4.1.2,但是从v4开始,就酱原来的injectGlobal方法用createGlobalStyle替换了.用法上也有一些不同了: 我今天直接引inj ...

  6. js-NodeList对象和HTMLCollection对象

    getElementsByName()和getElementsByTagName()都返回NodeList对象,而类似document.images和document.forms的属性为HTMLCol ...

  7. apply的“非改变this“的用法

    说到apply,大家都是知道是改变this指向的,也都会立马和call联系在一起,MDN官网上也是如是说: 其实我们在平常使用call和apply的时候,都是想到他们的改变函数的this的功能, 正如 ...

  8. CSS 属性-webkit-tap-highlight-color的理解

    1.-webkit-tap-highlight-color 这个属性只用于iOS (iPhone和iPad).当你点击一个链接或者通过Javascript定义的可点击元素的时候,它就会出现一个半透明的 ...

  9. DOM增删操作(select动态增加和删除以及清空)

    <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...

  10. bootstrapValidator验证中Maximum call stack size exceeded

    Tip1:如果表单不是通过Bootstrap构建(即元素包含表单项且关联的label没有form-group类),可能会看到错误Uncaught RangeError: Maximum call st ...