在Linux虚拟机内配置nginx以及docker

目录

1、nginx源码包编译以及安装依赖

1、配置安装所需的编译环境

2、安装函数库(pcre、zlib、openssl)

2、安装nginx

1、获取源码包

2、解压编译

3、启动nginx服务

1、关闭防火墙

2、运行nginx

3、使用本地浏览器进行验证

3、安装docker

1、查看操作系统发行版本以及清空安装的旧版本

2、安装docker环境

3、安装docker

4、测试

4、在dockers上拉取nginx镜像挂载


1、nginx源码包编译以及安装依赖

1、配置安装所需的编译环境


[root@localhost /]# yum install -y gcc gcc-c++

2、安装函数库(pcre、zlib、openssl)


[root@localhost /]# yum install -y pcre pcre-devel  #安装pcre库[root@localhost /]# yum install -y zlib zlib-devel  #安装zlib库[root@localhost /]# yum install -y openssl-devel   #安装openssl库

2、安装nginx

1、获取源码包

[root@localhost /]# mkdir nginxfile
[root@localhost /]# cd nginxfile/[root@localhost nginxfile]# wget https://nginx.org/download/nginx-1.24.0.tar.gz   #下载nginx源码包

2、解压编译


[root@localhost nginxfile]# tar -zxvf nginx-1.24.0.tar.gz   #解压源码包#编译配置
[root@localhost nginxfile]# cd nginx-1.24.0/
[root@localhost nginx-1.24.0]# ./configure --with-http_ssl_module
[root@localhost nginx-1.24.0]# ./configure --with-stream
[root@localhost nginx-1.24.0]# ./configure[root@localhost nginx-1.24.0]# make && make install   #执行安装

3、启动nginx服务

1、关闭防火墙

[root@localhost sbin]# systemctl stop firewalld.service
[root@localhost sbin]# systemctl status firewalld.service

2、运行nginx

[root@localhost nginx-1.24.0]# cd /usr/local/nginx/sbin/
[root@localhost sbin]# ls
nginx[root@localhost sbin]# ./nginx    #执行nginx#查看nginx的进程开启情况
[root@localhost sbin]# ps -aux | grep nginx
root       72876  0.0  0.0  34444   384 ?        Ss   21:27   0:00 nginx: master process ./nginx
nobody     72877  0.0  0.2  66624  3932 ?        S    21:27   0:00 nginx: worker process
root       72887  0.0  0.0  12136  1120 pts/2    R+   21:28   0:00 grep --color=auto nginx

3、使用本地浏览器进行验证

3、安装docker

1、查看操作系统发行版本以及清空安装的旧版本

[root@localhost /]# uname -r
4.18.0-348.el8.x86_64#卸载旧的docker版本
[root@localhost /]# yum remove docker \docker-client \docker-client-latest \docker-common \docker-latest \docker-latest-logrotate \docker-logrotate \docker-engine

2、安装docker环境

#安装yum-utils
[root@localhost /]# yum install -y yum-utils#添加库
[root@localhost /]# yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo#安装makecache
[root@localhost /]# yum makecache 

3、安装docker

[root@localhost /]# yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin

 安装时可能会报错,我们一般会这样去解决

#运行以下内容
[root@localhost /]# yum erase podman buildah#重新进行安装
[root@localhost /]# yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin

随后启动docker

[root@localhost /]# systemctl start docker
[root@localhost /]# systemctl status docker
● docker.service - Docker Application Container EngineLoaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset>   Active: active (running) since Wed 2023-08-09 00:51:52 CST; 9s ago

4、测试

[root@localhost /]# docker run hello-world
[rootelocalhost /]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
719385e32844: Pull complete
Digest: sha256:926fac19d22aa2d60f1a276b66a20eb765fbeea2db5dbdaafeb456ad8ce81598Status: Downloaded newer image for hello-world:latestHello from Docker!This message shows that your installation appears to be working correctlyTo generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon .
2. The Docker daemon pulled the "hello-world" image from the Docker Hub

4、在dockers上拉取nginx镜像挂载

拉取镜像

[root@localhost /]# docker pull nginx#查看本地镜像[root@localhost /]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
nginx         latest    89da1fb6dcb9   11 days ago    187MB
hello-world   latest    9c7a54a9a43c   3 months ago   13.3kB

