Kevin's blog Kevin's blog
首页
  • AI基础
  • RAG技术
  • 提示词工程
  • Wireshark抓包
  • 常见问题
  • 数据库
  • 代码技巧
  • 浏览器
  • 手册教程
  • 技术应用
  • 流程规范
  • github技巧
  • git笔记
  • vpn笔记
  • 知识概念
  • 学习笔记
  • 环境搭建
  • linux&运维
  • 微服务
  • 经验技巧
  • 实用手册
  • arthas常用
  • spring应用
  • javaAgent技术
  • 网站
友情链接
  • 分类
  • 标签
  • 归档

Kevin

你可以迷茫,但不可以虚度
首页
  • AI基础
  • RAG技术
  • 提示词工程
  • Wireshark抓包
  • 常见问题
  • 数据库
  • 代码技巧
  • 浏览器
  • 手册教程
  • 技术应用
  • 流程规范
  • github技巧
  • git笔记
  • vpn笔记
  • 知识概念
  • 学习笔记
  • 环境搭建
  • linux&运维
  • 微服务
  • 经验技巧
  • 实用手册
  • arthas常用
  • spring应用
  • javaAgent技术
  • 网站
友情链接
  • 分类
  • 标签
  • 归档
  • 手册教程

  • 技术应用

    • 工作杂货

    • 技巧备忘

      • IntelliJ IDEA
      • Git其他仓库分支合并
      • Mac新建软连接
      • 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 示例
      • SSH连接Github仓库
      • 博客构建
  • 流程规范

  • GitHub技巧

  • VPN

  • Git笔记

  • 实用手册
  • 技术应用
  • 技巧备忘
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  /Users/luoxiaofeng/githubprojects/blogweb/gh-pages/;
            # root   html;
            # index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
    include servers/*;
}
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
27
上次更新: 2022/06/02, 11:20:10
Mac新建软连接
SSH连接Github仓库

← Mac新建软连接 SSH连接Github仓库→

最近更新
01
AI是如何学习的
06-05
02
chatGpt提示原则
06-05
03
提示词工程实践指南
06-05
更多文章>
| Copyright © 2022-2025 Kevin | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式