JAVA和Nginx 教程大全

网站首页 > 精选教程 正文

小白入门必知必会-Nginx编译方式安装

wys521 2024-09-14 13:39:43 精选教程 21 ℃ 0 评论

一 Nginx基础

1.1 简介

Nginx是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务。

Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Rambler.ru站点开发的,公开版本1.19.6发布于2020年12月15日。

其将源代码以类BSD许可证的形式发布,因它的稳定性、丰富的功能集、简单的配置文件和低系统资源的消耗而闻名。2022年01月25日,nginx 1.21.6发布。

Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,在BSD-like 协议下发行。其特点是占有内存少,并发能力强,事实上nginx的并发能力在同类型的网页服务器中表现较好。

1.2 官网地址

https://nginx.org

1.3 下载地址

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

Mainline version:主线版本,通常是最新版本,加入一些最新的功能,没有经过太多的测试,生产环境中一般不会使用

Stable version:稳定版本,通常是经过官方测试的,是官方认为相对稳定的版本,生产环境通常会使用。

Legacy version:历史版本,当新的稳定版出现,那么原先的稳定版本就会被归类到“历史版本”中去。

二 编译安装Nginx

2.1 安装wget

yum install wget -y

2.2 安装包下载及解压

cd /tmp

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

tar xf nginx-1.22.1.tar.gz

cd nginx-1.22.1

CHANGES:可以查看当前的nginx修复了哪些bug、做了哪些变更、新增了哪些功能。

CHANGES.ru:CHANGES文件的俄文版,因为nginx是俄国人发明的。

conf:nginx配置文件的模板文件,编译安装时这些文件最终会被拷贝安装到安装目录中。

html:静态页面的模板文件

src:源代码目录

man:帮助文档的目录

contrib:目录中的vim目录可以帮助我们在使用vim编辑nginx配置文件时提供语法高亮功能。

2.3 安装编辑器及依赖包

yum install -y gcc gcc-c++ glibc make pcre-devel zlib-devel openssl-devel libxslt-devel GeoIP-devel perl-ExtUtils-Embed

2.4 编译

mkdir /web

cd /tmp/nginx-1.22.1

./configure --prefix=/web/nginx --with-file-aio --with-http_auth_request_module --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_geoip_module=dynamic --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_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module

echo $?

2.5 安装

make && make install

echo $?

2.6 实现语法高亮功能

cp -r contrib/vim/* /usr/share/vim/vimfiles/

2.7 启动nginx

检测语法

/web/nginx/sbin/nginx -t

查看版本

启动nginx

/web/nginx/sbin/nginx

查看nginx状态

ps -ef|grep nginx

2.8 浏览器访问

默认监听端口为80

http://192.168.0.99/

至此Nginx安装完成,感谢观察,如果对您有帮助,麻烦动动小手点点赞,坚持下去,一起努力加油吧。

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表