facebook twitter hatena line email

Mac/インストール/php-fpm

提供: 初心者エンジニアの簡易メモ
移動: 案内検索

php-fpmインストール

$ brew update
$ brew tap homebrew/dupes # Formuraの追加(apache)
$ brew tap homebrew/versions
$ brew install homebrew/php/php56 --with-fpm

ちなみに間違えて入れた場合は以下感じで削除できる

brew untap homebrew/php

php-fpm設定

$ sudo cp /private/etc/php-fpm.conf.default /private/etc/php-fpm.conf
$ sudo vi /private/etc/php-fpm.conf
 ;pid = run/php-fpm.pid
 pid = /var/run/php-fpm.pid
 ;error_log = log/php-fpm/php-fpm.log
 error_log = /var/log/php-fpm/php-fpm.log
$ sudo mkdir /var/log/php-fpm
$ sudo php-fpm

参考:http://qiita.com/alegriaghost/items/7af4bf029e90ec37f7e0

自動起動

ln -s /usr/local/opt/php56/homebrew.mxcl.php56.plist ~/Library/LaunchAgents/homebrew.mxcl.php56.plist
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.php56.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.php56.plist

確認

$ php-fpm -v
PHP 5.6.24 (fpm-fcgi) (built: Aug  8 2016 16:58:54)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

Operation not permittedエラー

error_logを変更せずにphp-fpmを起動しようとするとエラーとなる

Error: Failed to download resource "libpng"

Homebrewの権限を確認

ls -ltA /Users/mac1/Library/Caches/Homebrew

起動

$ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist

停止

$ launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist