現在OSx不支持本地pac文件,如果想用本地文件,需要啟動本機的apache服務。
step1. 在console運行 sudo apachectl start
正常的話,用瀏覽器看http://localhost/ 應該顯示 It Works
但是卻顯示無法連接。
step2. 在console 運行 sudo apachectl -t
終端顯示
Syntax error on line 20 of /private/etc/apache2/extra/httpd-mpm.conf: Invalid command 'LockFile', perhaps misspelled or defined by a module not included in the server configuration
查資料得知LockFile 是apache2.2以前使用的,apache2.4使用的是Mutex
而osx10.11以后用的是apache2.4
step3. 修改文件 /etc/apache2/extra/httpd-mpm.conf
把以下內容隱藏
<IfModule !mpm_winnt_module> <IfModule !mpm_netware_module> LockFile "/private/var/log/apache2/accept.lock" </IfModule> </IfModule>
step4. 重新測試 sudo apachectl -t 正常,運行sudo apachectl restart, 用瀏覽器測試正常
step5. 把Pac文件拷貝到/Library/WebServer/Documents/
step6. 設置pac文件路徑為http://localhost/xxx.pac
完成
