nginx-1.12.2编译安装

  • 下载源码包
  • 安装
  • 安装后配置

下载源码包

下载地址:http://nginx.org/en/download.html

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


安装

创建nginx worker 用户

groupadd -r www
useradd -r -g www -s /sbin/nologin www
id www

安装前,安装编译环境及依赖包

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

编译选项

./configure \
--prefix=/usr/local/nginx-1.12.2 \
--conf-path=/usr/local/nginx-1.12.2/etc/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--user=www \
--group=www \
--with-compat \
--with-file-aio \
--with-threads \
--with-http_addition_module \
--with-http_auth_request_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_mp4_module \
--with-http_random_index_module \
--with-http_realip_module \
--with-http_secure_link_module \
--with-http_slice_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_v2_module \
--with-mail \
--with-mail_ssl_module \
--with-stream \
--with-stream_realip_module \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong \
--param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' \
--with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie' \ make
make install

安装后配置

创建 nginx-1.12.2 到 nginx的链接

ln -s /usr/local/nginx-1.12.2 /usr/local/nginx
ls -l |grep nginx

创建配置文件存放目录链接

ln -s /usr/local/nginx/etc /etc/nginx
ls -l /etc/|grep nginx
ls /etc/nginx/

配置nginx启动项

ln -s  /usr/local/nginx/sbin/nginx /usr/sbin/
ls -l /usr/sbin/ |grep nginx
nginx -V vim /usr/lib/systemd/system/nginx.service [Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target [Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID [Install]
WantedBy=multi-user.target

编辑配置文件

vim /etc/nginx/nginx.conf

user www;

mkdir -p /var/cache/nginx/client_temp   # 创建缓存目录

防火墙配置

firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --reload

启动 nginx,并设置开机启动

systemctl start nginx
systemctl enable nginx

测试

浏览器访问 ip地址

curl -I <ip>

安装配置nginx完成,之后还需要优化和配置虚拟主机。升级的时候,把新版本的安装目录链接到 /usr/local/nginx 上,再把配置文件拷贝到新版本的安装目录就 ok 了。

rm -f /usr/local/nginx   # 删除原来的链接
ln -s /usr/local/nginx-<version> /usr/local/nginx # 新建新版本的链接
\cp -r /usr/local/nginx-<old-version>/etc/* /usr/local/gninx/etc/ # 拷贝配置文件到新版本的相应目录下 nginx -V # 查看版本信息
systemctl restart nginx # 重启nginx服务

有疑惑之处请发邮件到下面的邮箱。

2017-11-6 by achxku@163.com

nginx-1.12.2编译安装指导的更多相关文章

  1. Deepin 15.4 编译安装 LNMP(PHP 5.6.31 + Nginx 1.12.1 + MySQL 5.6.36)

    先查看先前的文章:Ubuntu 14 编译安装 PHP 5.4.45 + Nginx 1.4.7 + MySQL 5.6.26 笔记 编译 Nginx #安装依赖库 sudo apt-get -y i ...

  2. Nginx SPDY Pagespeed模块编译——加速网站载入

    在看<Web性能权威指南>的时候,看到了SPDY这货,于是便开始折腾起了这个了,也顺便把pagespeed加了进去. Nginx SPDY 引自百科~~ SPDY(读作“SPeeDY”)是 ...

  3. 对<< ubuntu 12.04编译安装linux-3.6.10内核笔记>>的修正

    前题: 在前几个月的时候,写了一篇笔记,说的是kernel compile的事情,当时经验不足,虽说编译过了,但有些地方写的有错误--因为当时的理解是有错误的.今天一一更正,记录如下: 前文笔记链接: ...

  4. WordPress 4.8 安装配置教程 (基于 centos 7.3, php 7.0, mysql 5.7.19, nginx 1.12.1)

    最近想要整个 blog,记录自己工作.学习中的点滴.Wordpress 自然是首选,因为内容才是关键,所以也就不怕别人说太 low.网上大部份都是讲 wordpress 配合 apache 的安装教程 ...

  5. MacOS Sierra10.12.4编译Android7.1.1源代码必须跳的坑

    简单介绍 下载Android7.1.1源代码花费了两天,编译整个源代码相同花费了2天,期间遇到无数个坑. 如今编译源代码,一旦中间遇到错误,则要又一次開始. 本文记录编译过程遇到的问题及解决方式,如有 ...

  6. 新安装和已安装nginx如何添加未编译安装模块/补丁

    新安装和已安装nginx如何添加未编译安装模块/补丁 --http://www.apelearn.com/bbs/forum.php?mod=viewthread&tid=10485& ...

  7. F-stack及其Nginx、redis的编译安装

    F-stack简介 F-stack粘合了dpdk.用户态协议栈和nginx.redis,弥补了dpdk没有协议栈的不足,并用nginx.redis提供了一个调用应用程序的接口. Quick Start ...

  8. 在VS13上编译通过的代码放在12上编译-错误:l __dtoui3 referenced in function _event_debug_map_HT_GROW

    在VS13上编译通过的代码放在12上编译 遇到错误:l __dtoui3 referenced in function _event_debug_map_HT_GROW 1>------ 已启动 ...

  9. nginx 升级为最新版 nginx -1.12.0

    标签:nginx 公司目前使用的nginx版本比较低(nginx-1.0.12),请网络安全公司做了一下“远程安全评估”,发现有下列漏洞: nginx URI处理安全限制绕过漏洞(CVE-2013-4 ...

随机推荐

  1. 16.Shortest Unsorted Continuous Subarray(最短未排序子数组)

    Level:   Easy 题目描述: Given an integer array, you need to find one continuous subarray that if you onl ...

  2. LUNA16数据集(一)简介

    LUNA16,全称Lung Nodule Analysis 16,是16年推出的一个肺部结节检测数据集,旨在作为评估各种CAD(computer aid detection计算机辅助检测系统)的ban ...

  3. DataGrip 使用--方法-..../

    tip1: 关键字 自动 大写--

  4. Gym - 101615J Grid Coloring DP 2017-2018 ACM-ICPC Pacific Northwest Regional Contest (Div. 1)

    题目传送门 题目大意: 给出n*m的网格,有红蓝两种颜色,每个格子都必须被染色,当一个格子被染成蓝色后,这个格子左上方的一块都必须被染成蓝色,问最后的方案数量. 思路: 按照题目条件,如果有一个格子被 ...

  5. 2015苏州大学ACM-ICPC集训队选拔赛(2)1004

    草爷要的数 Problem Description 今天校队队员们准备放松一下,我们队就准备选一些数字玩,然而每个人喜欢的数字是不同的,刻盘喜欢x(1<=x<=1^9),凯凯喜欢y(1&l ...

  6. 从M进制转换为N进制

    /// <summary> /// 从M进制转换为N进制 /// </summary> internal class MBase2NBase { /// <summary ...

  7. java反射之一

    public static void main(String[] args) { try { Class cla = Class.forName("com.money.test.Employ ...

  8. Alibaba Java Coding Guidelines 安装(eclipse)并简单使用

    源码地址:https://github.com/alibaba/p3c 1.安装 第1步.help >> Instakll New Software... 第2步.在Work with中输 ...

  9. 练习五十六:for循环

    某个公司采用公用电话传递数据,数据是四位的整数,在传递过程中是加密的,加密规则如下:每位数字都加上5,然后用和除以10的余数代替该数字,再将第一位和第四位交换,第二位和第三位交换 方法一: def o ...

  10. 转 python 的常用函数replace, split(),enumerate() 函数

    1.execmd = "su - " + ou + " -c 'sqlplus / as sysdba << EOF\n " + execmd3 + ...