Ubuntu系统Springboot项目Nginx安装(编译安装方式)

news2024/9/23 9:21:43

1.下载

nginx官网下载

Index of /download/

2.解压

这里我下载的1.25.3版本,系统是ubuntu

解压

tar -zxvf nginx-1.25.3.tar.gz 

3.编译安装

安装前需要执行安装一些系统依赖

3.1安装PCRE库

ubuntu:执行以下命令
sudo apt-get install libpcre3 libpcre3-dev
centos:执行以下命令
sudo yum install pcre pcre-devel

不安装会报错:

./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.

 3.2 安装Zlib

官网:zlib Home Site

将tar包上传服务器,上传路径自定义

 3.2.1 解压

tar -zxvf zlib-1.3.tar.gz 

 3.2.2 安装

进入解压目录zlib-1.3

cd zlib-1.3

执行三条安装命令

./configure
make
make install

不安装zlib就安装nginx会报错:

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

3.3 安装SSL模组依赖

一般nginx都需要ssl模组,此版本nginx不安装ssl组件不会报错,之前版本可能会报错

ubuntu安装

 sudo apt-get install libssl-dev

centos安装

sudo yum install openssl openssl-devel

3.4 安装Nginx

再次进入nginx解压目录安装nginx,--prefix命令是我指定的安装目录,你们运行的时候自己指定一下nginx的安装目录

./configure --prefix=/home/software/nginx/install --with-http_ssl_module

 安装命令

make && make install

4 配置Nginx开机自启

在目录/lib/systemd/system创建文件nginx.service

vim /lib/systemd/system/nginx.service

 注意修改/home/software/nginx/install/sbin/路径为你安装nginx的路径

ExecStart=/home/software/nginx/install/sbin/nginx
ExecReload=/home/software/nginx/install/sbin/nginx reload
ExecStop=/home/software/nginx/install/sbin/nginx quit

 配置文件内容,注意修改nignx命令位置

# Stop dance for nginx
# =======================
#
# ExecStop sends SIGSTOP (graceful stop) to the nginx process.
# If, after 5s (--retry QUIT/5) nginx is still running, systemd takes control
# and sends SIGTERM (fast shutdown) to the main process.
# After another 5s (TimeoutStopSec=5), and if nginx is alive, systemd sends
# SIGKILL to all the remaining processes in the process group (KillMode=mixed).
#
# nginx signals reference doc:
# http://nginx.org/en/docs/control.html
#
[Unit]
Description=A high performance web server and a reverse proxy server
Documentation=man:nginx(8)
After=network.target

[Service]
Type=forking 
ExecStart=/home/software/nginx/install/sbin/nginx
ExecReload=/home/software/nginx/install/sbin/nginx reload
ExecStop=/home/software/nginx/install/sbin/nginx quit
PrivateTmp=true 
TimeoutStopSec=5
KillMode=mixed

[Install]
WantedBy=multi-user.target

修改完成后

4.1 启动nginx服务

systemctl enable nginx.service

4.2 重启nginx服务

systemctl restart nginx

4.3 查看Nginx状态

systemctl status nginx

5 Nginx配置


#user  nobody;
worker_processes  2;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen [::]:80 default_server;
        server_name _;
        return 301 https://$host$request_uri;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

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

    }

    server {
        listen       443 ssl;
        server_name  localhost;
        #修改你的证书存放位置
        ssl_certificate      /home/software/nginx/install/cert/anakkix.cn_bundle.pem;
        ssl_certificate_key  /home/software/nginx/install/cert/anakkix.cn.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

        location / {
            proxy_set_header Host $host;
            proxy_pass      http://localhost:8080; # 当你访问80端口可以实现向8080端口转发
            root   html;
            index  index.html index.htm;
        }
    }
}

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

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

相关文章

第一百八十三回 如何给图片添加阴影

文章目录 1. 概念介绍2. 思路与方法2.1 实现思路2.2 实现方法 3. 代码与效果3.1 示例代码3.2 运行效果 4. 内容总结 我们在上一章回中介绍了"自定义可以滑动的刻度尺"样相关的内容&#xff0c;本章回中将介绍" 如何给图片添加阴影".闲话休提&#xff0c;让…

Scrum敏捷开发流程及支撑工具

Scrum是一种敏捷开发框架&#xff0c;用于管理复杂的项目。以下这些步骤构成了Scrum敏捷开发流程的核心。通过不断迭代、灵活应对变化和持续反馈&#xff0c;Scrum框架帮助团队快速交付高质量的产品。 以下是Scrum敏捷开发流程的基本步骤&#xff1a; 产品Backlog创建&#xf…

Unity之ARFoundation如何实现BodyTracking人体跟踪

前言 ARBodyTracking,就是指通过手机AR扫描并精确的捕获人物的肢体部位的技术。如下图所示 这项技术目前是有苹果的ARKit提供,苹果的body tracking 功能需要使用配备 TrueDepth 摄像头的设备,配备 A12 仿生芯片、运行 iOS 13 或更高版本的设备,比如 iPhone X 及更新机型。…

anaconda换源安装pytorch(附带bug解决办法)

1.安装anaconda 如何安装anaconda可以看这篇文章:如何安装anaconda 2.换源安装pytorch: 首先进入到pytorch官网&#xff0c;选对好参数之后复制命令进入到anaconda prompt即可: 然后进入自己的环境之后输入该命令(即conda install …)&#xff0c;则可以进行下载。下载完成…

从苹果到蔚来,「车手互联」网罗顶级玩家

