请稍等...

小波Note

四川 · 成都市多云16 ℃
中文

CentOS 安装 Nginx

成都 (cheng du)2023/1/1 14:39:452.22k预计阅读时间 7 分钟收藏Ctrl + D / ⌘ + D
cover
IT FB(up 主)
后端开发工程师

安装依赖

bash
        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

    

编译

提示

进入到文件解压的目录 可以指定 --prefix 目录,默认安装到 /usr/local/nginx

bash
        ./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

    

上面的命令展开如下,可以根据自己的需求删减

bash
        ./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

    

安装

bash
        make
make install

    

运行 / 重载 / 停止

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