<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Openresty on Net Boy</title>
    <link>https://lian.st/tags/openresty/</link>
    <description>Recent content in Openresty on Net Boy</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-gb</language>
    <lastBuildDate>Wed, 16 Oct 2024 23:32:15 +0800</lastBuildDate><atom:link href="https://lian.st/tags/openresty/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>FreeBSD编译安装openresty</title>
      <link>https://lian.st/posts/af40f8f4/</link>
      <pubDate>Wed, 16 Oct 2024 23:32:15 +0800</pubDate>
      
      <guid>https://lian.st/posts/af40f8f4/</guid>
      
      <description>&lt;h2 id=&#34;环境信息&#34;&gt;环境信息&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;OS Version : freeBSD 14
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;下载openresty&#34;&gt;下载openresty&lt;/h2&gt;
&lt;p&gt;freebsd 自带的fetch太慢了，还是用回wget吧.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;wget https://openresty.org/download/openresty-1.25.3.2.tar.gz
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;创建运行用户&#34;&gt;创建运行用户&lt;/h2&gt;
&lt;p&gt;创建一个普通用户&lt;code&gt;www&lt;/code&gt;用来作为&lt;code&gt;openresty&lt;/code&gt;运行的用户.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;adduser www
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;安装依赖&#34;&gt;安装依赖&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;下面依赖包根据实时版本安装，下面列出来的版本号不是一成不变的.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;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
&lt;/code&gt;&lt;/pre&gt;&lt;ol start=&#34;2&#34;&gt;
&lt;li&gt;
&lt;p&gt;brotli&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;git clone --recurse-submodules https://github.com/google/ngx_brotli
cd ngx_brotli/deps/brotli
mkdir out &amp;amp;&amp;amp; cd out
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=&amp;#34;-Ofast -m64 -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections&amp;#34; -DCMAKE_CXX_FLAGS=&amp;#34;-Ofast -m64 -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections&amp;#34; -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;  
..
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;编译安装&#34;&gt;编译安装&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;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 &amp;amp;&amp;amp; gmake install
root@localhost:/data/software/openresty-1.25.3.2 # ln -snf /usr/local/openresty/nginx/sbin/nginx /usr/local/bin/nginx
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;验证安装&#34;&gt;验证安装&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;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
&lt;/code&gt;&lt;/pre&gt;</description>
      
    </item>
    
  </channel>
</rss>
