Ubuntu 20.04 安装Nginx-1.25.4

 

操作系统:Ubuntu 20.04.5 LTS

软件版本:nginx-1.25.4

 

一、环境准备

安装GCC编译器

安装PCRE

安装OpenSSL

安装OpenSSL库
安装zlib库

# 安装GCC编译器(build-essential 包会安装GCC编译器以及其他一些用于编译源代码的必须工具)sudo apt update && sudo apt install build-essential# 安装PCREsudo apt update && sudo apt install libpcre3 libpcre3-dev# 安装OpenSSLsudo apt update && sudo apt install openssl# 安装OpenSSL库sudo apt update && sudo apt install libssl-dev# 安装zlib库sudo apt install zlib1g-dev

二、安装Nginx

 

# 下载最新的nginxwget https://nginx.org/download/nginx-1.25.4.tar.gz# 解压tar zxvf nginx-1.25.4.tar.gz# 打开目录cd nginx-1.25.4# 配置./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_sub_module --with-http_ssl_module

 下面是configure运行后正常的结果

root@master:/install/nginx-1.25.4# 
root@master:/install/nginx-1.25.4# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_sub_module --with-http_ssl_module
checking for OS+ Linux 5.4.0-176-generic x86_64
checking for C compiler ... found+ using GNU C compiler+ gcc version: 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.2) 
checking for gcc -pipe switch ... found
checking for -Wl,-E switch ... found
checking for gcc builtin atomic operations ... found
checking for C99 variadic macros ... found
checking for gcc variadic macros ... found
checking for gcc builtin 64 bit byteswap ... found
checking for unistd.h ... found
checking for inttypes.h ... found
checking for limits.h ... found
checking for sys/filio.h ... not found
checking for sys/param.h ... found
checking for sys/mount.h ... found
checking for sys/statvfs.h ... found
checking for crypt.h ... found
checking for Linux specific features
checking for epoll ... found
checking for EPOLLRDHUP ... found
checking for EPOLLEXCLUSIVE ... found
checking for eventfd() ... found
checking for O_PATH ... found
checking for sendfile() ... found
checking for sendfile64() ... found
checking for sys/prctl.h ... found
checking for prctl(PR_SET_DUMPABLE) ... found
checking for prctl(PR_SET_KEEPCAPS) ... found
checking for capabilities ... found
checking for crypt_r() ... found
checking for sys/vfs.h ... found
checking for BPF sockhash ... found
checking for SO_COOKIE ... found
checking for UDP_SEGMENT ... found
checking for nobody group ... not found
checking for nogroup group ... found
checking for poll() ... found
checking for /dev/poll ... not found
checking for kqueue ... not found
checking for crypt() ... not found
checking for crypt() in libcrypt ... found
checking for F_READAHEAD ... not found
checking for posix_fadvise() ... found
checking for O_DIRECT ... found
checking for F_NOCACHE ... not found
checking for directio() ... not found
checking for statfs() ... found
checking for statvfs() ... found
checking for dlopen() ... not found
checking for dlopen() in libdl ... found
checking for sched_yield() ... found
checking for sched_setaffinity() ... found
checking for SO_SETFIB ... not found
checking for SO_REUSEPORT ... found
checking for SO_ACCEPTFILTER ... not found
checking for SO_BINDANY ... not found
checking for IP_TRANSPARENT ... found
checking for IP_BINDANY ... not found
checking for IP_BIND_ADDRESS_NO_PORT ... found
checking for IP_RECVDSTADDR ... not found
checking for IP_SENDSRCADDR ... not found
checking for IP_PKTINFO ... found
checking for IPV6_RECVPKTINFO ... found
checking for IP_MTU_DISCOVER ... found
checking for IPV6_MTU_DISCOVER ... found
checking for IP_DONTFRAG ... not found
checking for IPV6_DONTFRAG ... found
checking for TCP_DEFER_ACCEPT ... found
checking for TCP_KEEPIDLE ... found
checking for TCP_FASTOPEN ... found
checking for TCP_INFO ... found
checking for accept4() ... found
checking for int size ... 4 bytes
checking for long size ... 8 bytes
checking for long long size ... 8 bytes
checking for void * size ... 8 bytes
checking for uint32_t ... found
checking for uint64_t ... found
checking for sig_atomic_t ... found
checking for sig_atomic_t size ... 4 bytes
checking for socklen_t ... found
checking for in_addr_t ... found
checking for in_port_t ... found
checking for rlim_t ... found
checking for uintptr_t ... uintptr_t found
checking for system byte ordering ... little endian
checking for size_t size ... 8 bytes
checking for off_t size ... 8 bytes
checking for time_t size ... 8 bytes
checking for AF_INET6 ... found
checking for setproctitle() ... not found
checking for pread() ... found
checking for pwrite() ... found
checking for pwritev() ... found
checking for strerrordesc_np() ... not found
checking for sys_nerr ... found
checking for localtime_r() ... found
checking for clock_gettime(CLOCK_MONOTONIC) ... found
checking for posix_memalign() ... found
checking for memalign() ... found
checking for mmap(MAP_ANON|MAP_SHARED) ... found
checking for mmap("/dev/zero", MAP_SHARED) ... found
checking for System V shared memory ... found
checking for POSIX semaphores ... not found
checking for POSIX semaphores in libpthread ... found
checking for struct msghdr.msg_control ... found
checking for ioctl(FIONBIO) ... found
checking for ioctl(FIONREAD) ... found
checking for struct tm.tm_gmtoff ... found
checking for struct dirent.d_namlen ... not found
checking for struct dirent.d_type ... found
checking for sysconf(_SC_NPROCESSORS_ONLN) ... found
checking for sysconf(_SC_LEVEL1_DCACHE_LINESIZE) ... found
checking for openat(), fstatat() ... found
checking for getaddrinfo() ... found
checking for PCRE2 library ... not found
checking for PCRE library ... found
checking for PCRE JIT support ... found
checking for OpenSSL library ... found
checking for zlib library ... found
creating objs/MakefileConfiguration summary+ using system PCRE library+ using system OpenSSL library+ using system zlib librarynginx path prefix: "/usr/local/nginx"nginx binary file: "/usr/local/nginx/sbin/nginx"nginx modules path: "/usr/local/nginx/modules"nginx configuration prefix: "/usr/local/nginx/conf"nginx configuration file: "/usr/local/nginx/conf/nginx.conf"nginx pid file: "/usr/local/nginx/logs/nginx.pid"nginx error log file: "/usr/local/nginx/logs/error.log"nginx http access log file: "/usr/local/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"root@master:/install/nginx-1.25.4# 

编译安装

make & make install

启动nginx(临时)

/usr/local/nginx/sbin/nginx

查看nginx进程

ps -ef|grep nginx

查看nginx版本和已安装的模块

/usr/local/nginx/sbin/nginx -V

创建服务文件
 

vim /usr/lib/systemd/system/nginx.service

添加下面的内容

[Unit]
Description=nginx
After=network.target[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true[Install]
WantedBy=multi-user.target

 添加权限

chmod +x /usr/lib/systemd/system/nginx.service

设置开机自启

systemctl daemon-reload && systemctl enable tomcat.service

启动nginx

systemctl start nginx

查看nginx状态

root@master:/# systemctl status nginx
● nginx.service - nginxLoaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)Active: active (running) since Mon 2024-04-15 08:04:11 UTC; 1min 31s agoProcess: 25573 ExecStart=/usr/local/nginx/sbin/nginx (code=exited, status=0/SUCCESS)Main PID: 25574 (nginx)Tasks: 2 (limit: 9426)Memory: 1.9MCGroup: /system.slice/nginx.service├─25574 nginx: master process /usr/local/nginx/sbin/nginx└─25575 nginx: worker processApr 15 08:04:11 cngscccw-vpa758 systemd[1]: Starting nginx...
Apr 15 08:04:11 cngscccw-vpa758 systemd[1]: Started nginx.
root@master:/#

