本身雖然平時愛折騰,卻不多有記下來的習慣,除非碰到特別多問題的部署纔會有衝動。今天看同事折騰git,在旁邊看着他mac上的evernote滿滿的記了好幾篇,全是技術相關的記錄,突然很感慨。過去解決了不少碎片化的問題,都沒有系統地記下來,雖然從此也不能保證,但起碼會決心擠出時間來寫點東西(如今私人時間多了 php
安裝nginx: mysql
mac上好用的軟件包管理工具首選homebrew,他家的宣傳口號牛逼得很,」mac ports driving you to drink?try home brew「 記得當時google前還真被macport折磨得要吐 nginx
安裝nginx很簡單 ,brew install nginx 就能夠了。其中有個小小提示:Warning: /usr/local/sbin is not in your PATH 只須要在/etc/paths中加入 /usr/local/sbin路徑便可 git
mac自帶了apache,默認的apache端口是80,nginx安裝後默認是8080,我沒有潔癖,不必兩個只能活一個,因此8080端口就留給nginx的測試 github
要使nginx開機啓動,終端命令 launchctl load -w /System/Library/LaunchDaemon/org.apache***.plist *號是忘記了得內容,反正按tab就行 (同理unload可撤銷) sql
配置文件/etc/nginx/nginx.conf 在其中的http內容中加入 include vhost/*.conf apache
新建vhost文件夾,這裏按{域名}.conf的規則建立virtual host xcode
安裝php-fpm: app
mac自己的php就支持fpm,php info查看fpm是否enable,不然能夠用homebrew再裝一次: php-fpm
brew tap josegonzalez/homebrew-php
而後 brew install php54 --with-fpm --with-mysql --with-tidy --with-debug
出現 configure: error: Cannot find OpenSSL's <evp.h>,homebrew github上有人回答了該問題
For future reference of anybody looking for Command Line Tools with Xcode 5, open up a Terminal window and type xcode-select --install. A window will appear informing you command line tools are required. Click Install and you should be good to go
xcode-select --install, 從新安裝後經過
啓動fpm:php-fpm 提示找不到conf和log,cp /private/etc/php-fpm.conf.default /private/etc/php-fpm.conf,根據提示的error log路徑建立文件或在conf中修改error log路徑,運行正常
修改nginx中php fpm的註釋,若是配置了vhost則配置文件加入相對的php location內容,script指向root path.
開機啓動php-fpm
vi /System/Library/LaunchDaemon/org.php.php-fpm.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>Label</key><string>php-fpm</string>
<key>Program</key><string>/usr/sbin/php-fpm</string>
<key>KeepAlive</key><true/>
</dict>
</plist>
launchctl load -w /System/Library/LaunchDaemon/org.php.php-fpm.plist
Thats all.