Mushroom Notes Mushroom Notes
🍄首页
  • JavaSE

    • 基础篇
    • 数据结构
    • IO流
    • Stream流
    • 函数式接口
    • JUC
    • 反射
    • 网络编程
    • 设计模式
  • JavaEE

    • Servlet
    • JDBC
    • 会话技术
    • 过滤器监听器
    • 三层架构
  • JDK

    • 总览
  • JVM

    • 总览
  • 常用mate
  • CSS
  • JavaScript
  • rds 数据库

    • MySQL
    • MySQL 进阶
    • MySQL 库表规范
  • nosql 数据库

    • Redis
    • Redis 进阶
    • Redis 底层
    • MongoDB
  • Spring生态

    • Spring
    • Spring MVC
    • Spring boot
    • Spring Validation
  • Spring Cloud生态

    • Spring Cloud
    • 服务治理
    • 远程调用
    • 网关路由
    • 服务保护
    • 分布式事务
    • 消息中间件
  • 数据库

    • Mybatis
    • Mybatis Plus
    • Elasticsearch
    • Redisson
  • 通信

    • Netty
📚技术
  • 方案专题
  • 算法专题
  • BUG专题
  • 安装专题
  • 网安专题
  • 面试专题
  • 常用网站
  • 后端常用
  • 前端常用
  • 分类
  • 标签
  • 归档

kinoko

一位兴趣使然的热心码农
🍄首页
  • JavaSE

    • 基础篇
    • 数据结构
    • IO流
    • Stream流
    • 函数式接口
    • JUC
    • 反射
    • 网络编程
    • 设计模式
  • JavaEE

    • Servlet
    • JDBC
    • 会话技术
    • 过滤器监听器
    • 三层架构
  • JDK

    • 总览
  • JVM

    • 总览
  • 常用mate
  • CSS
  • JavaScript
  • rds 数据库

    • MySQL
    • MySQL 进阶
    • MySQL 库表规范
  • nosql 数据库

    • Redis
    • Redis 进阶
    • Redis 底层
    • MongoDB
  • Spring生态

    • Spring
    • Spring MVC
    • Spring boot
    • Spring Validation
  • Spring Cloud生态

    • Spring Cloud
    • 服务治理
    • 远程调用
    • 网关路由
    • 服务保护
    • 分布式事务
    • 消息中间件
  • 数据库

    • Mybatis
    • Mybatis Plus
    • Elasticsearch
    • Redisson
  • 通信

    • Netty
📚技术
  • 方案专题
  • 算法专题
  • BUG专题
  • 安装专题
  • 网安专题
  • 面试专题
  • 常用网站
  • 后端常用
  • 前端常用
  • 分类
  • 标签
  • 归档
  • 方案专题

  • 算法专题

  • BUG专题

  • 安装专题

    • Git安装
    • Nginx安装
      • 压缩包安装步骤
        • 1.下载NGINX安装包
        • 2.在线安装依赖
        • 3.解压压缩包
        • 4.配置Nginx编译环境
        • 5.编译安装
        • 6.更多设置
    • NVM安装
  • 网安专题

  • 面试专题

  • 专题
  • 安装专题
kinoko
2023-12-26
目录

Nginx安装

# 压缩包安装步骤


# 1.下载NGINX安装包

官网:https://nginx.org/en/download.html (opens new window)
image.png

# 2.在线安装依赖

由于nginx是基于c语言开发的,所以需要安装c语言的编译环境,及正则表达式库等第三方依赖库。

#安装nginx所需要的依赖包
yum install -y gcc-c++	zlib zlib-devel	openssl openssl-devel pcre pcre-devel
1
2

# 3.解压压缩包

进入压缩包所在目录,解压安装包

#进入所在目录
cd /压缩包所在目录
#解压安装包
tar -zxvf nginx-1.24.0.tar.gz -C /解压目录
1
2
3
4

进入解压目录

#进入nginx目录
cd /usr/local/nginx-1.24.0
1
2

image.png

# 4.配置Nginx编译环境

执行配置脚本,--prefix是指定安装目录

#执行配置脚本 --prefix是指定安装目录
./configure --prefix=/usr/local/soft/nginx
1
2

如果遇到报错“./configure: error: C compiler cc is not found”

yum -y install gcc gcc-c++ autoconf automake make
1

# 5.编译安装

#对nginx编译和安装
make & make install
1
2

这时在安装目录会多出一个文件夹
image.png
启动

#启动脚本是在
# /usr/local/nginx/sbin/nginx
#启动,
/usr/local/soft/nginx/sbin/nginx -c /usr/local/soft/nginx/conf/nginx.conf
#停止
/usr/local/soft/nginx/sbin/nginx -s stop
#重载
/usr/local/soft/nginx/sbin/nginx -s reload
#杀掉nginx
/usr/local/soft/nginx/sbin/nginx -s quit
1
2
3
4
5
6
7
8
9
10

查询nginx是否启动:

ps -ef | grep nginx
1

注意:nginx服务启动后,默认就会有两个进程。
启动之后,我们可以直接访问Nginx的80端口, http://192.168.200.200
image.png

# 6.更多设置

关闭防火墙

#临时关闭防火墙
systemctl stop firewalld.service
#永久关闭防火墙
systemctl disable firewalld.service
1
2
3
4

开放80端口

firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
1
2

设置nginx 的开机启动

vim /etc/rc.local
#文本底部追加
/usr/local/soft/nginx/sbin/nginx
1
2
3

配置环境变量,方便全局调用Nginx命令

#打开/etc/profile 文件
vim /etc/profile
#添加nginx路径
export NGINX_HOME=/usr/local/soft/nginx
export PATH=$NGINX_HOME/sbin:$PATH
1
2
3
4
5

image.png
刷新环境变量

source /etc/profile
1

查看效果
image.png

#nginx#安装
上次更新: 2023/12/29 11:32:56
Git安装
NVM安装

← Git安装 NVM安装→

最近更新
01
JVM 底层
09-13
02
JVM 理论
09-13
03
JVM 应用
09-13
更多文章>
Theme by Vdoing | Copyright © 2022-2024 kinoko | MIT License | 粤ICP备2024165634号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式