linux 轻松编译安装nginx

#安装编译环境
yum -y install gcc gcc-c++
#安装pcre软件包(使nginx支持http rewrite模块)

yum install -y pcre pcre-devel

#安装openssl-devel(使nginx支持ssl)

yum install -y openssl openssl-devel

#安装zlib

yum install -y zlib zlib-devel

#创建用户nginx

useradd nginx

passwd nginx

#安装nginx
#下载nginx包
wget http://nginx.org/download/nginx-1.18.0.tar.gz
#解压nginx
tar xzf nginx-1.18.0.tar.gz -C /usr/local/
#cd到解压路径
cd /usr/local/
#下载nginx所需的模块
wget https://github.com/openresty/echo-nginx-module/archive/v0.61.tar.gz
#解压模块
tar xf v0.61.tar.gz
#配置参数
./configure --prefix=/usr/local/nginx --group=nginx --user=nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/tmp/nginx/client_body --http-proxy-temp-path=/tmp/nginx/proxy --http-fastcgi-temp-path=/tmp/nginx/fastcgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-pcre --with-http_realip_module --with-stream # --add-module=./echo-nginx-module-0.61 --add-module=./ngx_req_status-master
#编译安装
make && make install
#查看nginx版本
/usr/local/nginx/sbin/nginx -V
#检测nginx配置文件是否正确
/usr/local/nginx/sbin/nginx -t
#创建所需的目录
mkdir -p /tmp/nginx
#启动nginx服务
/usr/local/nginx/sbin/nginx

猜你喜欢

转载自blog.csdn.net/qq_48229321/article/details/109062420