Mac配置好多版本的php环境后如何在开机时自动启动fpm
首先,我们要创建一个plist配置文件,例如php-fpm.plist,我们可将它放置在以下地方
- ~/Library/LaunchAgents
- /Library/LaunchAgents
- /Library/LaunchDaemons
- /System/Library/LaunchAgents
- /System/Library/LaunchDaemons
在文件中复制以下代码
<?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>php-fpm</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/php/php-5.5.32/sbin/php-fpm</string> #fpm文件的地址
<string>-y</string> #fpm的选项参数
<string>/usr/local/php/php-5.5.32/etc/php-fpm.conf</string> #fpm配置文件的地址
</array>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
接着,修改目录权限sudo chown root /Library/LaunchDaemons/php-fpm.plist
再输入sudo launchctl load -D system /Library/LaunchDaemons/php-fpm.plist
注册服务
完成后重启系统就实现了自动启动fpm