返回

CentOS 安装 Nginx

软件小窝
2023-08-25 23:11:042.38k 字预计阅读时长 4 分钟

安装依赖

yum install gcc
yum install pcre pcre-devel
yum install openssl openssl-devel
yum install zlib zlib-devel
yum -y install libxml2 libxml2-dev
yum -y install libxslt-devel
yum install gd gd-devel

编译

Tips:如果不指定 --prefix 目录,默认安装到 `/usr/local/nginx`

./configure --prefix=xxx --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_xslt_module=dynamic --with-http_image_filter_module --with-http_image_filter_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_auth_request_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-stream --with-stream=dynamic --with-stream_ssl_module --with-stream_realip_module --with-stream_ssl_preread_module --with-compat
上面命令展开
./configure --prefix=xxxx
--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_xslt_module=dynamic 
--with-http_image_filter_module 
--with-http_image_filter_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_auth_request_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-stream 
--with-stream=dynamic 
--with-stream_ssl_module 
--with-stream_realip_module 
--with-stream_ssl_preread_module 
--with-compat 

安装

make
make install

运行 / 重载  / 停止

启动
xxx/xxx/sbin/nginx
重载
xxx/xxx/sbin/nginx -s reload
停止
xxx/xxx/sbin/nginx -s stop

本篇文章用到的软件

  • 1.22.1Nginx
    Nginx
    HTTP和反向代理web服务器
    下载