![如何启动openresty](https://linux22.com/image/226958/%E5%A6%82%E4%BD%95%E5%90%AF%E5%8A%A8openresty.png)
当我尝试在 CentOS 7.9 中启动 openresty 时,告诉我 nginx 没有启动:
[root@k8sslave01 letsencrypt]# systemctl status openresty.service
● openresty.service - The OpenResty Application Platform
Loaded: loaded (/usr/lib/systemd/system/openresty.service; disabled; vendor preset: disabled)
Active: failed (Result: timeout) since Thu 2023-11-30 18:28:25 CST; 2min 50s ago
Process: 31432 ExecStart=/usr/local/openresty/nginx/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 31430 ExecStartPre=/usr/local/openresty/nginx/sbin/nginx -t (code=exited, status=0/SUCCESS)
Nov 30 18:26:55 k8sslave01 systemd[1]: Starting The OpenResty Application Platform...
Nov 30 18:26:55 k8sslave01 nginx[31430]: nginx: the configuration file /usr/local/openresty/nginx/conf/nginx.conf syntax is ok
Nov 30 18:26:55 k8sslave01 nginx[31430]: nginx: configuration file /usr/local/openresty/nginx/conf/nginx.conf test is successful
Nov 30 18:26:55 k8sslave01 systemd[1]: Can't open PID file /usr/local/openresty/nginx/logs/nginx.pid (yet?) after start: No such file or directory
Nov 30 18:28:25 k8sslave01 systemd[1]: openresty.service start operation timed out. Terminating.
Nov 30 18:28:25 k8sslave01 systemd[1]: Failed to start The OpenResty Application Platform.
Nov 30 18:28:25 k8sslave01 systemd[1]: Unit openresty.service entered failed state.
Nov 30 18:28:25 k8sslave01 systemd[1]: openresty.service failed.
当我启动 nignx 时,openresty 配置与 nginx 不兼容:
[root@k8sslave01 letsencrypt]# systemctl status nginx.service
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2023-11-30 18:29:10 CST; 2min 52s ago
Process: 32613 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=1/FAILURE)
Process: 32611 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Nov 30 18:29:10 k8sslave01 systemd[1]: Starting The nginx HTTP and reverse proxy server...
Nov 30 18:29:10 k8sslave01 nginx[32613]: nginx: [emerg] unknown "allowed" variable
Nov 30 18:29:10 k8sslave01 nginx[32613]: nginx: configuration file /etc/nginx/nginx.conf test failed
Nov 30 18:29:10 k8sslave01 systemd[1]: nginx.service: control process exited, code=exited status=1
Nov 30 18:29:10 k8sslave01 systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
Nov 30 18:29:10 k8sslave01 systemd[1]: Unit nginx.service entered failed state.
Nov 30 18:29:10 k8sslave01 systemd[1]: nginx.service failed.
我将配置文件放在/etc/nginx/conf.d
.我应该怎么做才能解决这个问题?这是 openresty 版本:
[root@k8sslave01 letsencrypt]# openresty -V
nginx version: openresty/1.21.4.3
built by gcc 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC)
built with OpenSSL 1.1.1s 1 Nov 2022
TLS SNI support enabled
configure arguments: --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.2 --add-module=../echo-nginx-module-0.63 --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.33 --add-module=../ngx_lua-0.10.25 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.34 --add-module=../array-var-nginx-module-0.06 --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.13 --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-cc='ccache gcc -fdiagnostics-color=always' --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-compat --with-stream --with-http_ssl_module
答案1
您不能将 openresty 配置与库存 nginx 一起使用。
换句话说,修复你的 openresty,而不是尝试将内容复制到其他守护进程。