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. filter防止xxs攻击

    什么是XSS攻击? XSS攻击使用Javascript脚本注入进行攻击 例如在表单中注入: <script>location.href='http://www.itmayiedu.com' ...

  2. linux 环境下tomcat中部署jfinal项目

    tomcat中部署jfinal项目 问题现象如下图 问题描述: 我在自己的windows7系统上tomcat下面跑这个项目没有任何问题吗,但是当我把项目上传到linux服务器上的tomcatwebap ...

  3. spring boot +Thymeleaf+mybatis 集成通用PageHelper,做分页

    controller: /**  * 分页查询用户  * @param request  * @param response  * @return  * @throws Exception  */ @ ...

  4. aspectj 与 spring 自定义注解

    ** * ErrorCode: * * @author yangzhenlong * @since 2016/7/21 */ @Target({ElementType.METHOD}) @Retent ...

  5. sharepoint_study_12

    描述:SharePoint新建Web应用程序时提示如下错误: 解决: 1. Go to IIS 2. Select the DefaultAppPool and Go to the Advanced ...

  6. visual studio 2013 error: Page '312e8a59-2712-48a1-863e-0ef4e67961fc' not found.

    In order to resolve this error do the following : Open Developer Command Prompt for VS 2013 as “Run ...

  7. poj3020 建信号塔(匈牙利算法 最小覆盖边集)

    Antenna Placement Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10518   Accepted: 518 ...

  8. 设置Linux shell超时自动退出

    Linux shell,一般默认情况下是不会超时退出的,但是有的时候我们想要让它在多少分钟后没有操作自动退出终端(听起来有点像windows多少分钟后自动锁屏一样).我们可以通过设置来实现这一功能. ...

  9. spring bean name生成规则

    现象: PVService PVServiceImpl ===>名称就是PVServiceImpl, 首字母没有小写 PageViewServiceImpl ==>名称是pageViewS ...

  10. Jenkins安全配置详解

    一.进入安全配置界面 首页后点击进入系统管理(Manage Jenkins) ——下拉下方看到安全配置(Configure Global Security) ——进入安全配置界面 二,详解安全配置的选 ...