【问题标题】:nginx: unknown directive "redis_pass" in /etc/nginx/common/redis.confnginx:/etc/nginx/common/redis.conf 中的未知指令“redis_pass”
【发布时间】:2017-07-24 04:52:29
【问题描述】:

一个团队成员设置了一个虚拟环境,在端口 8000 上运行了一些东西(以及其他一些他可能没有告诉我的东西),现在 nginx 将无法启动,即使在重新启动后也是如此。

journalctl -xn开始日志:

-- Unit nginx.service has begun starting up.
Mar 03 18:39:23 digitalocean nginx[954]: nginx: [emerg] unknown directive "redis_pass" in /etc/nginx/common/redis.conf:27
Mar 03 18:39:23 digitalocean nginx[954]: nginx: configuration file /etc/nginx/nginx.conf test failed
Mar 03 18:39:23 digitalocean systemd[1]: nginx.service: control process exited, code=exited status=1
Mar 03 18:39:23 digitalocean systemd[1]: Failed to start A high performance web server and a reverse proxy server.
-- Subject: Unit nginx.service has failed

/etc/nginx/common/redis.conf的内容是:

# Redis NGINX CONFIGURATION
# DO NOT MODIFY, ALL CHANGES LOST AFTER UPDATE EasyEngine (ee)
set $skip_cache 0;
# POST requests and URL with a query string should always go to php
if ($request_method = POST) {
  set $skip_cache 1;
}
if ($query_string != "") {
  set $skip_cache 1;
}
# Don't cache URL containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
  set $skip_cache 1;
}
# Don't use the cache for logged in users or recent commenter or customer with items in cart
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in|woocommerce_items_in_cart") {
  set $skip_cache 1;
}
# Use cached or actual file if they exists, Otherwise pass request to WordPress
location / {
  try_files $uri $uri/ /index.php?$args;
}

location /redis-fetch {
    internal  ;
    set  $redis_key $args;
    redis_pass  redis;
}
location /redis-store {
    internal  ;
    set_unescape_uri $key $arg_key ;
    redis2_query  set $key $echo_request_body;
    redis2_query expire $key 14400;
    redis2_pass  redis;

}

location ~ \.php$ {
  set $key "nginx-cache:$scheme$request_method$host$request_uri";
  try_files $uri =404;

  srcache_fetch_skip $skip_cache;
  srcache_store_skip $skip_cache;

  srcache_response_cache_control off;

  set_escape_uri $escaped_key $key;

  srcache_fetch GET /redis-fetch $key;
  srcache_store PUT /redis-store key=$escaped_key;

  more_set_headers 'X-SRCache-Fetch-Status $srcache_fetch_status';
  more_set_headers 'X-SRCache-Store-Status $srcache_store_status';

  include fastcgi_params;
  fastcgi_pass php;
}

【问题讨论】:

  • 请发nginx.conf的内容。

标签: nginx easy-engine


【解决方案1】:

我认为您没有安装 ngx_redis 模块。您可以通过以下方式进行检查:

nginx -V

【讨论】:

  • 如何安装?
猜你喜欢
  • 2020-03-30
  • 2021-10-27
  • 2021-08-30
  • 2013-10-10
  • 2020-02-17
  • 1970-01-01
  • 2018-11-23
  • 1970-01-01
  • 2011-12-12
相关资源
最近更新 更多