Linux Nginx安装

Nginx - 安装步骤

一、下载nginx安装包

官方下载地址

https://nginx.org/en/download.html

执行下载:

wget https://nginx.org/download/nginx-1.18.0.tar.gz

二、安装nginx

2.1 解压nginx安装包

tar -zxvf nginx-1.18.0.tar.gz

解压后进入nginx目录 生成安装文件

--prefix nginx安装目录

./configure --prefix=/usr/local/nginx

运行后发现报错

错误信息:

./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.
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.

2.2 安装依赖包

pcre 、 pcre-devel 、zlib-devel

yum install -y pcre pcre-devel zlib-devel

依赖包安装成功后继续执行编译命令

 Configuration summary
 + using system PCRE library
 + OpenSSL library is not used
 + using system zlib library
 nginx path prefix: "/usr/local/nginx-1.18.0/"
 nginx binary file: "/usr/local/nginx-1.18.0//sbin/nginx"
 nginx modules path: "/usr/local/nginx-1.18.0//modules"
 nginx configuration prefix: "/usr/local/nginx-1.18.0//conf"
 nginx configuration file: "/usr/local/nginx-1.18.0//conf/nginx.conf"
 nginx pid file: "/usr/local/nginx-1.18.0//logs/nginx.pid"
 nginx error log file: "/usr/local/nginx-1.18.0//logs/error.log"
 nginx http access log file: "/usr/local/nginx-1.18.0//logs/access.log"
 nginx http client request body temporary files: "client_body_temp"
 nginx http proxy temporary files: "proxy_temp"
 nginx http fastcgi temporary files: "fastcgi_temp"
 nginx http uwsgi temporary files: "uwsgi_temp"
 nginx http scgi temporary files: "scgi_temp"

安装成功!!!

在这里插入图片描述

2.3 开始安装

1、make

2、编译成功后,执行安装make install

3、安装成功后,进入nginx安装目录:/usr/local/nginx

查看nginx版本./sbin/nginx -v

三、命令

关闭:./nginx -s stop
启动:./nginx
配置文件更新测试: ./nginx -t
重新加载配置文件: ./nginx -s reload

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值