brew 在 macOS 上安装 squid 但无法运行 squid

brew 在 macOS 上安装 squid 但无法运行 squid

我今天关注了这份文档

http://macappstore.org/squid/

并尝试运行这两个命令

  • /usr/local/Cellar/squid/4.11/sbin/squid -f squid.conf -N
  • sudo /usr/local/Cellar/squid/4.11/sbin/squid -f squid.conf -N

第一个没有输出,我找不到任何日志。第二个输出到 stderr/stdout,因为它被拒绝权限(到底是怎么回事,为什么 root 会被拒绝权限?)

这是第二条命令的输出...

Deans-MacBook-Pro:workspace dean$ sudo /usr/local/Cellar/squid/4.11/sbin/squid -f squid.conf -N
WARNING: Cannot write log file: /usr/local/var/logs/cache.log
/usr/local/var/logs/cache.log: Permission denied
         messages will be sent to 'stderr'.
2020/05/05 09:47:25| Created PID file (/usr/local/var/run/squid.pid)
2020/05/05 09:47:25| Current Directory is /Users/dean/workspace
WARNING: Cannot write log file: /usr/local/var/logs/cache.log
/usr/local/var/logs/cache.log: Permission denied
         messages will be sent to 'stderr'.
2020/05/05 09:47:25| Starting Squid Cache version 4.11 for x86_64-apple-darwin19.4.0...
2020/05/05 09:47:25| Service Name: squid
2020/05/05 09:47:25| Process ID 45668
2020/05/05 09:47:25| Process Roles: master worker
2020/05/05 09:47:25| With 256 file descriptors available
2020/05/05 09:47:25| Initializing IP Cache...
2020/05/05 09:47:25| DNS Socket created at [::], FD 9
2020/05/05 09:47:25| DNS Socket created at 0.0.0.0, FD 10
2020/05/05 09:47:25| Adding nameserver 192.168.2.1 from /etc/resolv.conf
2020/05/05 09:47:25| Logfile: opening log daemon:/usr/local/var/logs/access.log
2020/05/05 09:47:25| Logfile Daemon: opening log /usr/local/var/logs/access.log
2020/05/05 09:47:25| Store logging disabled
2020/05/05 09:47:25| Swap maxSize 0 + 262144 KB, estimated 20164 objects
2020/05/05 09:47:25| Target number of buckets: 1008
2020/05/05 09:47:25| Using 8192 Store buckets
2020/05/05 09:47:25| Max Mem  size: 262144 KB
2020/05/05 09:47:25| Max Swap size: 0 KB
2020/05/05 09:47:25| Using Least Load store dir selection
2020/05/05 09:47:25| Current Directory is /Users/dean/workspace
fopen: Permission denied
2020/05/05 09:47:25| Finished loading MIME types and icons.
2020/05/05 09:47:25| HTCP Disabled.
2020/05/05 09:47:25| Squid plugin modules loaded: 0
2020/05/05 09:47:25| Adaptation support is off.
2020/05/05 09:47:25| Accepting HTTP Socket connections at local=[::]:3128 remote=[::] FD 13 flags=9
2020/05/05 09:47:26| Configuring Parent zproxy.lum-superproxy.io/22225/0
2020/05/05 09:47:26| storeLateRelease: released 0 objects
2020/05/05 09:47:26| logfileHandleWrite: daemon:/usr/local/var/logs/access.log: error writing ((32) Broken pipe)
2020/05/05 09:47:26| Closing HTTP(S) port [::]:3128
2020/05/05 09:47:26| storeDirWriteCleanLogs: Starting...
2020/05/05 09:47:26|   Finished.  Wrote 0 entries.
2020/05/05 09:47:26|   Took 0.00 seconds (  0.00 entries/sec).
2020/05/05 09:47:26| FATAL: I don't handle this error well!
2020/05/05 09:47:26| Squid Cache (Version 4.11): Terminated abnormally.
CPU Usage: 0.045 seconds = 0.033 user + 0.012 sys
Maximum Resident Size: 45465600 KB
Page faults with physical i/o: 59
2020/05/05 09:47:26| Removing PID file (/usr/local/var/run/squid.pid)
Deans-MacBook-Pro:workspace dean$

关于如何让 squid 在 Mac 上运行,您有什么想法吗?

我的配置文件很简单

http_端口 3128

cache_peer proxy-host-name parent proxy-port 0 \
  no-query \
  login=username:password \
  connect-fail-limit=99999999 \
  proxy-only \
  name=my_peer
cache_peer_access my_peer allow all

答案1

我的解决方法是将此属性添加到squid配置文件文件

access_log stdio:/tmp/squid.log
cache_log /tmp/squid-cache.log

并创建此文件夹

sudo mkdir /var/spool/squid

终于跑了

sudo /usr/local/Cellar/squid/4.11/sbin/squid -f squid.conf -N

答案2

一般来说,在解决了权限问题之后,标准squid -z方法似乎有效

brew install squid

vim /usr/local/etc/squid.conf

sudo mkdir /var/spool/squid
sudo chown -R myuser:admin /var/spool/squid

/usr/local/Cellar/squid/4.13/sbin/squid -z

/usr/local/Cellar/squid/4.13/sbin/squid -N

ls -la /usr/local/var/logs/

相关内容