用了Mac有一陣了,以前一直使用的Mamp Pro的集成環境,很是強大。能夠自由切換php版本、更換Apache 和 Nginx、自定義站點 --破解MAmp pro 連接php
須要Homebrew,更換中國鏡像。有不少帖子這裏就不說了html
brew install php56 --with-debug --with-homebrew-libressl --with-homebrew-curl --with-gmp --with-libmysql --with-imap
# 加入開機啓動 mkdir -p ~/Library/LaunchAgents cp /usr/local/opt/php56/homebrew.mxcl.php56.plist ~/Library/LaunchAgents/ sudo aunchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist # 將php和php-fpm 加入環境變量 echo 'export PATH="$(brew --prefix php56)/bin:$PATH"' >> ~/.zshrc #for php echo 'export PATH="$(brew --prefix php56)/sbin:$PATH"' >> ~/.zshrc #for php-fpm
php-fpm -v
可能會出現以下報錯:mysql
Cannot load Xdebug - it was built with configuration API220131226,NTS, whereas running engine is API220131226,NTS,debug PHP Warning: PHP Startup: igbinary: Unable to initialize module Module compiled with build ID=API20131226,NTS PHP compiled with build ID=API20131226,NTS,debug
解決辦法: 將上面的報錯的擴展從新安裝編譯一下。(注意。必定要看你的報錯有幾個)nginx
brew reinstall php56-xdebug --build-from-source php56-igbinary --build-from-source
狀況分析: 我在第一次安裝的時候出現了。報錯,可是第二次裝的時候沒出現。 分析是由於以前用mamp集成環境,已經存在了對應的擴展。參考這個 連接sql
brew install nginx
安裝完成以後,會提示一些信息:
一、nginx 的配置文件: /usr/local/etc/nginx/nginx.conf
二、能夠在這個目錄下新建本身的虛擬主機: /usr/local/etc/nginx/servers/vim
一、 新建php-fpm配置,用於解析php腳本app
mkdir /usr/local/etc/nginx/conf.d vim /usr/local/etc/nginx/conf.d/php-fpm ## 將以下內容粘貼保存 location ~ \.php$ { try_files $uri = 404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_intercept_errors on; include fastcgi.conf; } ## 修改nginx.conf vim /usr/local/etc/nginx/nginx.conf
二、修改nginx。confcurl
vim /usr/local/etc/nginx/nginx.conf
user thanatos staff; ###指定用戶 worker_processes 1; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; autoindex on; # 開啓目錄結構 #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root /Users/thanatos/Web; index index.html index.htm index.php; autoindex on; include conf.d/php-fpm; # include 剛纔建立的腳本 } } include servers/*; }
三、將nginx加入開機開機啓動socket
cp /usr/local/opt/nginx/homebrew.mxcl.nginx.plist ~/Library/LaunchAgents/ sudo launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
保存退出,從新起nginx (要使用管理員權限,否則不能使用80端口)tcp
sudo brew services restart nginx
/usr/local/etc/php/5.6
主要修改運行的用戶
; Per pool prefix ; It only applies on the following directives: ; - 'access.log' ; - 'slowlog' ; - 'listen' (unixsocket) ; - 'chroot' ; - 'chdir' ; - 'php_values' ; - 'php_admin_values' ; When not set, the global prefix (or /usr/local/Cellar/php56/5.6.30_6) applies instead. ; Note: This directive can also be relative to the global prefix. ; Default Value: none ;prefix = /path/to/pools/$pool ; Unix user/group of processes ; Note: The user is mandatory. If the group is not set, the default user's group ; will be used. user = 你的用戶 group = 用戶組
保存重啓php-fpm
sudo brew services restart php56
一、安裝mysql比較簡單,主要是配置mysql的登錄
brew install mysql
二、加入開機啓動
cp /usr/local/opt/mysql/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/ sudo launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
三、修改root密碼 具體就不寫了。
由於,記錄的有點亂,就是本身作一個備忘,有遇到一樣問題的老哥,或者我落了那一步,歡迎糾正