[CentOS 7] 安装nginx

首先进行 nginx yum

Nginx安装记录

注意:如果用源码安装,nginx配置时需要指定--with-pcer对应的压缩包路径,如果使用二进制安装不需要指定

依赖包使用二进制yum一键安装:yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel

一键安装开发工具包:yum -y groupinstall "Development Tools" "Development Libraries"

下载Nginx

http://nginx.org/download/nginx-1.8.0.tar.gz

Nginx安装所需依赖包

1、rewrite模块需要pcre库(下载: http://www.pcre.org)    支持nginx伪静态

2、ssl模块需要openssl库(下载: http://www.openssl.org)    nginx扩展

3、gzip模块需要zlib库(下载:http://www.zlib.net)      nginx扩展

编译安装Nginx所需依赖包

pcre:

tar zxvf pcre-8.38.tar.gz

cd pcre-8.38/

./configure --prefix=/usr/local/pcre

make

make install

openssl:

tar zxvf openssl-1.0.2e.tar.gz

cd openssl-1.0.2e/

*注意此处

./config --prefix=/usr/local/openssl

make&&make install

tar zxvf zlib-1.2.8.tar.gz

cd zlib-1.2.8/

./configure --prefix=/usr/local/zlib

make&&make install

安装Nginx

groupadd -r nginx

useradd -r -g nginx -s /bin/false -M nginx

tar zxvf nginx-1.8.0.tar.gz

cd nginx-1.8.0/

./configure --prefix=/usr/local/nginx \   set installation prefix

--without-http_memcached_module \        disable ngx_http_memcached_module

--user=nginx \                     set non-privileged user for worker processes

--group=nginx \               set non-privileged group for worker processes

--with-http_stub_status_module \         取得一些nginx的运行状态

--with-http_ssl_module \             开启HTTP SSL模块,以支持HTTPS请求。

--with-http_gzip_static_module \         预压缩文件传输前检查,防止文件被重复压缩

--with-pcre=/home/eric/pcre-8.38 \        *路径指向解压源码所在的目录

--with-openssl=/home/eric/openssl-1.0.2d \    *路径指向解压源码所在的目录

--with-zlib=/home/eric/zlib-1.2.8         *路径指向解压源码所在的目录

make

make install

*注:编译好后可通过/usr/local/nginx/sbin/nginx -V (Nginx安装的路径)查看编译时候的参数

启动Nginx服务

cd /usr/local/nginx/

nginx -c /etc/nginx/nginx.conf

参数“-c”指定了Nginx配置文件的路径,如果不加“-c”参数,Nginx会默认加载其安装目录的conf子目录中的nginx.conf文件.

nginx安装 nginx: [emerg] getpwnam(“www”) failed 错误

附加:

查看监听端口netstat -nptl

nginx启动、重启、关闭
一、启动  
cd usr/local/nginx/sbin
./nginx
二、重启
  更改配置重启nginx  
kill -HUP 主进程号或进程号文件路径
或者使用
cd /usr/local/nginx/sbin
./nginx -s reload
    判断配置文件是否正确 
nginx -t -c /usr/local/nginx/conf/nginx.conf
或者
cd  /usr/local/nginx/sbin
./nginx -t
三、关闭
  查询nginx主进程号
  ps -ef | grep nginx
  从容停止   kill -QUIT 主进程号
  快速停止   kill -TERM 主进程号
  强制停止   kill -9 nginx
  若nginx.conf配置了pid文件路径,如果没有,则在logs目录下
  kill -信号类型 '/usr/local/nginx/logs/nginx.pid'
四、升级
  1、先用新程序替换旧程序文件
  2、kill -USR2 旧版程序的主进程号或者进程文件名
    此时旧的nginx主进程会把自己的进程文件改名为.oldbin,然后执行新版nginx,此时新旧版本同时运行
  3、kill -WINCH 旧版本主进程号
  4、不重载配置启动新/旧工作进程
    kill -HUP 旧/新版本主进程号
    从容关闭旧/新进程
    kill -QUIT 旧/新进程号
    快速关闭旧/新进程
    kill -TERM 旧/新进程号

Nginx关闭版本信息显示

nginx出错会在http头显示醒目的版本号提示,为了安全需要关闭这些信息。

方法很简单,只需在nginx.conf的http中加入server_tokens参数

http {

include       mime.types;

default_type  application/octet-stream;

server_tokens off;

}

防火墙

Centos 7默认启用Firewalld

访问Nginx需要开放80端口

firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --zone=trusted --add-port=80/tcp

删:Centos 7安装Nginx 1.8的更多相关文章

  1. CentOS 7 安装 Nginx 配置反向代理

    Linux使用Nginx Yum存储库上安装Nginx,适用于Red Hat Enterprise Linux和CentOS系统. 1.添加设置Nginx Yum存储库 在CentOS中首次安装Ngi ...

  2. linux/centos下安装nginx(rpm安装和源码安装)详细步骤

    Centos下安装nginx rpm包                                                                                 ...

  3. CentOS下安装Nginx并添加nginx_upload_module

    安装前,最好能保证依赖的系统软件已经升级.    yum update CentOS上安装Nginx,如果只是简单安装,不附加其他第三方模块,一句话可以搞定:    yum install nginx ...

  4. CentOS 7安装nginx

    CentOS 7安装nginx 参考网上其他文章做的 安装Nginx 我们从nginx官方的RPM源来安装一个预构建的稳定版本的nginx包. rpm --import http://nginx.or ...

  5. Centos 在线安装 nginx

    centos 在线安装 nginx 安装nginx ​ 参考文档: http://nginx.org/en/linux_packages.html 中的RHEL/CentOS章节,按照步骤安装repo ...

  6. CentOS 下 安装 nginx 执行配置命令 ./configure 报错

    CentOS 下 安装 nginx 执行配置命令 ./configure --prefix=/opt/nginx --sbin-path=/usr/bin/nginx 时提示以下错误: checkin ...

  7. 删:[CentOS 7] 安装nginx

    下载对应当前系统版本的nginx包(package) # wget  http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-cent ...

  8. CentOS 7 安装Nginx 并配置自动启动

    1.官网下载安装包 http://nginx.org/en/download.html,选择适合Linux的版本,这里选择最新的版本,下载到本地后上传到服务器或者centos下直接wget命令下载. ...

  9. 从零开始学 Java - CentOS 下安装 Nginx

    早上下起了暴雨 闹钟还未响起就听到雨滴哗啦啦击打窗户的声音,被吵醒了.起床上班,在楼下的十字路口,暴雨大到完全看不清对面,两个穿着雨衣的交警站在路口中间指挥着过往的车辆,大家都慌慌张张.急急忙忙的打着 ...

随机推荐

  1. (easy)LeetCode 205.Isomorphic Strings (*)

    Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the chara ...

  2. 利用Jersey构建REST之入门实例

    一.依赖包 1.目录结构如下:

  3. java枚举使用

    1.开发中如何使用枚举,一般在开发中使用消息提示.枚举可以继承,实现接口等.public enum Result { SUCCESS(1,"201 ok") { @Override ...

  4. openssl rsa 私钥 PKCS8私钥 公钥

    上文配置好 openssl 运行 => cmd => cd C:\usr\local\ssl\bin => 执行 openssl

  5. Hive基础之COALESCE用法

    语法: COALESCE(T v1, T v2, …) 返回参数中的第一个非空值:如果所有值都为NULL,那么返回NULL 以emp表为例: desc emp; empno int None enam ...

  6. VC 三点 划 曲线

    y = ax2+bx+c 条件,三点成一曲线 pointone(x1,y1)//(y1在X柱上,必须为零,如果不为零这个公式要重新求值) pointtwo(x2,y2)// 可以为任意值 pointt ...

  7. 【转】SQL注入(通过sqlmap来改变所有事情)

    第一步: sqlmap基于Python2.72版本,所以首先下载: https://www.python.org/  记住不要下载python3 第二步: 安装Python,将sqlmap解压到Pyt ...

  8. 【练习】显示MYSQL客户机选项

    [oracle@enmo ~]$ mysql --help mysql Ver , for Linux (x86_64) using EditLine wrapper Copyright (c) , ...

  9. 循环链表Josephus问题(c,cpp)

    问题描述: 设有n个人围坐在一个圆桌周围,现从第s个人开始报数,数到第m个的人出列,然后从出列的下一个人重新开始报数,数到第m个的人又出列,.......,如此反复直到所有的人出列为止. Joseph ...

  10. sql server数据库中 smallint, int ,bigint ,tinyint的区别与长度

    smallint  是一种精确的数值数据类型,其精度在算术运算后不变,采用2个字节编码 有符号的 smallint 值的范围是 -2^15-------2^15 -1,即 -32768 ----327 ...