三、安装命令一条龙

附上所有的命令清单和步骤

# 安装GCC编译器(build-essential 包会安装GCC编译器以及其他一些用于编译源代码的必须工具)sudo apt update && sudo apt install build-essential# 安装PCREsudo apt update && sudo apt install libpcre3 libpcre3-dev# 安装OpenSSLsudo apt update && sudo apt install openssl# 安装OpenSSL库sudo apt update && sudo apt install libssl-dev# 安装zlib库sudo apt install zlib1g-dev# 下载最新的nginxwget https://nginx.org/download/nginx-1.25.4.tar.gz# 解压tar zxvf nginx-1.25.4.tar.gz# 配置./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_sub_module --with-http_ssl_module# 编译和安装make & make install# 启动nginx(临时)/usr/local/nginx/sbin/nginx# 查看nginx进程ps -ef|grep nginx# 查看nginx版本和已安装的模块/usr/local/nginx/sbin/nginx -V# 创建服务文件vim /usr/lib/systemd/system/nginx.service添加下面的内容:[Unit]
Description=nginx
After=network.target[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true[Install]
WantedBy=multi-user.target# 添加权限chmod +x /usr/lib/systemd/system/nginx.service# 设置开机自启systemctl daemon-reload && systemctl enable tomcat.service# 启动nginxsystemctl start nginx

 


 

 

 

 

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

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

相关文章

与助听器相关的职业主要有哪些?

助听装置是目前解决听觉障碍的几乎唯一科学的方法。然而助听装置改变的不是听力,而是外界的声音信息。也就是助听装置只能将外界的声音信息改变成能够适应听觉障碍患者听觉动态范围的声音。显然助听器并不知道听觉障碍患者的听觉动态范围是多少?也不知道…

分布式系统——全站监控

文章目录 全站监控要点**监控范围与对象****监控指标与数据****监控工具与技术****监控策略与实践****全站监控的价值** 实例展示 全站监控要点 全站监控是针对分布式架构中所有组件和服务进行全方位、多层次、实时的性能监控、状态检测和故障告警的系统化方法。在分布式环境下…

linux的内存管理

Linux的内存管理是操作系统中至关重要的组成部分之一。它负责管理系统中的物理内存,以便进程可以访问和使用它。以下是Linux内存管理的一些关键方面: 虚拟内存管理: Linux使用虚拟内存系统,将物理内存和进程地址空间分开管理。每个…

PMP每年考几次,费用如何?

今年的的考试分别分布在3月、6月、8月、11月,一般来说PMP的考试时间是3、6、9、12月,如果有特殊情况PMI也会及时进行调整,具体看他们官网的通知了。 PMP的考试费用全球是统一的,在国内考试报名费用是3900元,如果考试没…

AIOS: LLM Agent Operating System

AIOS:LLM代理操作系统 摘要 文中提出了AIOS系统(人工智能操作系统),目的是解决在大型语言模型基础上部署智能代理时遇到的各种挑战,如调度不佳、资源分配不合理以及在代理与LLM交互过程中保持上下文的困难。AIOS旨在…

go 基本知识点备忘

原站地址:Go 语言教程 | 菜鸟教程 本文目的: 精简方式记录最重要的知识点,方便快速复习 一、基本语法 1. GO语言特点:高效,并行,开源,搭载Web服务器 2. 执行命令: go run hello.…

【学习】自动化测试有哪些优势和不足

在当今这个数字化时代,软件测试已经成为了任何一款产品成功的关键因素之一。而在诸多的测试方法中,自动化测试凭借着其独特的魅力吸引着越来越多的企业。今天就让我们一起走进自动化测试的世界,探讨它的优势与不足。 一、自动化测试优势 1.…

symbol 类型学习

探索 JavaScript 中的独特标识符:Symbol 类型 JavaScript 作为一门灵活且功能丰富的编程语言,提供了多种数据类型供开发者构建复杂的应用程序。其中,一种相对新颖且独特的类型——Symbol,为对象属性的管理带来了更高的安全性和定…

你的mongodb客户端是哪个呢?

MongoDB 是一种流行的文档数据库,它可以支持多种场景和应用。有很多客户端工具可以用来管理和操作 MongoDB,以下是一些常用的工具,以及它们的介绍: 一、MongoDB Shell MongoDB Shell 是连接(和使用)MongoD…

追溯历史:SIEM 中的生成式人工智能革命

作者:来自 Elastic Mike Nichols, Mike Paquette 网络安全领域仿佛是现实世界的一个映射,安全运营中心(security operation center - SOC)就像是你的数字警察局。网络安全分析师就像是警察,他们的工作是阻止网络犯罪分…

hyref 开发者推荐项目

GitHub - limingxinleo/phalcon: phalcon项目结构 GitHub - fan3750060/wpcore: php , swoole, wow, wowcore, World of Warcraft,master> wow_3.3.5a(Can not work normally) ,branch>wow_2.4.3_8606

基于SpringWeb MultipartFile文件上传、下载功能

在Web开发中,文件上传是一个常见的功能需求。Spring框架提供了MultipartFile接口,用于处理文件上传请求。MultipartFile可以代表一个多部分文件上传请求中的一个文件,提供了一系列方法用于获取文件的各种属性和内容,使得在后端处理…

数据中台规划与建设方案PPT(建议收藏)

推荐书籍: 《分布式商业生态战略:数字商业新逻辑与企业数字化转型新策略》 书籍介绍: 本书从新时代商业环境出发,紧随市场热点,如元宇宙、Web 3.0、资产数字化、反垄断、要素市场化配置、分布式自治组织(d…

2024年4月13日美团春招实习试题【第二题:最多0的个数】-题目+题解+在线评测【贪心】

2024年4月13日美团春招实习试题【第二题:最多0的个数】-题目题解在线评测【贪心】 题目描述:输入描述输出描述样例 解题思路一:贪心,将所有负数变为正数,然后排序。nums.sort(key lambda x: abs(x))解题思路二:c解题思…

数据仓库作业五:第8章 关联规则挖掘

目录 第8章 关联规则挖掘作业题 第8章 关联规则挖掘 作业题 1、设4-项集 X { a , b , c , d } X\{a,b,c,d\} X{a,b,c,d},试求出由 X X X 导出的所有关联规则。 解: 首先生成项集的所有非空真子集。这包括: { a } , { b } , { c } , {…

UE5集成gRPC

最近有项目需要在UE5里做RPC,对比了thrift、gRPC、rcplib等开源rpc框架,由于习惯使用protobuf,故选择了gRPC。然而,Google出品也是一言难尽啊,最起码编译太繁琐了。 本次使用的gRPC版本为1.62.1,UE5.2&…

基于机器学习的车辆状态异常检测

基于马氏距离的车辆状态异常检测(单一传感器) 基于多元自动编码器的车辆状态异常检测 基于单传感器平滑马氏距离的车辆状态异常检测 工学博士,担任《Mechanical System and Signal Processing》等期刊审稿专家,擅长领域&#xff1…

数据结构详解

数据结构 线性结构 一个有序数据元素的集合其中数据元素之间的关系是一对一的关系,即除了第一个和最后一个数据元素之外,其它数据元素都是首尾相接的 非线性结构 线性结构的对立面 数组 定义 数组是一种线性数据结构,用于存储相同类型…

java面向对象的封装Triangle

(1)定义三角形类Triangle, * - 声明实例变量a,b,c,代表三角形三条边,全部私有化private, * - 提供每条边的get方法, * - 提供public void setBases(double a, double b, double c):要…

【Redis(3)】深入理解Redis三种高可用方案,以做出明智的选择

通过上一篇文章详细介绍了Redis的持久化方式RDB和AOF配置,这一篇主要介绍Redis的几种高可用方案。 Redis作为一个成熟的远程字典服务,提供了三种常用的高可用设计方案,Redis的每种高可用性方案都各有千秋,选择时需要细致考虑业务…