创建nginx服务以及挂载本地nginx配置文件

#创建运行一个nginx容器同时挂载本地文件[root@localhost ~]# docker run --name nginx-test -p 9090:80 -d -v /usr/local/nginx/conf:/usr/share/nginx/conf -v /usr/local/nginx/html:/usr/share/nginx/html -v /etc/nginx/conf.d:/usr/share/nginx/conf.d nginx
38e38f4ea4534594b8b8cdcebee6bee843debbf8a18c82904ea5ac7f63efc283[root@localhost conf]# docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS         PORTS                                   NAMES
38e38f4ea453   nginx     "/docker-entrypoint.…"   4 minutes ago   Up 4 minutes   0.0.0.0:9090->80/tcp, :::9090->80/tcp   nginx-test

查看端口映射情况

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

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

相关文章

每次执行@Test方法前都执行一次DB初始化(SpringBoot Test + JUnit5环境)

引言 在执行单元测试时,可以使用诸如H2内存数据库替代线上的Mysql数据库等,如此在执行单元测试时就能尽可能模拟真实环境的SQL执行,同时也无需依赖线上数据库,增加了测试用例执行环境的可移植性。而使用H2数据库时,通…

Oracle DB 安全性 : TDE HSM TCPS Wallet Imperva

• 配置口令文件以使用区分大小写的口令 • 对表空间进行加密 • 配置对网络服务的细粒度访问 TCPS 安全口令支持 Oracle Database 11g中的口令: • 区分大小写 • 包含更多的字符 • 使用更安全的散列算法 • 在散列算法中使用salt 用户名仍是Oracle 标识…

【JavaEE】Spring Boot - 日志文件

【JavaEE】Spring Boot 开发要点总结(3) 文章目录 【JavaEE】Spring Boot 开发要点总结(3)1. 日志有什么作用2. 日志格式2.1 日志框架原理 3. 日志的打印3.1 System.out.println3.2 使用日志框架3.3 日志级别3.3.1 设置默认日志显…

深度学习(36)—— 图神经网络GNN(1)

深度学习(36)—— 图神经网络GNN(1) 这个系列的所有代码我都会放在git上,欢迎造访 文章目录 深度学习(36)—— 图神经网络GNN(1)1. 基础知识2.使用场景3. 图卷积神经网…

提高测试用例质量的6大注意事项

在软件测试中,经常会遇到测试用例设计不完整,用例没有完全覆盖需求等问题,这样往往容易造成测试工作效率低下,不能及时发现项目问题,无形中增加了项目风险。 因此提高测试用例质量,就显得尤为重要。一般来说…

电脑开不了机如何解锁BitLocker硬盘锁

事情从这里说起,不想看直接跳过 早上闲着无聊,闲着没事干,将win11的用户名称改成了含有中文字符的用户名,然后恐怖的事情发生了,蓝屏了… 然后就是蓝屏收集错误信息,重启,蓝屏收集错误信息&…

C#小轮子:自动连续Ping网络地址

文章目录 前言Ping代码异步问题 前言 工作中,我们经常用到Ping这个指令,有时候我们需要Ping整个网段来查看这个网段上面有什么设备,哪些Ip地址是通的,这个时候就需要Ping指令 Ping 代码 我这个是批量Ping的代码,而…

python爬虫实战(2)--爬取某博热搜数据

1. 准备工作 使用python语言可以快速实现,调用BeautifulSoup包里面的方法 安装BeautifulSoup pip install BeautifulSoup完成以后引入项目 2. 开发 定义url url https://s.微博.com/top/summary?caterealtimehot定义请求头,微博请求数据需要cookie…

OpenAI允许网站阻止其网络爬虫;谷歌推出类似Grammarly的语法检查功能

🦉 AI新闻 🚀 OpenAI推出新功能,允许网站阻止其网络爬虫抓取数据训练GPT模型 摘要:OpenAI最近推出了一个新功能,允许网站阻止其网络爬虫从其网站上抓取数据训练GPT模型。该功能通过在网站的Robots.txt文件中禁止GPTB…

datax抽取库名带点的表遇到的问题

