一丶官网 http://nginx.org/en/download.html 至于安装那个版本首先要看清楚版本代表什么意思

Nginx官网提供了三个类型的版本
Mainline version:Mainline 是 Nginx 目前主力在做的版本,可以说是开发版
Stable version:最新稳定版,生产环境上建议使用的版本(毫无疑问,生产环境用于次版本)
Legacy versions:遗留的老版本的稳定版

编译安装前所需要的准备:

1.GCC编译器
首先检查GCC是否安装,命令:gcc -v ,如果显示有相关版本信息,则说明已经安装好,没有就安装:

yum install -y gcc    # -y参数表示一直确认安装 

2.PCRE库
Nginx的HTTP模块要用它来解析正则表达式。

yum install -y pcre pcre-devel 

pcre-devel是使用PCRE做二次开发时所需要的开发库。类似的你可以想到安装LAMP时安装的php-devel。
3.zlib库
gzip格式的压缩会用到它。

yum install -y zlib zlib-devel 

4.OpenSSL库

yum install -y openssl openssl-devel 

wget http://nginx.org/download/nginx-1.14.0.tar.gz #这里安装的是1.14.0生产稳定版本

解压安装

tar -zxvf nginx-1.14.0.tar.gz
cd nginx-1.14.0/

  1. ./configure --prefix=/usr/local/nginx --pid-path=/run/nginx.pid  --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log  --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module --with-pcre   #生成 Makefile,为下一步的编译做准备
  2. make             #编译
  3. make install     #安装

附(Nginx部分控制命令):

默认Nginx安装在/usr/local/nginx/中,因此

  1. /usr/local/nginx/sbin/nginx           #默认启动方式 start
  2. /usr/local/nginx/sbin/nginx -t        #测试配置信息
  3. /usr/local/nginx/sbin/nginx -v        #显示版本信息,-V(大V)显示编译时的参数
  4. /usr/local/nginx/sbin/nginx -s stop  #快速停止服务
  5. /usr/local/nginx/sbin/nginx -s quit   #正常停止服务
  6. /usr/local/nginx/sbin/nginx -s reload                            #重启

Q: nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)

A: [root@localhost nginx]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

 
使用nginx -c的参数指定nginx.conf文件的位置

如果不行记得要打开端口

firewall-cmd --zone=public --add-port=80/tcp --permanent (--permanent永久生效,没有此参数重启后失效)

重新载入

firewall-cmd --reload

可选 创建方便启动命令

创建nginx启动命令脚本

vi /etc/init.d/nginx 

插入以下内容:

#! /bin/bash
# chkconfig: - 85 15
PATH=/usr/local/nginx
DESC="nginx daemon"
NAME=nginx
DAEMON=$PATH/sbin/$NAME
CONFIGFILE=$PATH/conf/$NAME.conf
PIDFILE=$PATH/logs/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
set -e
[ -x "$DAEMON" ] || exit 0
do_start() {
$DAEMON -c $CONFIGFILE || echo -n "nginx already running"
}
do_stop() {
$DAEMON -s stop || echo -n "nginx not running"
}
do_reload() {
$DAEMON -s reload || echo -n "nginx can't reload"
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
do_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
do_stop
echo "."
;;
reload|graceful)
echo -n "Reloading $DESC configuration..."
do_reload
echo "."
;;
restart)
echo -n "Restarting $DESC: $NAME"
do_stop
do_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2
exit 3
;;
esac
exit 0

  设置执行权限 
chmod a+x /etc/init.d/nginx 
注册成服务 
chkconfig --add nginx 
设置开机启动 
chkconfig nginx on

Centos7 安装nginx1.14的更多相关文章

  1. (转)CentOS7安装Nginx1.14.2

    原文:https://blog.csdn.net/zhyfyz/article/details/84957381 https://blog.csdn.net/q85795362/article/det ...

  2. CentOS7 安装nginx-1.14.0

    nginx源码包:http://nginx.org/en/download.html 1.安装gcc gcc是用来编译下载下来的nginx源码 yum install gcc-c++ 2.安装pcre ...

  3. Centos7安装Nginx1.14.0

    一.官网下载 http://nginx.org/en/download.html 版本说明: Nginx官网提供了三个类型的版本 Mainline version:Mainline 是 Nginx 目 ...

  4. 编译安装和apt安装Nginx1.14.0

    安装依赖 yum -y install gcc gcc-c++yum -y install zlib zlib-devel openssl openssl-devel pcre-devel 在Ubun ...

  5. centos7.6 安装nginx-1.14.2

    一.安装所需依赖环境 yum -y install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel 二.下载nginx官方源 ...

  6. CentOS 安装Nginx1.14.0

    原文地址:http://www.cnblogs.com/ascd-eg/p/9275441.html 一.安装所需环境   1.gcc 安装         yum install gcc-c++   ...

  7. ubuntu16.04源码编译安装nginx1.14.2

    1.下载nginx-1.14.2, 官网地址:nginx.org 2.解压nginx-1.14.2.tar.gz tar zxvf nginx-1.14.2.tar.gz 3.切到文件夹nginx-1 ...

  8. centos7.5下yum安装nginx-1.14.2

    rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm ...

  9. CentOS7安装Nginx-1.9.9+PHP5.6

    linux系统CentOS7 Nginx 下载地址http://nginx.org/en/download.html wget下载路径http://nginx.org/download/nginx-1 ...

随机推荐

  1. 【SQL Server 问题记录】A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible.

    本文涉及的相关问题,如果你的问题或需求有与下面所述相似之处,请阅读本文 A network-related or instance-specific error occurred while esta ...

  2. twitter ads_campaign management(图示)

    下载链接

  3. Git 与 GitHub 入门级

    今天我们来搞一下Git 这东西虽然没啥搞头儿,但是开发当中还必须得会用,谁让你我都是苦逼的开发呢~~~~ 一.下载与安装 这玩意简单,给你赋个图片,自己研究一下~~~~ 1.官网:https://gi ...

  4. 腾讯云服务器突然远程连不上(包含ssh,拒绝访问)

    版权声明:本文转载自  https://blog.csdn.net/Alexwu555/article/details/78448113, 暂时这样 , 以后再来整理.不太习惯不能直接贴截图啊 配置安 ...

  5. HBuild 连接苹果手机

    PC.苹果手机.数据线 1.在电脑端安装iTunes,安装完成之后提示重启. 2.用数据线连接苹果手机 PC 3.打开HBuild      菜单栏   -->  运行   -->  真机 ...

  6. [LeetCode]题53:Maximum Subarray

    Given an integer array nums, find the contiguous subarray (containing at least one number) which has ...

  7. 『TensorFlow』命令行参数解析

    argparse很强大,但是我们未必需要使用这么繁杂的东西,TensorFlow自己封装了一个简化版本的解析方式,实际上是对argparse的封装 脚本化调用tensorflow的标准范式: impo ...

  8. React文档(十三)思考React

    在我们的看来,React是使用js创建大型快速网站应用的首要方法.它在Facebook和Instagram的使用已经为我们展现了它自己. React的一个很好的地方就在于当你创建应用的时候它使你思考如 ...

  9. 【sparkSQL】SparkSession的认识

    https://www.cnblogs.com/zzhangyuhang/p/9039695.html https://www.jianshu.com/p/dea6a78b9dff 在Spark1.6 ...

  10. 精选!15 个必备的 VSCode 插件(前端类)

      精选!15 个必备的 VSCode 插件(前端类)   就像大多数 IDE 一样,VSCode 也有一个扩展和主题市场,包含了数以千计质量不同的插件.为了帮助大家挑选出值得下载的插件,我们针对性的 ...