2025年8月20日水曜日

macOS 上の ollama を 0.0.0.0 で LISTEN する方法

macOS 上の ollama を 0.0.0.0 で LISTEN する方法

概要

plist を編集します

環境

  • macOS 15.6
  • ollama 0.11.4

環境変数を設定する

OLLAMA_HOST と OLLAMA_ORIGINS を追加します

  • vim /opt/homebrew/opt/ollama/homebrew.mxcl.ollama.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>EnvironmentVariables</key>
        <dict>
                <key>OLLAMA_FLASH_ATTENTION</key>
                <string>1</string>
                <key>OLLAMA_KV_CACHE_TYPE</key>
                <string>q8_0</string>
                <key>OLLAMA_HOST</key>
                <string>0.0.0.0</string>
                <key>OLLAMA_ORIGINS</key>
                <string>192.168.*</string>
        </dict>
        <key>KeepAlive</key>
        <true/>
        <key>Label</key>
        <string>homebrew.mxcl.ollama</string>
        <key>LimitLoadToSessionType</key>
        <array>
                <string>Aqua</string>
                <string>Background</string>
                <string>LoginWindow</string>
                <string>StandardIO</string>
                <string>System</string>
        </array>
        <key>ProgramArguments</key>
        <array>
                <string>/opt/homebrew/opt/ollama/bin/ollama</string>
                <string>serve</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>StandardErrorPath</key>
        <string>/opt/homebrew/var/log/ollama.log</string>
        <key>StandardOutPath</key>
        <string>/opt/homebrew/var/log/ollama.log</string>
        <key>WorkingDirectory</key>
        <string>/opt/homebrew/var</string>
</dict>
</plist>

動作確認

  • brew services restart ollama
  • ollama run gemma3

最後に

基本認証はないので外部からはアクセスできないようにしておきましょう

参考サイト

0 件のコメント:

コメントを投稿