Linux绿色版Nginx

背景

​ Nginx想必大家都比较熟悉了,这里就不做过多的诉述它的强大和用处了。上次在开发时,产品提出了一个需求:在不同网段的实现请求的转发和响应,最终讨论使用 nginx+autossh 做成一个小安装包 + 代码的形式实现这一功能(这里不具体展开这个需求,主要描述一下怎么制作一个绿色版、解压即用的nginx);由于我在上一家公司用到的nginx,就是解压即用的;所以准备直接拿一个zip压缩包,来进行配置,但是问了一下这边同事,发现这边的nginx是安装版本的,即是下载安装包,然后安装进 /usr/local/nginx ;但是大伙都知道,很多项目现场部署的服务器都是没有外网的,并且可能存在相关Linux依赖都不齐全 甚至 root 用户都没权限的情况,所以让现场直接去源码编译安装有时是很不现实的,所以,本文就是为了制作一个绿色版、任意用户、解压即用的nginx。

准备
  • Linux(虚拟机/服务器)

  • Linux目录结构

    |-------nginx (要制作的nginx的空目录)

    |-------nginx-src(存在nginx源码、依赖等)

    ​ |----nginx-1.16.1

    ​ |----openssl-1.0.2s

    ​ |----pcre-8.43

    ​ |----zlib-1.2.11

  • nginx-src目录下载nginx源码及相关依赖(Linux上没wget,可以本地直接访问网址下载后上传)

    wget https://www.openssl.org/source/openssl-1.0.2s.tar.gz
    wget https://ftp.exim.org/pub/pcre/pcre-8.43.tar.gz
    wget https://zlib.net/zlib-1.2.11.tar.gz
    wget http://nginx.org/download/nginx-1.16.1.tar.gz解压缩
    tar -zxvf nginx-1.16.1.tar.gz
    tar -zxvf openssl-1.0.2s.tar.gz
    tar -zxvf pcre-8.43.tar.gz
    tar -zxvf zlib-1.2.11.tar.gz
    

    准备完成后文件目录如下nginx为空,nginx-src为nginx源码和依赖

    [root@localhost nginx-green]# pwd
    /root/nginx-green
    [root@localhost nginx-green]# ll
    total 0
    drwxr-xr-x 6 root root  54 Jan 17 16:35 nginx
    drwxr-xr-x 6 root root 191 Jan 17 16:35 nginx-src
    [root@localhost nginx-green]# cd nginx-src/
    [root@localhost nginx-src]# ll
    total 8892
    drwxr-xr-x  9 root root     186 Jan 17 16:35 nginx-1.16.1
    -rw-r--r--  1 root root 1032630 Jan 17 16:35 nginx-1.16.1.tar.gz
    drwxr-xr-x 21 root root    4096 Jan 17 16:35 openssl-1.0.2s
    -rw-r--r--  1 root root 5349149 Jan 17 16:35 openssl-1.0.2s.tar.gz
    drwxr-xr-x  9 root root    8192 Jan 17 16:35 pcre-8.43
    -rw-r--r--  1 root root 2085854 Jan 17 16:35 pcre-8.43 .tar.gz
    drwxr-xr-x 14 root root    4096 Jan 17 16:35 zlib-1.2.11
    -rw-r--r--  1 root root  607698 Jan 17 16:35 zlib-1.2.11.tar.gz
    
配置及安装
配置
./configure \--with-openssl=../openssl-1.0.2s \--with-pcre=../pcre-8.43 \--with-zlib=../zlib-1.2.11 \--with-pcre-jit --user=root \--prefix=../../nginx \--with-http_ssl_module \--with-http_v2_module# 出现以下提示表示配置完成
# 如果有ERROR需要手动解决 :
# 参考链接:https://www.klavor.com/dev/20190724-586.htmlConfiguration summary+ using PCRE library: ../pcre-8.43+ using OpenSSL library: ../openssl-1.0.2s+ using zlib library: ../zlib-1.2.11nginx path prefix: "../../nginx"nginx binary file: "../../nginx/sbin/nginx"nginx modules path: "../../nginx/modules"nginx configuration prefix: "../../nginx/conf"nginx configuration file: "../../nginx/conf/nginx.conf"nginx pid file: "../../nginx/logs/nginx.pid"nginx error log file: "../../nginx/logs/error.log"nginx http access log file: "../../nginx/logs/access.log"nginx http client request body temporary files: "client_body_temp"nginx http proxy temporary files: "proxy_temp"nginx http fastcgi temporary files: "fastcgi_temp"nginx http uwsgi temporary files: "uwsgi_temp"nginx http scgi temporary files: "scgi_temp"

注意:前3项为安装时指定依赖的位置,这里直接使用我们自己下载的依赖,因为系统的依赖可能会因为版本不符或者不存在会导致配置失败;其中最重要的配置是 –prefix=…/…/nginx,这个配置指定了我们待会编译安装的nginx的保存目录,并且,…/…/nginx**这个路径在编译安装完成后,在后续启动的会引用这个配置(这里有投机取巧嫌疑,如果不是***…/…/nginx***的话,会在nginx启动时读取不到正确的目录,需要手动指定绝对路径,所以这里强烈!!!建议设置成***…/…/nginx***)。

安装
make
make install
打包

​ 至此绿色版本nginx已经制作完成,直接把nginx文件夹打包迁移置其他环境解压即用了。

