Ubuntu 20.04使用源码安装nginx 1.14.0

nginx安装及使用(详细版)是一篇参考博文。

http://nginx.org/download/可以选择下载源码的版本。

在这里插入图片描述

sudo wget http://nginx.org/download/nginx-1.14.0.tar.gz下载源代码。
在这里插入图片描述

sudo tar xzf nginx-1.14.0.tar.gz进行解压。
在这里插入图片描述

cd nginx-1.14.0进入到源代码目录里边。
在这里插入图片描述

ls -l看一下当前源码目录里边有什么文件。
在这里插入图片描述

ls -l auto可以看一下auto目录有什么文件,而在auto目录里有cc目录(用于编译),lib目录(存放库),os目录(对操作系统的判断)等。
在这里插入图片描述

nginx-1.14.0目录里边CHANGES文件就是写明了当前版本中有什么改变,sudo wc -l CHANGES可以看到此文件中有8069行。
在这里插入图片描述
head -n 12 CHANGES可以看一下前12行内容。
在这里插入图片描述

CHANGES.ru是俄罗斯语的CHANGES文件。

conf目录里边是配置文件,ls -l conf可以看一下配置目录的配置文件。
在这里插入图片描述

configure可执行文件有两个作用:

1.选定编译特性;
2.检查编译环境,是否有编译时所需的库,以及库的版本是否满足编译的需要等。

在这里插入图片描述

contrib目录里边有一些脚本和工具,典型的是vim高亮工具。
在这里插入图片描述

sudo vim conf/nginx.conf打开文件之后可以看到毫无高亮。
在这里插入图片描述

输入:q!
在这里插入图片描述

然后再按Enter之后退出vim
在这里插入图片描述

sudo mkdir ~/.vim/在当前用户的家目录下创建一个.vim目录,然后sudo cp -r contrib/vim/* ~/.vim/contrib/vim/目录下所有的文件都转移到~/.vim/目录下边。
在这里插入图片描述

sudo mkdir /nginx在根目录下创建一个nginx的目录。
在这里插入图片描述

sudo ./configure --prefix=/nginx指定安装目录为/nginx,然后开始检查编译环境。
在这里插入图片描述

完成之后发现报错如下:

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

在这里插入图片描述
《./configure: error: the HTTP rewrite module requires the PCRE library. You can either disable the mo》是解决方法参考的博客。

sudo apt-get install libpcre3 libpcre3-dev安装依赖包,发现报错如下:

Reading package lists... Done
Building dependency tree
Reading state information... Done
Package libpcre3-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another sourceE: Package 'libpcre3-dev' has no installation candidate

在这里插入图片描述

我这里执行sudo apt update
在这里插入图片描述

完成之后如下图:
在这里插入图片描述

sudo apt install -y libpcre3 libpcre3-dev安装依赖包。
在这里插入图片描述

sudo ./configure --prefix=/nginx指定安装目录为/nginx,然后再次开始检查编译环境。
在这里插入图片描述

完成之后如下图:
在这里插入图片描述

sudo make进行编译。
在这里插入图片描述

发现报错如下:

src/os/unix/ngx_user.c: In function ‘ngx_libc_crypt’:
src/os/unix/ngx_user.c:26:7: error: ‘struct crypt_data’ has no member named ‘current_salt’26 |     cd.current_salt[0] = ~salt[0];|       ^
make[1]: *** [objs/Makefile:781: objs/src/os/unix/ngx_user.o] Error 1
make[1]: Leaving directory '/root/nginx-1.14.0'
make: *** [Makefile:8: build] Error 2

在这里插入图片描述

《linux异常(四):nginx1.6 |struct crypt_data’ has no member named ‘current_salt’ |[objs/Makefile:473》是我解决问题参考的博客。

sed -i 's#cd.current_salt\[0\] = ~salt\[0\]\;#/* cd.current_salt\[0\] = ~salt\[0\]\; */#' src/os/unix/ngx_user.ccd.current_salt[0] = ~salt[0];注释掉。
在这里插入图片描述

sudo make再次编译。
在这里插入图片描述

报错如下:

src/http/ngx_http_script.c: In function ‘ngx_http_script_add_copy_code’:
src/http/ngx_http_script.c:698:18: error: cast between incompatible function types from ‘size_t (*)(ngx_http_script_engine_t *){aka ‘long unsigned int (*)(struct <anonymous> *)} to ‘void (*)(ngx_http_script_engine_t *){aka ‘void (*)(struct <anonymous> *)} [-Werror=cast-function-type]698 |     code->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;|                  ^
src/http/ngx_http_script.c: In function ‘ngx_http_script_add_var_code’:
src/http/ngx_http_script.c:787:18: error: cast between incompatible function types from ‘size_t (*)(ngx_http_script_engine_t *){aka ‘long unsigned int (*)(struct <anonymous> *)} to ‘void (*)(ngx_http_script_engine_t *){aka ‘void (*)(struct <anonymous> *)} [-Werror=cast-function-type]787 |     code->code = (ngx_http_script_code_pt) ngx_http_script_copy_var_len_code;|                  ^
src/http/ngx_http_script.c: In function ‘ngx_http_script_add_capture_code’:
src/http/ngx_http_script.c:1181:18: error: cast between incompatible function types from ‘size_t (*)(ngx_http_script_engine_t *){aka ‘long unsigned int (*)(struct <anonymous> *)} to ‘void (*)(ngx_http_script_engine_t *){aka ‘void (*)(struct <anonymous> *)} [-Werror=cast-function-type]1181 |     code->code = (ngx_http_script_code_pt)|                  ^
src/http/ngx_http_script.c: In function ‘ngx_http_script_add_full_name_code’:
src/http/ngx_http_script.c:1296:18: error: cast between incompatible function types from ‘size_t (*)(ngx_http_script_engine_t *){aka ‘long unsigned int (*)(struct <anonymous> *)} to ‘void (*)(ngx_http_script_engine_t *){aka ‘void (*)(struct <anonymous> *)} [-Werror=cast-function-type]1296 |     code->code = (ngx_http_script_code_pt) ngx_http_script_full_name_len_code;|                  ^
cc1: all warnings being treated as errors
make[1]: *** [objs/Makefile:886: objs/src/http/ngx_http_script.o] Error 1
make[1]: Leaving directory '/root/nginx-1.14.0'
make: *** [Makefile:8: build] Error 2

在这里插入图片描述

参考《Nginx安装时make部分报错解决 类型装换异常 不兼容》解决。

sed -i 's/-Werror//g' objs/Makefile-Werror去掉。
在这里插入图片描述

sudo make再次编译。
在这里插入图片描述

完成之后如下图:
在这里插入图片描述

sudo make install进行安装。
在这里插入图片描述

sudo vim /etc/profilePATH=${PATH}:/nginx/sbin添加到最后一行。
在这里插入图片描述

source /etc/profile使配置生效。
在这里插入图片描述

nginx -v显示nginx version: nginx/1.14.0就是安装成功了。
在这里插入图片描述

此文章为10月Day 7学习笔记,内容来源于极客时间《Nginx 核心知识 150 讲》

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/98663.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

nginx-proxy反向代理缓存

介绍&#xff1a; 反向代理缓存&#xff0c;类似于动静分离&#xff0c;即通过nginx代理服务器根据客户端发送的url请求&#xff0c;去后台服务器获取数据&#xff0c;将静态数据缓存到nginx代理服务器上&#xff0c;并配置有过期时间&#xff0c;当客户端下次以相同的url请求…

[鹏城杯 2022]简单的php - 无数字字母RCE+取反【*】

[鹏城杯 2022]简单的php 一、解题流程二、思考总结 题目代码&#xff1a; <?php show_source(__FILE__);$code $_GET[code];if(strlen($code) > 80 or preg_match(/[A-Za-z0-9]|\|"||\ |,|\.|-|\||\/|\\|<|>|\$|\?|\^|&|\|/is,$code)){die( Hello);}e…

专业的园林景观设计师到底需要学什么?优漫动游

随着可持续发展科学发展观的普及与重视&#xff0c;园林生态城市逐渐成为生活在钢筋水泥中人们的理想目标。而想要达到人与自然生态和谐相处的生活要求&#xff0c;正需要运用到园林景观设计学相关专业知识。 专业的园林景观设计师到底需要学什么&#xff1f; 庞大的社会需…

时序预测 | MATLAB实现ICEEMDAN-IMPA-LSTM时间序列预测

时序预测 | MATLAB实现ICEEMDAN-IMPA-LSTM时间序列预测 目录 时序预测 | MATLAB实现ICEEMDAN-IMPA-LSTM时间序列预测预测效果基本介绍程序设计参考资料 预测效果 基本介绍 ICEEMDAN-IMPA-LSTM功率/风速预测 基于改进的自适应经验模态分解改进海洋捕食者算法长短期记忆网络时间序…

leetcode - 2038. Remove Colored Pieces if Both Neighbors are the Same Color

Description There are n pieces arranged in a line, and each piece is colored either by ‘A’ or by ‘B’. You are given a string colors of length n where colors[i] is the color of the ith piece. Alice and Bob are playing a game where they take alternatin…

C++统一初始化和初始化列表

一直对C初始化使用圆括号和花括号的区别有所疑惑&#xff0c;参考书籍和博客简单总结一下 文章目录 常见的初始化操作统一初始化(Uniform Initialization)初始化列表(Initializer Lists) 常见的初始化操作 对于一个基础数据类型进行初始化&#xff0c;比如 int&#xff1a; i…

深度学习基础知识 nn.Sequential | nn.ModuleList | nn.ModuleDict

深度学习基础知识 nn.Sequential &#xff5c; nn.ModuleList &#xff5c; nn.ModuleDict 1、nn.Sequential 、 nn.ModuleList 、 nn.ModuleDict 类都继承自 Module 类。2、nn.Sequential、nn.ModuleList 和 nn.ModuleDict语法3、Sequential 、ModuleDict、 ModuleList 的区别…

