安装依赖

yum -y install gcc gcc-c++yum -y install zlib zlib-devel openssl openssl-devel pcre-devel

在Ubuntu 下, 对应openssl-devel的包是 libssl-dev

建立用户及用户组

groupadd -r nginx
# -r 表示创建的是系统组
useradd -s /sbin/nologin -g nginx -r nginx
# -r 表示创建的是系统用户
id nginx
# 即使用其他用户启动nginx, 也必须创建nginx用户和用户组, 否则会出现 nginx: [emerg] getpwnam("nginx") failed 错误

编译和安装

./configure --prefix=/opt/nginx/nginx-1.14. --user=nginx --group=nginx --with-http_gzip_static_module --with-pcre --with-http_ssl_module --with-http_flv_module --with-stream --with-stream_ssl_module --with-http_stub_status_module
make
make install

建立latest目录和软链, 方便将来替换为新版本

cd /opt/nginx/
ln -s nginx-1.14. latest

配置

将nginx加入系统服务

cd /lib/systemd/system/
vi nginx.service # 内容 [Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target [Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStartPre=/opt/nginx/latest/sbin/nginx -t -c /opt/nginx/latest/conf/nginx.conf
ExecStart=/opt/nginx/latest/sbin/nginx
ExecReload=/opt/nginx/latest/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true [Install]
WantedBy=multi-user.target # 内容结束 systemctl enable nginx.service

打开端口启动服务

firewall-cmd --zone=public --list-all
firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --reload # 启动nginx
systemctl start nginx

Ubuntu18.04下apt安装Nginx1.14.0

Ubuntu18.04下默认的nginx版本就是1.14.0, 可以直接通过 sudo apt install nginx 安装. 安装后会自动加入service并启动, 可以通过 sudo systemctl list-unit-files 检查

默认的配置文件位于 /etc/nginx/nginx.conf, 这是给Ubuntu定制的配置文件, 基础配置部分, 会加载 /etc/nginx/modules-enabled/*.conf , 在 http 部分, 会自动加载 include /etc/nginx/conf.d/*.conf 和 include /etc/nginx/sites-enabled/*, 这样方便用户通过 modules-enabled, modules-available 和 sites-enabled, sites-available 来管理可用站点.

从这里开始配置就和编译安装的一样了.

编译安装和apt安装Nginx1.14.0的更多相关文章

  1. CentOS 安装Nginx1.14.0

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

  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. nginx1.14.0下载、安装、启动

    nginx1.14.0下载及安装 wget http://nginx.org/download/nginx-1.14.0.tar.gztar -zxvf nginx-1.14.0.tar.gzcd n ...

  5. elementaryos5安装mysql5.7、php7.2、nginx1.14.0

    一.mysql5.7 安装mysql5.7: sudo apt-get install mysql-server-5.7 查看安装的mysql版本: mysql -V 5.7版本mysql安装过程中以 ...

  6. 安装 error: Microsoft Visual C++ 14.0 is required 解决方案

    最近写的项目需要用到Python的第三方库,比如:mmh3, pyshark等等,而直接pip install ... 会报错:error: Microsoft Visual C++ 14.0 is ...

  7. Nginx1.14.0+ModSecurity实现简单的WAF

    一.编译安装Nginx 1.安装依赖环境 $ yum -y install gcc-c++ flex bison yajl yajl-devel curl-devel curl GeoIP-devel ...

  8. nginx1.14.0版本https加密配置

    修改host文件,为最后访问域名准备 C:\Windows\System32\drivers\etc host文件目录192.168.10.140 www.joyce.com 在最后添加这个自定义域名 ...

  9. nginx: [emerg] unknown directive "聽" in D:\software03\GitSpace\cms\nginx-1.14.0/conf/nginx.conf:36

    nginx: [emerg] unknown directive "聽" in D:\software03\GitSpace\cms\nginx-1.14.0/conf/nginx ...

随机推荐

  1. JS(JavaScript)的初了解(更新中···)

    1.js介绍 Js全称叫javascript,但不是java,他不仅是是一门前台语言,经过发展,现在也是一门后台语言:而java是后台语言. Js作者是布兰登艾奇. 前台语言:运行在客户端的 后台语言 ...

  2. 逐步构建循环神经网络 RNN

    rnn.utils.py import numpy as np def softmax(x): e_x = np.exp(x - np.max(x)) return e_x / e_x.sum(axi ...

  3. 使用C#加密及解密字符串

    using System; using System.IO; using System.Security.Cryptography; using System.Text; namespace Util ...

  4. SAP Fiori Client

    iPhone资源->iPhone商务软件 SAP Fiori Client 固件要求:需要 iOS 9.0 或更高版本.与 iPhone.iPad 和 iPod touch 兼容. 利用适用于 ...

  5. HDFS初次编程

    hadoop是用Java语言实现的开源软件框架,可以支持多种语言,我学习的时候用得自然就是Java了. 在开始编程之前需要做一些配置工作: Hadoop开发:Hadoop为HDFS和Mapreduce ...

  6. spark streaming 整合kafka(二)

    转载:https://www.iteblog.com/archives/1326.html 和基于Receiver接收数据不一样,这种方式定期地从Kafka的topic+partition中查询最新的 ...

  7. 通过RequestContextHolder直接获取HttpServletRequest对象

    问题 朋友遇到一个问题:他想在Service方法中使用HttpServletRequest的API,但是又不想把HttpServletRequest对象当作这个Service方法的参数传过来,原因是这 ...

  8. 超轻量级Json框架SmartObject

    最近我在codeplex上发了一个项目SmartObject(基于framework4.5,目前是1.0版本).用法如下: // HowToUse using Spider.Data; //json ...

  9. ios10兼容问题

    var lastTouchEnd = 0; document.addEventListener('touchend', function(event) { var now = (new Date()) ...

  10. 【网址】.net/dot net可再发行组件下载哪家强

    微软开发者文档中有篇文章包含了.net/dot net各版本下载全家福: https://msdn.microsoft.com/zh-cn/library/5a4x27ek.aspx 安全可靠.没有三 ...