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

$ 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. react hooks学习

    接触React项目快两个月了,还在研究摸索各种知识点的过程中,充实且幸福. 在项目中学习新知识,还是很有效率的,一边写项目,一边实验新的知识点,比如react hooks!嘻嘻嘻~~~ 写了好一段时间 ...

  2. PyInstaller使用教程

    简介 PyInstaller是一个第三方库,它能够在Windows.Linux. Mac OS X 等操作系统下将 Python 源文件打包,通过对源文件打包, Python 程序可以在没有安装 Py ...

  3. @ComponentScan注解及其XML配置

    开发中会经常使用包扫描,只要标注了@Controller.@Service.@Repository,@Component 注解的类会自动加入到容器中,ComponentScan有注解和xml配置两种方 ...

  4. 6.单表的CRUD操作

    1.插入后用新id初始化被插入对象 <insert id="insertStudentCatchId"> insert into student (age,name,s ...

  5. 简单介绍 Java 构造器

    导读 构造器是编程的强大组件.使用它们来释放 Java 的全部潜力. 在开源.跨平台编程领域,Java 无疑(?)是无可争议的重量级语言.尽管有许多伟大的跨平台框架,但很少有像 Java 那样统一和直 ...

  6. 自动化测试环境搭建(appium+selenium+python)

    一.需要安装的软件(根据你所需要的版本安装即可,不一定必须按照小编的版本来) JDK:1.8.0_171 Python:3.7.1 node.js:10.13.0 android-sdk_r24.4. ...

  7. 数据库 Redis:Windows环境安装

    1. 下载 Redis (1)前往 GitHub 下载:https://github.com/microsoftarchive/redis (2)点击 release : (3)选择好版本号后,下载文 ...

  8. ak-2

    1.人大金仓数据 jdbc 安装完成之后有个jdbc的文件夹  里边就是 jdbc包,相应的window前端工具有jdbc示例,因为太多没看全呢,有一个“”模式“”的概念  jdbc连接时如果要指定模 ...

  9. 【线段树 dp】8.6集合

    线段树维护dp 题目大意 给定初始大小为 $N$ 的正整数集合.定义两个数$x$和$y$建立联系的的代价为 $|x-y|$.我们定义整数集合的代价为:将每个整数都与至少一个另外的整数建立联系之后,所有 ...

  10. vue 后退不刷新,前进刷新 keep-alive

    最近在开发中遇到了这样的一个问题: A.B.C三个页面,有如下这样的场景: (1)从页面A离开进入B或C的时候,缓存A页面的数据,并且返回到A后,能保持A页面的跳转前职位 (2)离开B进入C的时候,缓 ...