前言 {#前言}
简单记录下,编译用到的一部分代码.
以下代码运行环境: ubuntu x86_64
依赖 {#依赖}
|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1 2
| sudo apt update && sudo apt upgrade && sudo apt autoremove sudo apt install -y build-essential ca-certificates zlib1g-dev libpcre3 libpcre3-dev tar unzip libssl-dev wget curl libtool git cmake ninja-build mercurial libunwind-dev pkg-config golang # 编译工具&依赖库
|
编译 {#编译}
brotli 压缩
|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1 2 3 4 5 6
| git clone --depth=1 --recurse-submodules -j8 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 -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections" -DCMAKE_CXX_FLAGS= "-Ofast -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections" -DCMAKE_INSTALL_PREFIX=./installed .. cmake --build . --config Release --target brotlienc cd ../../../..
|
openssl
|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1 2 3 4 5 6 7
| git clone -b master --depth=1 https://github.com/openssl/openssl.git cd openssl ./Configure --prefix=/usr/src/openssl --openssldir=/usr/src/openssl make install ldconfig openssl version -a cd ../
|
ngx_security_headers
|-----------|-------------------------------------------------------------------------------------------------------|
| 1
| git clone --depth=1 --recurse-submodules https://github.com/GetPageSpeed/ngx_security_headers
|
nginx
|---------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1 2 3 4 5 6 7 8 9
| hg clone https://hg.nginx.org/nginx cd nginx make clean ./auto/configure --prefix=/etc/nginx --user=www-data --group=www-data --with-pcre --add-module=../ngx_brotli --add-module=../ngx_security_headers --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/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 --with-http_v2_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-stream_realip_module --with-compat --with-threads --with-file-aio --with-http_ssl_module --with-http_gzip_static_module --with-http_gunzip_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-http_slice_module --with-http_sub_module --with-http_flv_module --with-http_addition_module --with-http_realip_module --with-http_mp4_module --with-http_dav_module --with-http_v3_module \ --with-cc-opt= "-I /usr/src/openssl/include" \ --with-ld-opt= "-L /usr/src/openssl/lib64" make make install cd ../
|
完成,可以删除这些文件夹,也可以不用删除,方便下次编译(记得 git pull
)
tips: 如果在 make install
安装后想要卸载,命令: make uninstall