【多线程进阶】线程安全的集合类

文章目录 前言1. 多线程环境使用 ArrayList2. 多线程环境使用队列3. 多线程环境使用哈希表3.1 HashTable3.2 ConcurrentHashMap 总结 前言 本文主要讲解 Java 线程安全的集合类, 在之前学习过的集合类中, 只有 Vector, Stack, HashTable, 是线程安全的, 因为在他们的关键方法中…

vue项目中使用rem替换px-使用方法-03-使用插件

使用场景:有适配pc端改为适配pc端和移动端,使用2套css App.vue created: function () {if(document.documentElement.clientWidth > 640){require(./style/index.:);this.plaform = pc;}else{require(./style/mobile.scss);this.plaform = mobile;} } 注意: 为2套css分…

axios登录,登出接口的简单封装步骤详解!

目录 总结一、步骤1.安装Axios&#xff1a;2.axios对象封装3.请求api封装4.使用pinia临时库保存响应信息&#xff08;按需求用&#xff09;5.最后&#xff0c;在组件中使用&#xff01; 总结 封装axios对象&#xff0c;编写公共请求代码、添加拦截逻辑、然后分层实现axios请求…

anaconda安装及配置+pytorch安装与配置(自用笔记)

anaconda安装及配置 1、anaconda官网下载安装包 下载好后进行安装 2、anaconda安装地址(记住安装路径)&#xff1a; 3、配置环境变量 打开anaconda prompt: 输入命令conda list: 可以看到安装好的很多包&#xff01; 至此anaconda配置完成。 PyTorch的安装与配置 使用con…

android 代码设置静态Ip地址的方法

在Android中&#xff0c;可以使用以下代码示例来设置静态IP地址&#xff1a; import android.content.Context import android.net.ConnectivityManager import android.net.LinkAddress import android.net.Network import android.net.NetworkCapabilities import android.ne…

分库分表理论总结

一、概述 分库分表是在面对高并发、海量数量时常见的数据库层面的解决方案。通过把数据分散到不同的数据库中&#xff0c;使得单一数据库的数据量变小来缓解单一数据库的性能问题&#xff0c;从而达到提升数据库性能的目的。比如&#xff1a;将电商数据库拆分为若干独立的数据…

安装配置deep learning开发环境

1. 下载安装anacondahttps://www.anaconda.com/download-success vim ~/.condarcchannels: - bioconda - https://mirrors.ustc.edu.cn/anaconda/pkgs/main/ - https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/ - https://mirrors.tuna.tsinghua.edu.cn/anaco…

Android 自定义PopupWindow,实现下拉框

1、效果图 2、前言 1、页面由 MagicIndicator ViewPager2 Fragment 实现&#xff1b; 2、下拉框是基于WindowManager实现&#xff1b; 3、我使用PopupWindow实现下拉框时&#xff0c;发现一个问题&#xff0c;PopupWindow 在窗口显示的情况下&#xff0c;无法直接从外部修…

面试经典 150 题 4 —(数组 / 字符串)— 80. 删除有序数组中的重复项 II

80. 删除有序数组中的重复项 II 方法一 class Solution { public:int removeDuplicates(vector<int>& nums) {int len 0;for(auto num : nums)if(len < 2 || nums[len-2] ! num)nums[len] num;return len;} };方法二 class Solution { public:int removeDupli…

分享购商业模式解析:三个角色、排位机制、奖励机制

分享购是一个自循环商业模式&#xff0c;它通过将第三方平台&#xff08;如京东、天猫、淘宝等&#xff09;的优惠券和折扣等信息整合到自营商城中&#xff0c;并合理分配给用户或消费者&#xff0c;增强了用户黏性&#xff0c;实现了持续多次的变现。分享购的核心机制是其排位…

Rabbitmq安装-docker版

1.简介 2.安装消息队列 下载地址https://www.rabbitmq.com/download.html 使用docker方式安装 需要先下载docker&#xff0c;参考文章https://blog.csdn.net/weixin_43917045/article/details/104747341?csdn_share_tail%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22arti…

操作系统备考学习 day7 (2.3.4 ~ 2.3.5)

操作系统备考学习 day7 第二章 进程与线程2.3 同步与互斥2.3.4 信号量 用信号量实现进程互斥、同步、前驱关系信号量机制实现进程互斥信号量机制实现进程同步信号量机制实现前驱关系 2.3.5 经典同步问题生产者-消费者问题多生产者和多消费者模型抽烟者问题读者-写者问题哲学家进…

使用运放产生各种波形

目录复制 文章目录 RC正弦振荡电路文氏电桥振荡电路移项式正弦波振荡电路 集成函数发生器运算放大器驱动电容性负载峰值检波多通道运放未使用的运放接法 RC正弦振荡电路 文氏电桥振荡电路 这个振荡器起振条件RF > 2R1,起振后又希望RF 2R1产生矛盾怎么办&#xff1f; 将RF换…