Openresty 部署 - nginx && centos编译 系统软件 docker


https://hub.docker.com/r/openresty/openresty

https://openresty.org/cn/download.html


docker run -d  --name openresty  --restart=always -p 88:80 -v /data/docker/nginx/openresty/nginx.conf:/usr/local/openresty/nginx/nginx.conf:ro -v /data/docker/nginx/openresty/conf.d:/etc/nginx/conf.d:ro  -v /data/file/pagespeed:/var/ngx_pagespeed_cache -v /data/site:/data/site  -v /data/docker:/data/docker  -v /data/file:/data/file  openresty/openresty:bullseye-fat


docker exec -it  openresty /bin/bash

apt-get update -y

apt-get install -y wget vim net-tools curl git cron zip unzip 

apt-get install -y cmake golang python 

apt-get install -y build-essential autoconf automake libtool  gcc make gdb

cd  /data/site/htmltoo.f/htmltoo.soft/src/common/openresty

wget  https://openresty.org/download/openresty-1.21.4.1.tar.gz

tar -xzvf   openresty-1.21.4.1.tar.gz  && rm -rf   openresty-1.21.4.1.tar.gz

git clone -b lts https://github.com/ADD-SP/ngx_waf.git

cd  ngx_waf

-选择使用静态模块还是动态模块

sh assets/guide.sh

# It is recommended that you use dynamic modules.

-如果输出上面这行则建议使用动态模块。

# It is recommended that you use static modules.

-如果输出上面这行则建议使用静态模块。

---static modules---configure---

nginx -V

--prefix=/usr/local/openresty/nginx --with-cc-opt='-O2 -DNGX_LUA_ABORT_AT_PANIC -I/usr/local/openresty/zlib/include -I/usr/local/openresty/pcre/include -I/usr/local/openresty/openssl111/include' --add-module=../ngx_devel_kit-0.3.1 --add-module=../echo-nginx-module-0.62 --add-module=../xss-nginx-module-0.06 --add-module=../ngx_coolkit-0.2 --add-module=../set-misc-nginx-module-0.33 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.09 --add-module=../srcache-nginx-module-0.32 --add-module=../ngx_lua-0.10.21 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.33 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.19 --add-module=../redis2-nginx-module-0.15 --add-module=../redis-nginx-module-0.3.9 --add-module=../ngx_stream_lua-0.0.11 --with-ld-opt='-Wl,-rpath,/usr/local/openresty/luajit/lib -L/usr/local/openresty/zlib/lib -L/usr/local/openresty/pcre/lib -L/usr/local/openresty/openssl111/lib -Wl,-rpath,/usr/local/openresty/zlib/lib:/usr/local/openresty/pcre/lib:/usr/local/openresty/openssl111/lib' --with-pcre-jit --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_v2_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_auth_request_module --with-http_secure_link_module --with-http_random_index_module --with-http_gzip_static_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-threads --with-stream --with-http_ssl_module

apt-get update && apt-get install --yes flex  bison

cd  ../LuaJIT-2.1-20220411

make PREFIX=/usr/local/luajit

make install PREFIX=/usr/local/luajit

ln -sf luajit-2.1.0-beta3 /usr/local/luajit/bin/luajit

/sbin/ldconfig

cd  ../nginx-1.21.4

# ======永久生效的可以执行如下脚本======

cat >> /etc/profile <<END

export LUAJIT_LIB=/usr/local/luajit/lib

export LUAJIT_INC=/usr/local/luajit/include/luajit-2.1

END

# 使/etc/profile 立刻生效

source /etc/profile


./configure --prefix=/usr/local/openresty/nginx --with-cc-opt='-O2 -DNGX_LUA_ABORT_AT_PANIC -I/usr/local/openresty/zlib/include -I/usr/local/openresty/pcre/include -I/usr/local/openresty/openssl111/include' --add-module=../ngx_devel_kit-0.3.1 --add-module=../echo-nginx-module-0.62 --add-module=../xss-nginx-module-0.06 --add-module=../ngx_coolkit-0.2 --add-module=../set-misc-nginx-module-0.33 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.09 --add-module=../srcache-nginx-module-0.32 --add-module=../ngx_lua-0.10.21 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.33 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.19 --add-module=../redis2-nginx-module-0.15 --add-module=../redis-nginx-module-0.3.9 --add-module=../ngx_stream_lua-0.0.11 --with-ld-opt='-Wl,-rpath,/usr/local/openresty/luajit/lib -L/usr/local/openresty/zlib/lib -L/usr/local/openresty/pcre/lib -L/usr/local/openresty/openssl111/lib -Wl,-rpath,/usr/local/openresty/zlib/lib:/usr/local/openresty/pcre/lib:/usr/local/openresty/openssl111/lib' --with-pcre-jit --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_v2_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_auth_request_module --with-http_secure_link_module --with-http_random_index_module --with-http_gzip_static_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-threads --with-stream --with-http_ssl_module  --add-module=/data/site/htmltoo.f/htmltoo.soft/src/common/openresty/ngx_waf

sed -i 's/^\(CFLAGS.*\)/\1 -fstack-protector-strong -Wno-sign-compare/' objs/Makefile

make  &&  make -j$(nproc)


---最新nginx的30条日志

docker logs -f --tail="30" openresty


# centos平台

yum install pcre-devel openssl-devel gcc


1.编译安装

cd /opt/

wget https://openresty.org/download/openresty-1.21.4.1.tar.gz

tar -xzvf openresty-1.21.4.1.tar.gz

cd openresty-1.21.4.1/


./configure --prefix=/usr/local/openresty/ \

--with-luajit \

--without-http_redis2_module \

--with-http_iconv_module \

--with-pcre-jit \

--with-ipv6 \

--with-http_realip_module \

--with-http_ssl_module \

--with-http_stub_status_module \

--with-http_v2_module


make

make install


ln -s /usr/local/openresty/bin/resty /usr/local/bin/resty

ln -s /usr/local/openresty/bin/openresty /usr/local/bin/openresty

ln -s /usr/local/openresty/nginx/sbin/nginx /usr/local/bin/nginx


2.yum安装

yum install yum-utils

yum-config-manager --add-repo https://openresty.org/package/rhel/openresty.repo


yum install openresty

yum install resty


ln -s /usr/local/openresty/bin/resty /usr/local/bin/resty

ln -s /usr/local/openresty/bin/openresty /usr/local/bin/openresty

ln -s /usr/local/openresty/nginx/sbin/nginx /usr/local/bin/nginx


3.测试安装

nginx -v

resty -v

openresty -v


---启动

-检验配置

/usr/local/openresty/bin/openresty -t

-启动

/usr/local/openresty/bin/openresty

-停止

/usr/local/openresty/bin/openresty -s stop

-重新加载配置

/usr/local/openresty/bin/openresty -s reload



vim  /lib/systemd/system/openresty.service

[Unit]
Description=openresty - high performance web server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/openresty/bin/openresty -c /usr/local/openresty/nginx/conf/nginx.conf
ExecReload=/usr/local/openresty/bin/openresty -s reload
ExecStop=/usr/local/openresty/bin/openresty -s stop
[Install]
WantedBy=multi-user.target


-使配置文件生效

systemctl daemon-reload

-启动

systemctl start openresty

-停止

systemctl stop openresty

-重载配置

systemctl reload openresty

-重启

systemctl restart openresty




签名:这个人很懒,什么也没有留下!
最新回复 (0)
返回