萌萌の初音
萌萌の初音
发布于 2022-09-03 / 2675 阅读
0

Centos下安装Nginx记录

安装前提

由于web服务器nginx版本有点低,并且还在用http1.1,决定对nginx进行升级,将操作进行记录;

安装步骤

1. 下载nginx包

通过wget下载,并用tar进行解压:

wget https://nginx.org/download/nginx-1.23.1.tar.gz
tar -xzvf nginx-1.23.1.tar.gz
2.进入解压目录并配置configure

打算把module都装全就这么长一截了,–prefix=参数是你的nginx安装目录,在你执行make install时生效。–add-module=参数是nginx没有自带额外的module,–with是启用,–without是禁用。

cd nginx-1.23.1/
./configure --prefix=/opt/nginx --add-module=../nginx-rtmp-module --with-select_module --with-poll_module --with-threads --with-file-aio --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_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_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_perl_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-stream --with-stream_ssl_module --with-stream_realip_module --with-stream_geoip_module --with-google_perftools_module --with-cpp_test_module --with-compat --with-pcre --with-pcre-jit
3.configure时所需的依赖包
yum insatll libxml2 libxml2-dev libxslt-devel gd gd-devel perl-devel perl-ExtUtils-Embed GeoIP-devel gperftools gcc-c++
4.修改Makefile文件

Makefile需要修改参数才能编译通过:

vim objs/Makefile

把CFLAGS参数改为“CFLAGS = -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -g -fPIC”

5.编译并安装
make && make install
/opt/nginx/sbin/nginx

稍等片刻,nginx就安装完成了。

6.以后要升级nginx忘记之前的安装参数怎么办?
./nginx -V