search

Home  >  Q&A  >  body text

macos - Mac下Redis如何开机启动

Redis已经安装成功,请问Mac下如何开机启动呢?

已解决问题,谢谢,特此总结: Mac下配置Redis服务器(自启动、后台运行)

PHP中文网PHP中文网2798 days ago830

reply all(4)I'll reply

  • 巴扎黑

    巴扎黑2017-04-21 10:58:44

    If you use brew, just brew install redis

    Then it will tell you to

    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
    

    This way it can be started when the user logs in

    If you compiled redis yourself, then write a redis.plist yourself

    launchctl load YOUR_PATH/NAME_OF_REDIS.plist
    

    Please replace {...} in the following examples with your own settings

    <?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>KeepAlive</key>
        <true/>
        <key>Label</key>
        <string>local.autorun.redis</string>
        <key>ProgramArguments</key>
        <array>
          <string>{REDIS_BIN_PATH}/redis-server</string>
          <string>{REDIS_CONFIG_PATH}/redis.conf</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>UserName</key>
        <string>{YOUR_USERNAME}</string>
        <key>WorkingDirectory</key>
        <string>/usr/local/var</string>
        <key>StandardErrorPath</key>
        <string>/usr/local/var/log/redis.log</string>
        <key>StandardOutPath</key>
        <string>/usr/local/var/log/redis.log</string>
      </dict>
    </plist>
    

    Wish you success ;)

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-21 10:58:44

    Read the information: "Three Ways to Configure Mac OS X Startup Items" The answer below is indeed wrong, it seems not that simple.


    The following is the wrong answer, just look at the joke

    Although I have never used Redis, you can use the launchctl command to set up the process you want to start at boot.

    This command is used to control the startup process (launchd) in OS X system. If you need to control the services started by launchd in real time, you can use this command control. For example, if you need to stop the Spotlight service, you can run the following command:

    launchctl unload /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
    

    If you want to start the service after stopping it, then:

    launchctl load /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
    

    You can try using the following command

    launchctl load redis-server start
    

    reply
    0
  • 迷茫

    迷茫2017-04-21 10:58:44

    Recommend two GUI tools, cakebrewlaunchrocket, cakebrew is used to manage brew’s formulae, and launchrocket is used to manage the start/stop/start of related services

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-21 10:58:44

    Now change to the following command:

    brew services start redis

    reply
    0
  • Cancelreply