编译安装 nginx-1.13.12

参考:http://www.linuxe.cn/post-168.html

1、在安装Nginx之前需要确保系统里已经安装好相关环境:pcre库(提供正则表达式和Rewrite模块的支持)、zlib库(提供Gzip压缩)、openssl(提供ssl支持),如果没有安装的话,用Yum来安装这些依赖环境即可,不需要额外编译:

yum  install  pcre  pcre-devel  openssl  openssl-devel  zlib  zlib-devel  -y

2、为Nginx创建好用户和组,后续编译会用上

groupadd nginx
useradd -s /sbin/nologin -g nginx nginx

3、配置、编译

./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-http_stub_status_module
make && make install

4、

4、编译安装完成后会在指定的安装目录创建以下目录:

prefix/sbin :  Nginx的启动脚本,也可以用该脚本做一系列检查工作
prefix/conf :  配置文件存放的目录
prefix/logs :  日志文件目录
prefix/html :  默认的网页文件存放目录

/usr/local/nginx/sbin/nginx  -t  #检查配置文件是否有错

/usr/local/nginx/sbin/nginx  -v       #查看Nginx版本

/usr/local/nginx/sbin/nginx  -V  #查看编译Nginx时的选项

3、编译安装Nginx,常用选项:

--prefix=path:设置Nginx的安装路径,不写的话默认是在/usr/local/nginx
--sbin-path=path:设置Nginx的可执行文件路径,默认路径是prefix/sbin/nginx
--conf-path=path:设置Nginx配置文件路径,默认路径是prefix/conf/nginx.conf
--pid-path=path:设置Nginx pid文件路径,默认路径是prefix/logs/nginx.pid
--error-log-path=path:设置错误日志存放路径,默认路径是prefix/logs/error.log
--http-log-path=path:设置访问日志存放路径,默认路径是prefix/logs/access.log
--user=name:设置运行Nginx的用户,默认用户是nobody
--group=name:设置运行Nginx的用户组,默认用户组是nobody
  --with-http_ssl_module             enable ngx_http_ssl_module
  --with-http_v2_module              enable ngx_http_v2_module
  --with-http_realip_module          enable ngx_http_realip_module
  --with-http_addition_module        enable ngx_http_addition_module
  --with-http_xslt_module            enable ngx_http_xslt_module
  --with-http_xslt_module=dynamic    enable dynamic ngx_http_xslt_module
  --with-http_image_filter_module    enable ngx_http_image_filter_module
  --with-http_image_filter_module=dynamic
                                     enable dynamic ngx_http_image_filter_module
  --with-http_geoip_module           enable ngx_http_geoip_module
  --with-http_geoip_module=dynamic   enable dynamic ngx_http_geoip_module
  --with-http_sub_module             enable ngx_http_sub_module
  --with-http_dav_module             enable ngx_http_dav_module
  --with-http_flv_module             enable ngx_http_flv_module
  --with-http_mp4_module             enable ngx_http_mp4_module
  --with-http_gunzip_module          enable ngx_http_gunzip_module
  --with-http_gzip_static_module     enable ngx_http_gzip_static_module
  --with-http_auth_request_module    enable ngx_http_auth_request_module
  --with-http_random_index_module    enable ngx_http_random_index_module
  --with-http_secure_link_module     enable ngx_http_secure_link_module
  --with-http_degradation_module     enable ngx_http_degradation_module
  --with-http_slice_module           enable ngx_http_slice_module
  --with-http_stub_status_module     enable ngx_http_stub_status_module

5、Nginx主配置文件(/usr/local/nginx/conf/nginx.conf)详解:
nginx的配置文件里有很多“{}”包括起来的标签,其中main和events都是全局性标签,

每个主机都配置在server标签里

在server标签里的location标签是做匹配

Location标签的匹配规则:
~      #区分大小写的正则匹配,
~*    #不区分大小写的正则匹配
^~    #禁止正则表达式匹配,当匹配到这里后停止其他所有匹配
=      #精确匹配

未做任何配置的配置文件:

#user  nobody;    #默认运行Nginx的用户名
worker_processes  1;    #开启的进程数,通常和cpu个数相等
events {
    worker_connections  1024;    #每个进程的并发数
}
http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;      #长连接超时时间为65秒

    server {
        listen       80;
        server_name  localhost;
        location / {
            root   html;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }

原文地址:https://www.cnblogs.com/linuxws/p/9099667.html

时间: 2024-07-31 19:15:20

编译安装 nginx-1.13.12的相关文章

RedHat 7 编译安装Nginx 1.12并配置WEB站点

一.安装环境 1.操作系统版本:Red Hat Enterprise Linux Server release 7.2 (Maipo) 2.Nginx版本:nginx-1.12.2.tar.gz 3.pcre版本:pcre-8.42.tar.gz 4.zlib版本:zlib-1.2.11.tar.gz 5.openssl版本:openssl-1.0.2l.tar.gz 二.安装说明 官网上关于Nginx的依赖包说明如下: 三.安装过程 1.安装gcc:yum install gcc-c++ -y

Centos7 编译安装 Nginx、MariaDB、PHP

前言 本文主要大致介绍CentOS 7下编译安装Nginx.MariaDB.PHP.面向有Linux基础且爱好钻研的朋友.技艺不精,疏漏再所难免,还望指正. 环境简介: 系统: CentOS 7,最小化安装 IP: 192.168.170.128 Nginx: 1.6.1 MariaDB: 5.5.39 PHP: 5.5.16 1.准备工作 1.1.系统硬件准备 尽管Linux能最大化发挥硬件资源,但RHEL/CentOS随着版本增加对最低硬件的配置也越来越高[1].RHEL7/CentOS最低

Centos7 编译安装 Nginx PHP Mariadb Memcached 扩展 ZendOpcache扩展 (实测 笔记 Centos 7.0 + Mariadb 10.1.9 + Nginx 1.9.9 + PHP 7.0.0)

环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7-x86_64-Minimal-1503-01.iso 安装步骤: 1.准备 1.1 设置静态IP.DNS地址(网络设备名称有可能不一样,这里是eno16780032,如使用DHCP获取动态IP,可忽略) [[email protected] ~]# vi /etc/sysconfig/network-scripts/ifcfg-eno16780032 找到BOOTPROTO,并且修

centos7下编译安装nginx并实现日志轮替

centos7编译安装nginx: 首先确保系统上存在编译安装使用的必要工具运行:  # yum groupinstall "development tools" "server platform development" 1 下载PCRE version 4.4 - 8.40 (ngx_http_rewrite_module模块需要)    # wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/p

开发人员学Linux(5):CentOS7编译安装Nginx并搭建Tomcat负载均衡环境

1.前言在上一篇讲述了JMeter的使用,在本篇就可以应用得上了.本篇将讲述如何编译安装Nginx并利用前面的介绍搭建一个负载均衡测试环境.2.软件准备Nginx-1.12.0,下载地址:https://nginx.org/download/nginx-1.12.0.tar.gzTomcat8(本系列已介绍过如何下载和安装)JMeter(本系列已介绍过如何下载和使用)注:VirtualBox宿主机IP为"192.168.60.16,虚拟机IP为:192.168.60.198,虚拟机通过桥接方式接

CentOS6.6 32位 Minimal版本纯编译安装Nginx Mysql PHP Memcached

CentOS是红帽发行的免费的稳定Linux版本,在企业服务器应用中都会选用Minimal版本,因为Minimal是CentOS"最纯洁"的服务器系统,因为Minimal版本连vim编辑器都需要自己安装,Minimal组件最少,无桌面,扩展灵活,非常适合做服务器. 1.配置网卡 Minimal版本的CentOS被安装后,网卡驱动默认是down状态,需要手动激活,在连接好网线后需要执行命令: [[email protected] soft]# vi /etc/sysconfig/netw

在CentOS上编译安装Nginx+实验环境搭建+测试

0.说明 Nginx作为一款优秀的Web Server软件同时也是一款优秀的负载均衡或前端反向代理.缓存服务软件,很有必要搭建实验环境来对其进行学习. 1.实验环境 本次实验的测试环境使用的宿主机操作系统为Windows 7,在Vmware虚拟机安装CentOS 6.5,说明如下: 宿主机操作系统Windows 7 虚拟机安装的操作系统CentOS 6.5 虚拟机操作系统上网方式NAT 而当使用NAT的方式进行上网时虚拟机.宿主机之间的网络连接关系可如下所示: 关于为什么网络拓扑结构是这样的,这

centos 6.3 编译安装 nginx +mysql + php

一篇文章是对另一篇文章的整理,作为记录收藏 1,配置防火墙,开启80端口.3306端口 配置iptables,开启80端口.3306端口 vi /etc/sysconfig/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT #允许80端口通过防火墙 -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT #允许3306端口

CentOS 6.5 编译安装Nginx

Nginx Nginx("enginex") 是一个高性能的 HTTP 和反向代理服务器,也是一个 IMAP/POP3/SMTP代理服务器. Nginx 是由Igor Sysoev为俄罗斯访问量第二的Rambler.ru站点开发的,它已经在该站点运行超过四年多了.Igor 将源代码以类BSD许可证的形式发布.自Nginx 发布四年来,Nginx 已经因为它的稳定性.丰富的功能集.示例配置文件和低系统资源的消耗而闻名了.目前国内各大门户网站已经部署了Nginx,如新浪.网易.腾讯等:国内

编译安装nginx出现报错,以及启动nginx服务时80端口被占用怎么解决?

1.准备基础环境[[email protected] ~]# yum -y install gcc gcc-c++ make wget 2.解压源码包,进入目录[[email protected] ~]# tar xf nginx-1.12.2.tar.gz[[email protected] ~]# cd nginx-1.12.2[[email protected] nginx-1.12.2]# 3.配置相关的选项,并生产Makefile[[email protected] nginx-1.1