【个人技术经验及开发技巧分享】 【个人技术经验及开发技巧分享】
首页
  • 操作系统初识
  • JAVA基础
  • JVM
  • 开发框架
  • Redis
  • Zookeeper
  • 消息中间件
  • 持久化
  • 算法
  • 网络
  • 系统架构
  • 并发编程
  • 框架
  • 开发杂货
  • 线上排查
  • 技巧备忘
  • 部署指南
  • 版本管理
  • 工作流程
  • 发版流程
  • 友情链接
  • 网站备忘
  • 在线工具
  • 学习
  • 各种云
  • 应用下载

Louis

首页
  • 操作系统初识
  • JAVA基础
  • JVM
  • 开发框架
  • Redis
  • Zookeeper
  • 消息中间件
  • 持久化
  • 算法
  • 网络
  • 系统架构
  • 并发编程
  • 框架
  • 开发杂货
  • 线上排查
  • 技巧备忘
  • 部署指南
  • 版本管理
  • 工作流程
  • 发版流程
  • 友情链接
  • 网站备忘
  • 在线工具
  • 学习
  • 各种云
  • 应用下载
  • 开发杂货

  • 线上排查

  • 技巧备忘

  • 部署指南

    • Nginx安装
      • 1 MAC上安装nginx
        • 1.1 判断mac电脑是否已安装brew
        • 1.2 如果没有安装brew,可以用国内版本安装
        • 1.3 查询需要安装的nginx包是否存在
        • 1.4 安装nginx
        • 1.5 安装成功后,查看nginx安装目录
        • 1.6 启动nginx
        • 1.7 nginx 常用操作
      • 2 LINUX上安装nginx
        • 2.1 官网地址
        • 2.2 下载解压
        • 2.3 安装必要插件
        • 2.4 配置及安装
      • 3 nginx.conf 示例
    • Nginx Https证书安装
    • ElasticSearch安装
    • Kibana安装
    • SkyWalking链路追踪
    • Zookeeper安装
    • RabbitMQ安装
    • Kafka集群搭建
    • Kafka Manager安装
    • MySQL安装
    • Canal数据同步
    • Redis高可用集群搭建
    • XXL-JOB本地部署
    • ELk+Filebeat部署
    • Nacos源码本地运行
  • 技术应用
  • 部署指南
luoxiaofeng
2022-05-10
目录

Nginx安装

# 1 MAC上安装nginx

# 1.1 判断mac电脑是否已安装brew

brew update
1

# 1.2 如果没有安装brew,可以用国内版本安装

# 官网地址:https://brew.sh/index_zh-cn.html
# 官网安装命令:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# 国内版本:(根据提示选择安装下载镜像、执行脚本选择Y)
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
1
2
3
4
5
6

# 1.3 查询需要安装的nginx包是否存在

brew search nginx
1

# 1.4 安装nginx

brew install nginx
1

# 1.5 安装成功后,查看nginx安装目录

brew info nginx
1
服务目录:open /usr/local/var/www
配置目录:open /usr/local/etc/nginx
1
2

# 1.6 启动nginx

nginx
1

打开浏览器,访问 http://localhost:8080/

# 1.7 nginx 常用操作

#重启
nginx -s reload
#关闭
nginx -s stop
1
2
3
4

# 2 LINUX上安装nginx

# 2.1 官网地址

http://nginx.org
http://nginx.org/en/download.html
1
2

# 2.2 下载解压

# 执行下载: 
wget http://nginx.org/download/nginx-1.18.0.tar.gz

# 然后把下载好的文件进行解压:
tar -zxvf nginx-1.18.0.tar.gz

# 进入nginx目录:
cd nginx-1.18.0
1
2
3
4
5
6
7
8

# 2.3 安装必要插件

运行命令:

yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel
1
gcc 可以编译 C,C++,Ada,Object C和Java等语言
pcre pcre-devel pcre是一个perl库,包括perl兼容的正则表达式库,nginx的http模块使用pcre来解析正则表达式
zlib zlib-devel zlib库提供了很多种压缩和解压缩方式nginx使用zlib对http包的内容进行gzip
openssl openssl-devel openssl是web安全通信的基石
1
2
3
4

# 2.4 配置及安装

1.新建个组,用于运行nginx

groupadd www
1

2.添加个www用户,并为不能用于登录的

useradd -g www www -s /bin/false
1

3.配置

./configure --prefix=/usr/local/nginx \
--user=www \
--group=www \
--with-http_ssl_module \
--with-stream \
--with-stream_ssl_module \
--with-stream_realip_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-http_realip_module \
--with-http_sub_module \
--with-pcre
1
2
3
4
5
6
7
8
9
10
11
12

4.安装

make && make install
1

5.测试配置文件是否成功

/usr/local/nginx/sbin/nginx -t
1

6.启动nginx

/usr/local/nginx/sbin/nginx
1

# 3 nginx.conf 示例

#user  nobody;
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  localhost;
        location / {
            alias  /louis/blog/;
            # root   html;
            # index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#安装部署#Nginx
博客构建
Nginx Https证书安装

← 博客构建 Nginx Https证书安装→

最近更新
01
SpringBoot
10-21
02
Spring
10-20
03
Sentinel
10-14
更多文章>
Copyright © 2022-2023 Louis | 粤ICP备2022060093号-1
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式