编译安装nginx1.20.1

在centos 6.x或者7.x环境下,安装nginx

1,首先安装必须的依赖库

yum -y install gcc gcc-c++ make openssl openssl-devel glibc glibc-devel zlib zlib-devel pcre pcre-devel lua-devel unzip wget gd gd-devel perl-devel perl-ExtUtils-Embed GeoIP GeoIP-devel GeoIP-data libxml2-devel.x86_64 libxslt-devel.x86_64

2,下载nginx的源码包1.20.1

编译安装

./configure --prefix=/usr/local/nginx --user=nginx --group=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_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_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-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-debug --with-http_flv_module

make -j 2 #make with 2 cpus

make install #开始安装

3.1创建nginx 用户以及软链接

useradd -s /sbin/nologin -M nginx

ln -sf /usr/local/nginx/sbin/nginx /usr/sbin/nginx

3.2 启动

nginx -c /usr/local/nginx/conf/nginx.conf