我已在 Slackware 14.2 中成功安装并配置了 Squid Proxy Server 3.5.26。我当前以 root 用户身份登录,使用以下命令启动 Squid 时出现错误sudo squid -z
:
WARNING: Cannot write log file: /var/log/squid/cache.log
/var/log/squid/cache.clog: Permission Denied
messages will be sent to 'stderr'
2019/04/08 16:16:20 kid1| Set Current Directory to
/var/log/squid/cache/squid
2019/04/08 16:16:20 kid1| Creating missing swap directories
FATAL: Failed to make swap directory /var/cache/squid: (13) Permission Denied
Squid Cache (Version 3.5.26): Terminated abnormally.
CPU Usage: 0.008 seconds = 0.006 user + 0.002 sys
Maximum Resident Size: 45392 KB
Page faults with physical i/o:0
Even if i made /var/log/squid permissions to 777. Still the application is unable to write cache.log.
Running :
squid -NCd1
该命令输出:
WARNING: Cannot write log file: /var/log/squid/cache.log
/var/log/squid/cache.log: Permission denied
messages will be sent to 'stderr'.
2019/04/08 17:26:44| Set Current Directory to /var/log/squid/cache/squid
WARNING: Cannot write log file: /var/log/squid/cache.log
/var/log/squid/cache.log: Permission denied
messages will be sent to 'stderr'.
2019/04/08 17:26:44| WARNING: Closing open FD 2
2019/04/08 17:26:44| Starting Squid Cache version 3.5.26 for x86_64-
slackware-linux-gnu...
2019/04/08 17:26:44| Service Name: squid
2019/04/08 17:26:44| Process ID 1669
2019/04/08 17:26:44| Process Roles: master worker
2019/04/08 17:26:44| With 1024 file descriptors available
2019/04/08 17:26:44| Initializing IP Cache...
2019/04/08 17:26:44| parseEtcHosts: /etc/hosts: (13) Permission denied
2019/04/08 17:26:44| DNS Socket created at [::], FD 8
2019/04/08 17:26:44| DNS Socket created at 0.0.0.0, FD 9
2019/04/08 17:26:44| /etc/resolv.conf: (13) Permission denied
2019/04/08 17:26:44| Warning: Could not find any nameservers. Trying to
use localhost
2019/04/08 17:26:44| Please check your /etc/resolv.conf file
2019/04/08 17:26:44| or use the 'dns_nameservers' option in squid.conf.
2019/04/08 17:26:44|
'/usr/share/squid/errors/templates/ERR_ACCESS_DENIED':
(13) Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_ACCESS_DENIED
2019/04/08 17:26:44|
'/usr/share/squid/errors/templates/ERR_CACHE_ACCESS_DENIED': (13)
Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_CACHE_ACCESS_DENIED
2019/04/08 17:26:44|
'/usr/share/squid/errors/templates/ERR_CACHE_MGR_ACCESS_DENIED': (13)
Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_CACHE_MGR_ACCESS_DENIED
2019/04/08 17:26:44|
'/usr/share/squid/errors/templates/ERR_FORWARDING_DENIED': (13)
Permission
denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_FORWARDING_DENIED
2019/04/08 17:26:44| '/usr/share/squid/errors/templates/ERR_NO_RELAY':
(13)
Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_NO_RELAY
2019/04/08 17:26:44|
'/usr/share/squid/errors/templates/ERR_CANNOT_FORWARD': (13) Permission
denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_CANNOT_FORWARD
2019/04/08 17:26:44|
'/usr/share/squid/errors/templates/ERR_READ_TIMEOUT':
(13) Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_READ_TIMEOUT
2019/04/08 17:26:44|
'/usr/share/squid/errors/templates/ERR_LIFETIME_EXP':
(13) Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_LIFETIME_EXP
2019/04/08 17:26:44| '/usr/share/squid/errors/templates/ERR_READ_ERROR':
(13) Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_READ_ERROR
2019/04/08 17:26:44| '/usr/share/squid/errors/templates/ERR_WRITE_ERROR':
(13) Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_WRITE_ERROR
2019/04/08 17:26:44|
'/usr/share/squid/errors/templates/ERR_CONNECT_FAIL':
(13) Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_CONNECT_FAIL
2019/04/08 17:26:44|
'/usr/share/squid/errors/templates/ERR_SECURE_CONNECT_FAIL': (13)
Permission
denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_SECURE_CONNECT_FAIL
2019/04/08 17:26:44|
'/usr/share/squid/errors/templates/ERR_SOCKET_FAILURE':
( 13) Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_SOCKET_FAILURE
2019/04/08 17:26:44| '/usr/share/squid/errors/templates/ERR_DNS_FAIL':
(13) Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_DNS_FAIL
2019/04/08 17:26:44| '/usr/share/squid/errors/templates/ERR_URN_RESOLVE':
(13) Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_URN_RESOLVE
2019/04/08 17:26:44|
'/usr/share/squid/errors/templates/ERR_ONLY_IF_CACHED_MISS': (13)
Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_ONLY_IF_CACHED_MISS
2019/04/08 17:26:44| '/usr/share/squid/errors/templates/ERR_TOO_BIG':
(13) Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_TOO_BIG
2019/04/08 17:26:44|
'/usr/share/squid/errors/templates/ERR_INVALID_RESP':
(13) Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_INVALID_RESP
2019 /04/08 17:26:44|
'/usr/share/squid/errors/templates/ERR_UNSUP_HTTPVERSION': (13)
Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_UNSUP_HTTPVERSION
2019/04/08 17:26:44| '/usr/share/squid/errors/templates/ERR_INVALID_REQ':
(13) Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_INVALID_REQ
2019/04/08 17:26:44| '/usr/share/squid/errors/templates/ERR_UNSUP_REQ':
(13) Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_UNSUP_REQ
2019/04/08 17:26:44| '/usr/share/squid/errors/templates/ERR_INVALID_URL':
(13) Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_INVALID_URL
2019/04/08 17:26:44|
'/usr/share/squid/errors/templates/ERR_ZERO_SIZE_OBJECT': (13) Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_ZERO_SIZE_OBJECT
2019/04/08 17:26:44|
'/usr/share/squid/errors/templates/ERR_PRECONDITION_FAILED': (13)
Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_PRECONDITION_FAILED
2019/04/08 17:26:44| '/usr/share/squid/errors/templates/ERR_CONFLICT_HOST':
(13) Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_CONFLICT_HOST
2019/04/08 17:26:44| '/usr/share/squid/errors/templates/ERR_FTP_DISABLED':
(13) Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_FTP_DISABLED
2019/04/08 17:26:44|
'/usr/share/squid/errors/templates/ERR_FTP_UNAVAILABLE': (13) Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_FTP_UNAVAILABLE
2019/04/08 17:26:44| '/usr/share/squid/errors/templates/ERR_FTP_FAILURE':
(13) Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_FTP_FAILURE
2019/04/08 17:26:44| '/usr/share/squid/errors/templates/ERR_FTP_PUT_ERROR':
(13) Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_FTP_PUT_ERROR
2019/04/08 17:26:44| '/usr/share/squid/errors/templates/ERR_FTP_NOT_FOUND':
(13) Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_FTP_NOT_FOUND
2019/04/08 17:26:44| '/usr/share/squid/errors/templates/ERR_FTP_FORBIDDEN':
(13) Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_FTP_FORBIDDEN
2019/04/08 17:26:44|
'/usr/share/squid/errors/templates/ERR_FTP_PUT_CREATED': (13) Permission
denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_FTP_PUT_CREATED
2019/04/08 17:26:44|
'/usr/share/squid/errors/templates/ERR_FTP_PUT_MODIFIED': (13) Permission
denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_FTP_PUT_MODIFIED
2019/04/08 17:26:44| '/usr/share/squid/errors/templates/ERR_ESI': (13)
Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_ESI
2019/04/08 17:26:44|
'/usr/share/squid/errors/templates/ERR_ICAP_FAILURE':
(13) Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_ICAP_FAILURE
2019/04/08 17:26:44|
'/usr/share/squid/errors/templates/ERR_GATEWAY_FAILURE': (13) Permission
denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_GATEWAY_FAILURE
2019/04/08 17:26:44| '/usr/share/squid/errors/templates/ERR_DIR_LISTING':
(13) Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_DIR_LISTING
2019/04/08 17:26:44|
'/usr/share/squid/errors/templates/ERR_SHUTTING_DOWN':
(13) Permission denied
2019/04/08 17:26:44| WARNING: failed to find or read error text file
ERR_SHUTTING_DOWN
2019/04/08 17:26:44| Logfile: opening log
daemon:/var/log/squid/access.log
2019/04/08 17:26:44| Logfile Daemon: opening log
/var/log/squid/access.log
2019/04/08 17:26:44| ipcCreate: /usr/libexec/log_file_daemon: (22)
Invalid argument
2019/04/08 17:26:44| Unlinkd pipe opened on FD 15
2019/04/08 17:26:44| ipcCreate: /usr/libexec/unlinkd: (22) Invalid
argument
2019/04/08 17:26:44| Store logging disabled
2019/04/08 17:26:44| Swap maxSize 262144 + 262144 KB, estimated 40329
objects
2019/04/08 17:26:44| Target number of buckets: 2016
2019/04/08 17:26:44| Using 8192 Store buckets
2019/04/08 17:26:44| Max Mem size: 262144 KB
2019/04/08 17:26:44| Max Swap size: 262144 KB
2019/04/08 17:26:44| ERROR: /var/cache/squid: (13) Permission denied
FATAL: Failed to verify one of the swap directories, Check cache.log
for details. Run 'squid -z' to create swap directories
if needed, or if running Squid for the first time.
Squid Cache (Version 3.5.26): Terminated abnormally.
CPU Usage: 0.023 seconds = 0.016 user + 0.007 sys
Maximum Resident Size: 58800 KB
Page faults with physical i/o: 0
答案1
检查 SELinux 是否处于活动状态:sestatus
如果是,请尝试使用以下方法禁用它:setenforce 0
或者setenforce Permissive
或者如果您使用 AppArmor,请使用以下命令检查其状态:apparmor_status
检查你的 AppArmor 配置文件/etc/apparmor.d/usr.sbin.squid
和/或尝试禁用你的 squid 二进制文件的 AppArmor。
ln -s /etc/apparmor.d/usr.sbin.squid /etc/apparmor.d/disable/usr.sbin.squid
或者尝试暂时禁用 AppArmor 来检查问题是否出在那里:
service apparmor teardown