一、描述任务 使用Datax抽取mysql中的数据到hive的wedw_ods层中,mysql的库名为:b.p.n.p 表名为:bene_group 二、datax.json脚本生成 因为datax的脚本是自动生成的,生成的格式如下: {"core": {},"jo…

python接口自动化测试框架2.0,让你像Postman一样编写测试用例,支持多环境切换、多业务依赖、数据库断言等

项目介绍 接口自动化测试项目2.0 软件架构 本框架主要是基于 Python unittest ddt HTMLTestRunner log excel mysql 企业微信通知 Jenkins 实现的接口自动化框架。 前言 公司突然要求你做自动化,但是没有代码基础不知道怎么做?或者有自动化…

部署模型并与 TVM 集成

本篇文章译自英文文档 Deploy Models and Integrate TVM tvm 0.14.dev0 documentation 更多 TVM 中文文档可访问 →Apache TVM 是一个端到端的深度学习编译框架,适用于 CPU、GPU 和各种机器学习加速芯片。 | Apache TVM 中文站 本节介绍如何将 TVM 部署到各种平台&…

搭建Repo服务器

1 安装repo 参考&#xff1a;清华大学开源软件镜像站:Git Repo 镜像使用帮助 2 创建manifest仓库 2.1 创建仓库 git init --bare manifest.git2.2 创建default.xml文件 default.xml文件内容&#xff1a; <?xml version"1.0" encoding"UTF-8" ?…

基于Googlenet深度学习网络的人员行为动作识别matlab仿真

目录 1.算法运行效果图预览 2.算法运行软件版本 3.部分核心程序 4.算法理论概述 1. 原理 1.1 深度学习与卷积神经网络&#xff08;CNN&#xff09; 1.2 GoogLeNet 2. 实现过程 2.1 数据预处理 2.2 构建网络模型 2.3 数据输入与训练 2.4 模型评估与调优 3. 应用领域…

STM32 LL库开发

一、STM32开发方式 标准库开发&#xff1a;Standard Peripheral Libraries&#xff0c;STDHAL库开发&#xff1a;Hardware Abstraction Layer&#xff0c;硬件抽象层LL库开发&#xff1a;Low-layer&#xff0c;底层库 二、HAL库与LL库开发对比 ST在推行HAL库的时候&#xff0c;…

C# Linq源码分析之Take方法

概要 Take方法作为IEnumerable的扩展方法&#xff0c;具体对应两个重载方法。本文主要分析第一个接收整数参数的重载方法。 源码解析 Take方法的基本定义 public static System.Collections.Generic.IEnumerable Take (this System.Collections.Generic.IEnumerable source…

【uniapp】uniapp使用微信开发者工具制作骨架屏:

文章目录 一、效果&#xff1a;二、过程&#xff1a; 一、效果&#xff1a; 二、过程&#xff1a; 【1】微信开发者工具打开项目&#xff0c;生成骨架屏&#xff0c;将wxml改造为vue页面组件&#xff0c;并放入样式 【2】页面使用骨架屏组件 【3】改造骨架屏&#xff08;去除…

以mod_jk方式整合apache与tomcat(动静分离)

前言&#xff1a; 为什么要整合apache和tomcat apache对静态页面的处理能力强&#xff0c;而tomcat对静态页面的处理不如apache&#xff0c;整合后有以下好处 提升对静态文件的处理性能 利用 Web 服务器来做负载均衡以及容错 更完善地去升级应用程序 jk整合方式介绍&#…

项目知识点记录

1.使用druid连接池 使用properties配置文件&#xff1a; driverClassName com.mysql.cj.jdbc.Driver url jdbc:mysql://localhost:3306/book?useSSLtrue&setUnicodetrue&charsetEncodingUTF-8&serverTimezoneGMT%2B8 username root password 123456 #初始化链接数…

【验证码逆向专栏】最新某度旋转验证码 v2 逆向分析

声明 本文章中所有内容仅供学习交流使用&#xff0c;不用于其他任何目的&#xff0c;不提供完整代码&#xff0c;抓包内容、敏感网址、数据接口等均已做脱敏处理&#xff0c;严禁用于商业用途和非法用途&#xff0c;否则由此产生的一切后果均与作者无关&#xff01; 本文章未…