[root@localhost nginx-green]# pwd
/root/nginx-green
[root@localhost nginx-green]# ll
total 0
drwxr-xr-x 6 root root  54 Jan 17 16:35 nginx
drwxr-xr-x 6 root root 191 Jan 17 16:35 nginx-src
[root@localhost nginx-green]# zip -r nginx.zip nginx
.
.
.
[root@localhost nginx-green]# ll
total 4328
drwxr-xr-x 6 root root      54 Jan 17 16:35 nginx
drwxr-xr-x 6 root root     191 Jan 17 16:35 nginx-src
-rw-r--r-- 1 root root 4431284 Jan 17 17:01 nginx.zip
下载链接

https://github.com/wuzefang/nginx-green

Linux绿色版Nginx相关推荐

  1. Linux制作绿色版nginx

    在docker化的部署方式中,时常需要一个轻量化的nginx系统,主要用于实现动静分离,实现路由转发,或部署静态资源(可类比web容器). 轻量化的nginx,可以与静态资源一起,或接口服务一起,方便 ...

  2. CentOs7 安装绿色版Nginx并配置开机启动

    1.下载nginx 下载地址: http://nginx.org/en/download.html 2.安装编译需要的包支持 yum -y install gcc zlib zlib-devel pc ...

  3. wine on ubuntu linux, and source insight 绿色版的安装

    (附: 建议安装 playonlinux, 它是一个以wine为基础的,使用 Python 写成的图形化前端,主要用来辅助 Wine 在 Linux 中安装面向 Windows 平台的程序和游戏,如 ...

  4. Linux下安装nginx (tar解压版安装) nginx1.16.1

    https://blog.csdn.net/qq_40431100/article/details/104729504 Linux下安装nginx (tar解压版安装) nginx1.16.1 Jkc ...

  5. 使用FlashFXP V3.8烈火汉化绿色版软件连接Linux

    使用FlashFXP V3.8烈火汉化绿色版软件连接Linux 单击右上角的小闪电图标: 特别注意:出于安全考虑,FTP默认禁止使用root账号登陆Linux主机,必须使用除root用户以外的其他用户 ...

  6. linux安装nginx1.14.0,Ubuntu 14.04 安装最新稳定版Nginx 1.6.0

    Ubuntu14.04默认安装的是Nginx 1.4.6 如果已经安装,请先卸载 sudo apt-get remove nginx 最新的稳定版Nginx 1.6.0在ubuntuupdates p ...

  7. 网易云音乐Linux绿色免安装版For CentOS

    网易云音乐Linux绿色免安装版For CentOS 本软件修改自网易云音乐,版权归原作者所有. 修改后特点: 绿色无公害,复制即可用 免安装,不用担心复杂的安装过程 制作过程中已经解决组件问题 *制 ...

  8. mysql 绿色版远程访问_【Linux】MySQL解压版安装及允许远程访问

    安装环境/工具 1.Linux( centOS 版) 2.mysql-5.6.31-linux-glibc2.5-x86_64.tar 安装步骤 1.下载mysql解压版(mysql-5.6.31-l ...

  9. linux下制作codeblocks绿色版,并集成devhelp

    Codeblocks更新到12.11了,可是软件中心还是10.01的.在codeblocks的官网找了一下发现了ubnutu的ppa, sudo apt-add-repository ppa:pasg ...

最新文章

  1. liunx 上get 不到url参数 java_thinkphp5.0 模板上直接获取url参数
  2. 原创数据结构算法Flash动画演示课件-Action Script(AS)脚本实现
  3. rust门卡有什么用_Rust能力养成之(10)用Cargo进行项目管理:扩展 调用与优化
  4. LibJson数据解析方法
  5. cad立面索引符号 规范_一套标准规范施工图包含哪些?13年深化设计师3分钟带你正确认知...
  6. Nginx快速搭建和基本使用
  7. JSON(1)--- 语法
  8. Java基础 -- 冒泡排序算法(带详细注释)
  9. kotlin的loop和Range、list和map
  10. Julia: find 和其它
  11. 零基础学习SQL Server(一)---查询语句在项目实例中的执行
  12. (java)word转html并提取word中的目录结构树生成到html页面中的左边树
  13. oracle detele,Oracle中,一个Delete操作的流程
  14. 【AI创新者】图森未来CTO侯晓迪:定义问题比解决问题更重要
  15. 离骚,屈原,名句翻译
  16. 天载网上炒股大盘缩量诱多
  17. 正态分布西格玛越大_6西格玛中正太分布包含什么?
  18. 【天梯赛】L2-039 清点代码库** (25 point(s))
  19. WPS格式转换成html代码
  20. 案例3-数据驱动测试-从excel导入数据

热门文章

  1. Android 平台通讯架构研究
  2. python十六进制和十进制互转
  3. 计算机学院贺凤,石家庄邮电职业技术学院
  4. css案例10——单行文本省略、多行省略
  5. python通关-集合操作方法详解
  6. 留守女子在家中身亡 2岁孙女7天无人照顾
  7. window.history.go(-1)和window.location.go(-1)区别
  8. 【Mysql学习笔记】count(1)、count(*)、count(id)和count(字段)
  9. 电力系统经济调度-入门版
  10. 【 办公类-03】 VS Python 大8班“运动场地”的周次安排。