FreeBSD编译安装openresty
环境信息
OS Version : freeBSD 14
下载openresty
freebsd 自带的fetch太慢了,还是用回wget吧.
wget https://openresty.org/download/openresty-1.25.3.2.tar.gz
创建运行用户
创建一个普通用户www用来作为openresty运行的用户.
adduser www
安装依赖
- 下面依赖包根据实时版本安装,下面列出来的版本号不是一成不变的.
root@nl:/data/openresty-1.25.3.2 # pkg install cmake-3.30.5 perl5-5.36.3_2 gcc-13_5 make++-2.0_1 pcre-8.45_4 zlib-ng-2.2.2 openssl-3.0.15,1 git-2.46.2 make++-2.0_1 gmake-4.4.1
-
brotli
git clone --recurse-submodules https://github.com/google/ngx_brotli cd ngx_brotli/deps/brotli mkdir out && cd out cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS="-Ofast -m64 -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections" -DCMAKE_CXX_FLAGS="-Ofast -m64 -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections" -DCMAKE_INSTALL_PREFIX=./installed .. cmake --build . --config Release --target brotlienc # nginx vhost config ... #启用brotli压缩 brotli on; brotli_comp_level 6; brotli_buffers 16 8k; brotli_min_length 20; # 注意要配置压缩的文件类型(content-type) brotli_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/svg+xml application/wasm application/octet-stream; ..
编译安装
root@nl:/data/openresty-1.25.3.2 # ./configure --prefix=/usr/local/openresty \
--with-http_ssl_module \
--with-http_gzip_static_module \
--with-http_realip_module \
--with-stream \
--with-stream_ssl_module \
--with-http_secure_link_module \
--with-http_sub_module \
--with-http_v2_module \
--with-http_dav_module \
--add-module=/data/ngx_brotli
root@nl:/data/openresty-1.25.3.2 # gmake && gmake install
root@localhost:/data/software/openresty-1.25.3.2 # ln -snf /usr/local/openresty/nginx/sbin/nginx /usr/local/bin/nginx
验证安装
root@localhost:/data/software/openresty-1.25.3.2 # nginx -v
nginx version: openresty/1.25.3.2
root@localhost:/data/software/openresty-1.25.3.2 # nginx
root@localhost:/usr/local/openresty/nginx/conf # netstat -anl | grep 80
tcp4 0 0 192.168.30.200.80 192.168.30.120.43858 FIN_WAIT_2
tcp4 0 0 192.168.30.200.80 192.168.30.120.56748 TIME_WAIT
tcp4 0 0 *.80 *.* LISTEN
tcp4 0 36 192.168.30.200.22 192.168.30.120.38036
root@localhost:/usr/local/openresty/nginx/conf # ps aux | grep nginx
root 18668 0.0 1.1 23596 10580 - Is 07:29 0:00.00 nginx: master process nginx (nginx)
www 18669 0.0 1.5 30252 15032 - S 07:29 0:00.01 nginx: worker process (nginx)
root 18678 0.0 0.2 12808 2000 0 S+ 07:31 0:00.00 grep nginx