Linux安装nginx-1.22.0

一、准备资源

1、官网下载&命令下载

官网下载: nginx-1.22.0.tar.gz

也可以通过wget命令下载

2、提前准备nginx编译资源

yum -y install openssl openssl-devel gd gd-devel pcre-devel zlib-devel
yum -y install gcc-c++

二、开始安装

1、确保系统有wget命令

yum install wget -y

2、获取解压包

wget http://nginx.org/download/nginx-1.22.0.tar.gz

3、解压

tar -zvxf nginx-1.22.0.tar.gz

4、进入解压目录

cd nginx-1.22.0

5、编译前配置

./configure \
--with-pcre \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-http_image_filter_module \
--with-http_slice_module \
--with-mail \
--with-threads \
--with-file-aio \
--with-stream \
--with-mail_ssl_module \
--with-stream_ssl_module 
这是一个用于配置Nginx编译选项的命令,./configure 是用于生成Makefile的脚本,后跟一系列配置参数。让我们逐步解释每个参数的含义:

--prefix=/usr/local/nginx: 指定Nginx安装的根目录路径为/usr/local/nginx。
这意味着Nginx将会安装到该目录下(默认此路径,可以不填写。)。
--with-pcre: 启用PCRE(Perl Compatible Regular Expressions)库支持。PCRE库用于支持正则表达式。
--with-http_ssl_module: 启用HTTP SSL模块,使Nginx支持HTTPS协议。
--with-http_v2_module: 启用HTTP/2模块,以支持HTTP/2协议。
--with-http_realip_module: 启用HTTP RealIP模块,用于获取真实客户端的IP地址。
--with-http_addition_module: 启用HTTP Addition模块,用于添加内容到HTTP响应体中。
--with-http_sub_module: 启用HTTP Substitution模块,用于替换HTTP响应体中的文本。
--with-http_dav_module: 启用HTTP DAV模块,以支持WebDAV协议。
--with-http_flv_module: 启用HTTP FLV模块,用于流式传输Flash视频文件。
--with-http_mp4_module: 启用HTTP MP4模块,用于处理MP4格式的视频文件。
--with-http_gunzip_module: 启用HTTP Gunzip模块,用于解压缩响应体。
--with-http_gzip_static_module: 启用HTTP Gzip Static模块,用于在服务器端压缩静态文件。
--with-http_random_index_module: 启用HTTP Random Index模块,用于设置随机索引文件。
--with-http_secure_link_module: 启用HTTP Secure Link模块,用于生成保密链接。
--with-http_stub_status_module: 启用HTTP Stub Status模块,用于获取Nginx当前状态的简单页面。
--with-http_auth_request_module: 启用HTTP Auth Request模块,用于向其他服务器发出认证请求。
--with-http_image_filter_module: 启用HTTP Image Filter模块,用于调整和过滤图像。
--with-http_slice_module: 启用HTTP Slice模块,用于按范围提供文件的一部分。
--with-mail: 启用Mail模块,以支持Nginx作为邮件代理服务器。
--with-threads: 启用线程支持。
--with-file-aio: 启用文件异步I/O支持。
--with-stream: 启用Stream模块,用于TCP和UDP代理。
--with-mail_ssl_module: 启用Mail SSL模块,以支持SSL加密的邮件传输。
--with-stream_ssl_module: 启用Stream SSL模块,以支持SSL加密的TCP和UDP代理。

6、执行编译并安装

make && make install

7、启动nginx

sudo /usr/local/nginx/sbin/nginx

8、查看nginx进程

ps -ef | grep nginx

9、防火墙开放80端口

firewall-cmd --permanent --add-port=80/tcp

#重启防火墙
firewall-cmd --reload

10、访问80端口测试

浏览器输入服务器地址会默认访问80端口,出现如下界面代表安装成功

想要设置开机自启动请访问此链接

nginx脚本自启动设置

  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值