部署Ollama到MacOS

1. 安装ollama客户端

官方下载地址
https://ollama.com/download

2.创建并编辑配置文件

nano ~/Library/LaunchAgents/com.user.ollama.service.plist

3.配置文件中写入下面内容

定义了服务方式运行,以及做了跨域设置。使得内网其他的网络访问被允许

<?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>Label</key>
    <string>com.user.ollama.service</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/ollama</string>
        <string>serve</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
    <key>StandardErrorPath</key>
    <string>/tmp/ollama.err</string>
    <key>StandardOutPath</key>
    <string>/tmp/ollama.out</string>
    <key>EnvironmentVariables</key>
    <dict>
        <key>OLLAMA_HOST</key>
        <string>0.0.0.0</string>
        <key>Ollama_ORIGINS</key>
        <string>*</string>
    </dict>
</dict>
</plist>

4.赋予权限,启动服务

chmod 644 ~/Library/LaunchAgents/com.user.ollama.service.plist

launchctl load ~/Library/LaunchAgents/com.user.ollama.service.plist

Configuration macOS

If Ollama is run as a macOS application, environment variables should be set using launchctl.

Steps

Open the Terminal application. For each environment variable you need to set, use the following command:

launchctl setenv OLLAMA_HOST "0.0.0.0"
launchctl setenv OLLAMA_ORIGINS "*"

Leave a Reply

Your email address will not be published. Required fields are marked *