Please wait...

小波Note

四川 · 成都市14 ℃
English

Install Nginx on CentOS

成都 (cheng du)1/1/2023, 2:39:45 PM2.42kEstimated reading time 8 minFavoriteCtrl + D / ⌘ + D
cover
IT FB(up 主)
Back-end development engineer

Install dependencies

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

    

Compile

Tips

Enter the directory where the file is unzipped You can specify the --prefix directory, which is installed by default to /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

    

The above command is expanded as follows, and you can delete it according to your own needs

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

    

Install

bash
        make
make install

    

Run / Reload / Stop

bash
        // Start
xxx/xxx/sbin/nginx
// Reload
xxx/xxx/sbin/nginx -s reload
// Stop
xxx/xxx/sbin/nginx -s stop