一、安装编译工具及库文件

$ yum -y install make zlib zlib-devel gcc gcc-c++ libtool  openssl openssl-devel pcre pcre-devel  //PCRE 作用是让 Nginx 支持 Rewrite 功能

二、安装Nginx

1、下载Nginx至文件夹/usr/local内

$ cd /usr/local/     //进入目标目录
$ wget http://nginx.org/download/nginx-1.14.2.tar.gz //下载nginx,选择稳定版本

2、解压缩文件包

$ tar zxvf nginx-1.14.2.tar.gz

3、进入安装目录,编译安装

$ cd nginx-1.14.2
$ ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-pcre --with-http_ssl_module
$ make
$ make install

安装完成后的摘要信息:

Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ using system zlib library nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
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"

默认安装到/usr/local/nginx目录。

4、查看Nginx版本

$ /usr/local/nginx/sbin/nginx -v

输出结果如下:
nginx version: nginx/1.14.2
到此,nginx安装完成。

5、启动、关闭Nginx

检查配置文件是否正确

$ /usr/local/nginx/sbin/nginx -t
$ /usr/local/nginx/sbin/nginx -V //可以看到编译选项

启动Nginx

$ /usr/local/nginx/sbin/nginx     // 启动
$ /usr/local/nginx/conf/nginx.conf //配置文件

重新载入配置文件

$ /usr/local/nginx/sbin/nginx -s reload

重启Nginx,不会改变启动时指定的配置文件

$ /usr/local/nginx/sbin/nginx -s reopen

停止Nginx

$ /usr/local/nginx/sbin/nginx -s stop

$ pkill nginx

三、Nginx配置

具体配置可搜索,这里不做介绍
配置文件nginx.conf,位置
/usr/local/nginx/conf/nginx.conf

四、防火墙配置

CentOS7默认的防火墙为firewall
开启端口80方法:

$ firewall-cmd --zone=public --add-port=80/tcp --permanent  //--permanent永久生效,没有此参数重启后失效
$ firewall-cmd --reload //重新载入
$ firewall-cmd --zone=public --query-port=80/tcp //查看
//$ firewall-cmd --permanent --query-port=80/tcp //或者这样查看
$ firewall-cmd --zone=public --remove-port=80/tcp --permanent //删除端口

.

CentOS 7服务器下Nginx安装配置的更多相关文章

  1. CentOS 6.3下NFS安装配置

    CentOS 6.3下NFS安装配置 一.环境介绍   NFS服务器:CentOS6.3 192.168.8.20 NFS客户端:CentOS6.5 192.168.8.39 二.服务器端安装配置   ...

  2. VMware Linux 下 Nginx 安装配置 - nginx.conf 配置 [负载两个 Tomcat] (三)

    首先启动Nginx 1. 相关浏览 两个 Tomcat 配置:  VMware Linux 下 Nginx 安装配置 - Tomcat 配置 (二) Nginx 安装配置启动: VMware Linu ...

  3. VMware Linux 下 Nginx 安装配置 - Tomcat 配置 (二)

    准备工作 相关浏览: VMware Linux 下 Nginx 安装配置 (一) 1. 选在 /usr/local/ 下创建 softs 文件夹,通过 ftp 命令 把 apache-tomcat-7 ...

  4. Centos 6.5 下Nginx安装部署https服务器

    一般我们都需要先装pcre, zlib,前者为了重写rewrite,后者为了gzip压缩.1.选定源码目录选定目录 /usr/local/cd /usr/local/2.安装PCRE库cd /usr/ ...

  5. red5下nginx安装配置

    http://zfl110.iteye.com/blog/1155149 原址:http://lqw.iteye.com/blog/652763 安装Nginx 1.首先安装pcre-8.02.tar ...

  6. linux下Nginx 安装配置

    Nginx 安装 一.首先要安装 PCRE PCRE 作用是让 Ngnix 支持 Rewrite 功能. 1.下载 PCRE 安装包,下载地址: http://downloads.sourceforg ...

  7. CentOS 6.5下NFS安装配置

    [root@local /]# yum -y install nfs-utils rpcbind3.创建共享目录:[root@local /]# mkdir /sharestore4.NFS共享文件路 ...

  8. VMware Linux 下 Nginx 安装配置 (一)

    资源准备 1. pcre-8.34.tar.gz: ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ 2. zlib-1.2.8.tar.g ...

  9. CentOS 6.6下Redis安装配置记录

    转载于:http://www.itxuexiwang.com/a/shujukujishu/redis/2016/0216/120.html?1455855209 在先前的文章中介绍过redis,以下 ...

随机推荐

  1. WinPE基础知识之导出表

    // 导出的东西包括函数(变量.类)地址,序号,函数(变量.类)名 typedef struct _IMAGE_EXPORT_DIRECTORY { DWORD Characteristics; // ...

  2. RabbitMQ的持久化(六)

    RabbitMQ的持久化主要体现在三个方面,即交换机持久化,队列持久化及消息持久化 注意,因公司使用php-amqplib来实现RabbitMQ,故之后举例说明的代码均使用的php-amqplib,而 ...

  3. Go语言根据数据表自动生成model以及controller代码

    手写model的用法请参考: https://www.jianshu.com/p/f5784b8c00d0 这里仅说明自动生成model文件的过程 bee generate appcode -tabl ...

  4. 前端基础(四):BOM和DOM

    前戏 到目前为止,我们已经学过了JavaScript的一些简单的语法.但是这些简单的语法,并没有和浏览器有任何交互. 也就是我们还不能制作一些我们经常看到的网页的一些交互,我们需要继续学习BOM和DO ...

  5. 了解认识asp.net运行机制

    asp.net  运行机制 下面了解认识httpModule 要创建一个httpModule类 using System;using System.Collections.Generic;using ...

  6. 少有人知的 GitHub 使用技巧

    GitHub 大家常上吧?可是使用 GitHub 的各种小窍门你就不一定知道了.本文将各种使用 GitHub 的小窍门分享给大家. diff时忽略空格 有些修改只是增减了空格,在URL中添加?w=1就 ...

  7. docker 在push镜像到本地registry出现的500 Internal Server Error

    ]# docker push 192.168.163.131:5000/test The push refers to a repository [192.168.163.131:5000/test] ...

  8. CF1037H Security——SAM+线段树合并

    又是一道\(SAM\)维护\(endpos\)集合的题,我直接把CF700E的板子粘过来了QwQ 思路 如果我们有\([l,r]\)对应的\(SAM\),只需要在上面贪心就可以了.因为要求的是字典序比 ...

  9. vulkan asynchronous compute

    https://www.youtube.com/watch?v=XOGIDMJThto https://www.khronos.org/assets/uploads/developers/librar ...

  10. django设置debug设为False,前端样式出现错乱或静态文件404问题。

    部署到生产环境中遇到的坑大部分都是引用静态文件带来的, setting设置里面debug设为False, 需要设置ALLOWED_HOSTS=["服务器ip"],不然运行不了的. ...