Centos下nginx源码编译安装

 83
使用root权限执行

1、前置准备,增加nginx用户和目录
useradd -M -g root nginx
mkdir /etc/nginx
mkdir /var/cache/nginx
2、安装源码编译器
yum install gcc gcc-c++ make unzip pcre pcre-devel zlib zlib-devel libxml2 libxml2-devel readline readline-devel ncurses ncurses-devel perl-devel perl-ExtUtils-Embed openssl-devel -y
3、下载nginx源码
cd /opt
wget http://nginx.org/download/nginx-1.19.2.tar.gz
//如果wget未安装执行wget安装命令后重试
yum install -y wget
4、解压nginx
tar -zxvf nginx-1.19.2.tar.gz
5、进入nginx模块目录,下载依赖模块,若不需要可跳过
wget https://github.com/openresty/echo-nginx-module/archive/v0.62.tar.gz //下载echo模块
wget https://github.com/openresty/headers-more-nginx-module/archive/v0.33.tar.gz //下载headers_more模块
tar -zxvf v0.62.tar.gz //解压echo模块
tar -zxvf v0.33.tar.gz //解压headers_more模块
6、配置编译参数,并编译程序
cd /opt/nginx-1.19.2
./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-cpp_test_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --add-module=/opt/echo-nginx-module-0.62 --add-module=/opt/headers-more-nginx-module-0.33
make -j4 //编译
make install //安装
7、启动nginx
nginx
接下来就可以愉快的玩耍了
回帖