打开官网页面点击 Download ,会跳转到一个下载的页面

image_2023-01-28-09-02-32

点击下载 Linux 版的 Nginx,之后上传到 Linux 中

解压 Nginx

image_2023-01-28-09-22-01

解压完成后进入到解压后的目录中

image_2023-01-28-09-23-03

目录中有一个 configure 脚本,用这个脚本来安装,安装过程中需要一些依赖

执行该脚本进行安装可能会报错提示需要的依赖没有找到的错误

需要的依赖:

  • gcc:执行命令 sudo yum install -y gcc

错误提示:

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

缺少 pcre

  • pcre: 执行命令: sudo yum install -y pcre pcre-devel

同样的报错可能缺少 zlib库

  • zlib: 执行命令: sudo yum install -y zlib zlib-devel

报错解决!!执行下一步操作

image_2023-01-28-09-34-26

执行 make

image_2023-01-28-09-36-32

执行 sudo make install

image_2023-01-28-09-38-18

安装成功

启动 Nginx 进入 sbin 目录在这个目录中有一个可执行的文件为 nginx

image_2023-01-28-09-39-54

启动 Nginx