作者 |Amy 编辑 |德新 汽车作为家之外的第二大移动空间&#xff0c;正与手机这一移动智能终端进行「车手互联」。 车手互联始于十年前的苹果CarPlay&#xff0c;一度成为时代弄潮儿&#xff0c;不断有后继者模仿并超越。时至今日&#xff0c;CarPlay2.0依旧停留在概念阶段&am…

vue3怎么提升效率的?为什么vue3比vue2快?效率提升主要在哪些方面?

官方文档中说vue3在 客户端渲染效率比vue2提升了1.3~2倍&#xff0c; SSR渲染效率比vue2提升了2~3倍&#xff0c;那么究竟是怎么提升的呢&#xff1f; 一、静态提升 在 vue3项目中的package.json文件中&#xff0c;可以看到这个 vue/compiler-sfc&#xff0c;它是用来解析(.v…

KernelSHAP vs TreeSHAP

Kernel SHAP和Tree SHAP都用于近似Shapley值。Tree SHAP要快得多。缺点是它只能用于基于树的算法&#xff0c;如随机森林和xgboost。另一方面&#xff0c;Kernel SHAP是模型不可知的(model agnostic)&#xff0c;这意味着它可以与任何机器学习算法一起使用。我们将比较这两种近…

SEAM-STRESS

模型 PCM means ‘Pixel Correlation Module’ 辅助信息 作者未提供代码

Python二叉树用法介绍

更多资料获取 &#x1f4da; 个人网站&#xff1a;ipengtao.com 二叉树是一种常见的数据结构&#xff0c;具有树形结构&#xff0c;每个节点最多有两个子节点。Python中有多种方式来表示和操作二叉树&#xff0c;本文将介绍二叉树的基本概念、构建、遍历和一些常见操作&#x…

[UGUI]Unity背包系统制作详细步骤

二、背包制作 1.创建空物体&#xff0c;然后创建UI-Image 制作背包整个背包所在的父UI的背景图 选中BG&#xff0c;找到他的锚点设置&#xff0c;按住Alt键&#xff0c;点击右下角的适配&#xff0c;让锚点和内容都匹配画布 PS&#xff1a;不按Alt键是设置一个元素的锚点位…

某医院小程序存在支付漏洞和越权

某医院小程序存在支付漏洞和越权查看他人身份证&#xff0c;手机号&#xff0c;住址等信息 一个医院线上的小程序 登陆后点击个人信息&#xff0c;抓包&#xff0c;放到repeter模块&#xff0c; 修改strUserID参数可以越权查看别人信息 放intruder模块可以跑数据&#xff0c;这…

神器!使用 patchworklib 库进行多图排版真棒啊

如果想把多个图合并放在一个图里&#xff0c;如图&#xff0c;该如何实现 好在R语言 和 Python 都有对应的解决方案&#xff0c; 分别是patchwork包和patchworklib库。 推介1 我们打造了《100个超强算法模型》&#xff0c;特点&#xff1a;从0到1轻松学习&#xff0c;原理、…

互联网程序设计HTML+CSS+JS

一、HTML基础 HTML超文本标记语言。 超文本&#xff1a;链接&#xff1b; 标记&#xff1a;标签&#xff0c;带尖括号的文本。 1、标签结构 标签要成对出现&#xff0c;中间包裹内容&#xff1b; <>里面放英文字母&#xff08;标签名&#xff09;&#xff1b; 结束…

013 C++ set与map的用法

前言 本文将会向你介绍set与map的主要用法 set详解 int main() {set<string> s;vector<string> v { "Fan1","Fan2", "Fan3", "Fan4" };for (auto e : v){s.insert(e);}string input;while (cin >> input){if (s.…

java+python农村集体产权管理系统php+vue

注册、登陆该系统根据操作权限的不同分为管理员和用户两种&#xff0c;新用户在登陆前要进行用户注册&#xff0c;注册完成后方可进行登陆。 本次设计的关键问题处理&#xff0c;主要有如下几点&#xff1a; (1&#xff09;本次开发&#xff0c;采用主流Thinkphp框架进行开发&a…

LRU 是什么?

程序员的公众号&#xff1a;源1024&#xff0c;获取更多资料&#xff0c;无加密无套路&#xff01; 最近整理了一份大厂面试资料《史上最全大厂面试题》&#xff0c;Springboot、微服务、算法、数据结构、Zookeeper、Mybatis、Dubbo、linux、Kafka、Elasticsearch、数据库等等 …

java中IO知识点概念

这里写自定义目录标题 内存中的数据以电子信号的形式表示&#xff0c;而磁盘中的数据是以磁场的方向表示。1.流的分类2.File类3.流的API 关键4.理解缓冲的作用-一次性多拿些读写文件的时候为什么要有缓冲流 -意义是什么缓冲流的使用 5.路径问题6.文件的创建7.内存和磁盘存储本质…

Python---lambda表达式

普通函数与匿名函数 在Python中&#xff0c;函数是一个被命名的、独立的完成特定功能的一段代码&#xff0c;并可能给调用它的程序一个返回值。 所以在Python中&#xff0c;函数大多数是有名函数 > 普通函数。但是有些情况下&#xff0c;我们为了简化程序代码&#xff0c;…

SpringSecurity+JWT实现权限控制以及安全认证

一.简介 Spring Security 是 Spring家族中的一个安全管理框架。相比与另外一个安全框架Shiro&#xff0c;它提供了更丰富的功能&#xff0c;社区资源也比Shiro丰富。 认证&#xff1a;验证当前访问系统的是不是本系统的用户&#xff0c;并且要确认具体是哪个用户​ 授权&…

Numpy进阶

NumPy进阶80题完整版