magento - 由于VCC编译器错误: expected of 'acl' , 'sub', 'backend', Varnish 无法重新启动,

标签 magento varnish

我在亚马逊Linux上安装了 Varnish (3.0.5),但无法启动 Varnish

[root@ip-172-31-10-??? sysconfig]# service varnish start
Starting Varnish Cache:                                    [FAILED]

然后,我尝试更改默认的 Varnish vcl并尝试使用“varnishd -d -f/etc/sysconfig/varnish”来定位出现以下错误的问题
[root@ip-172-31-10-??? sysconfig]# varnishd -d -f /etc/sysconfig/varnish
Message from VCC-compiler:
Expected one of
        'acl', 'sub', 'backend', 'director', 'probe',  or 'import'
Found: 'NFILES' at
('input' Line 8 Pos 1)
NFILES=131072
######-------

Running VCC-compiler failed, exit 1

VCL compilation failed

完整的 Varnish 文件如下:
# Configuration file for varnish
#
# /etc/init.d/varnish expects the variable $DAEMON_OPTS to be set from this
# shell script fragment.
#

# Maximum number of open files (for ulimit -n)
NFILES=131072

# Locked shared memory (for ulimit -l)
# Default log size is 82MB + header
MEMLOCK=82000

# Maximum number of threads (for ulimit -u)
NPROCS="unlimited"

# Maximum size of corefile (for ulimit -c). Default in Fedora is 0
# DAEMON_COREFILE_LIMIT="unlimited"

# Set this to 1 to make init script reload try to switch vcl without restart.
# To make this work, you need to set the following variables
# explicit: VARNISH_VCL_CONF, VARNISH_ADMIN_LISTEN_ADDRESS,
# VARNISH_ADMIN_LISTEN_PORT, VARNISH_SECRET_FILE, or in short,
# use Alternative 3, Advanced configuration, below
RELOAD_VCL=1

# This file contains 4 alternatives, please use only one.

## Alternative 1, Minimal configuration, no VCL
#
# Listen on port 6081, administration on localhost:6082, and forward to
# content server on localhost:8080.  Use a fixed-size cache file.
#
# DAEMON_OPTS="-a :6081  -T localhost:6082  -b localhost:8080   -u varnish -g varnish  -s file,/var/lib/varnish/varnish_storage.bin,1G"


## Alternative 2, Configuration with VCL
#
# Listen on port 6081, administration on localhost:6082, and forward to
# one content server selected by the vcl file, based on the request.  Use a
# fixed-size cache file.
#
#DAEMON_OPTS="-a :6081 \
#             -T localhost:6082 \
#             -f /etc/varnish/default.vcl \
#             -u varnish -g varnish \
#             -S /etc/varnish/secret \
#             -s file,/var/lib/varnish/varnish_storage.bin,1G"


## Alternative 3, Advanced configuration
#
# See varnishd(1) for more information.
#
# # Main configuration file. You probably want to change it :)
VARNISH_VCL_CONF=/etc/varnish/default.vcl
#
# # Default address and port to bind to
# # Blank address means all IPv4 and IPv6 interfaces, otherwise specify
# # a host name, an IPv4 dotted quad, or an IPv6 address in brackets.
VARNISH_LISTEN_ADDRESS=127.0.0.1
VARNISH_LISTEN_PORT=80
#
# # Telnet admin interface listen address and port
VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1
VARNISH_ADMIN_LISTEN_PORT=6082
#
# # Shared secret file for admin interface
VARNISH_SECRET_FILE=/etc/varnish/secret
#
# # The minimum number of worker threads to start
VARNISH_MIN_THREADS=50
#
# # The Maximum number of worker threads to start
VARNISH_MAX_THREADS=1000
#
# # Idle timeout for worker threads
VARNISH_THREAD_TIMEOUT=120
#
# # Cache file location
VARNISH_STORAGE_FILE=/var/lib/varnish/varnish_storage.bin
#
# # Cache file size: in bytes, optionally using k / M / G / T suffix,
# # or in percentage of available disk space using the % suffix.
VARNISH_STORAGE_SIZE=1G
#
# # Backend storage specification
VARNISH_STORAGE="file,${VARNISH_STORAGE_FILE},${VARNISH_STORAGE_SIZE}"
#VARNISH_STORAGE="malloc,${VARNISH_STORAGE_SIZE}"
#
# # Default TTL used when the backend does not specify one
VARNISH_TTL=120
#
# # DAEMON_OPTS is used by the init script.  If you add or remove options, make
# # sure you update this section, too.
DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT}  -f ${VARNISH_VCL_CONF}   -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT}   -t ${VARNISH_TTL} -w ${VARNISH_MIN_THREADS},${VARNISH_MAX_THREADS},${VARNISH_THREAD_TIMEOUT}   -u varnish -g varnish        -S ${VARNISH_SECRET_FILE}      -s ${VARNISH_STORAGE}"


## Alternative 4, Do It Yourself. See varnishd(1) for more information.
#
# DAEMON_OPTS=""

最佳答案

varnishd命令要求-f选项使用vcl文件而不是sysconfig文件,因此您的测试运行应为:

varnishd -d -f /etc/varnish/default.vcl 

根据您的VARNISH_VCL_CONF=/etc/varnish/default.vcl中的/etc/sysconfig/varnish
模仿启动脚本的完整命令行大致如下:
varnishd -d -a 127.0.0.1:80 -f /etc/varnish/default.vcl -T 127.0.0.1:6082 -t 120 -w 1000,100,120 -u varnish -g varnish -S /etc/varnish/secret -s file,/var/lib/varnish/varnish_storage.bin,1G

关于magento - 由于VCC编译器错误: expected of 'acl' , 'sub', 'backend', Varnish 无法重新启动,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27697241/

相关文章:

c - Varnish 中的小写 url(内联 C)

Varnish 多个后端不起作用

apache - 错误 503 服务不可用 - Varnish 缓存

linux - 为了安全起见,安装 Magento 后哪些文件应该是可写的?

php - 自定义 Magento 订单字段和 Magento 数据库

wordpress - Varnish + nginx ssl + woocommerce - wc-ajax 不正常

php - Magento 阻止 Varnish 缓存页面

search - 如何修改 Magento 搜索以检查子 skus?

templates - Magento 通过代码获取电子邮件模板

magento - 在 Magento 中如何在产品网格中显示自定义属性..?