mac涓嬪畨瑁卬ginx+php+mysql+xdebug

涓�锛屽畨瑁卙omebrew

灏卞儚linux涓嬮潰鏈墆um涓�鏍凤紝mac涔熸湁涓猦omebrew锛岀鐞嗚蒋浠堕潪甯镐究鎹枫��

瀹樼綉锛歨ttp://brew.sh/index_zh-cn.html 

涓婇潰鏈夊彞鍛戒护锛屽鍒朵笅鏉ョ粓绔墽琛岋紝濡傛灉鍛戒护杩斿洖404娌℃壘鍒帮紝鍛戒护浠ュ畼缃戞渶鏂颁负鍙傝�冦��

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

浠绘剰閿户缁紝鍙兘闇�瑕佽緭鍏ヤ綘MAC鐨勫紑鏈哄瘑鐮�

婕暱鐨勭瓑寰呫�傘�傘�傚彲浠ュ幓娲椾釜婢′簡鍐嶅洖鏉ョ湅

mac涓嬪畨瑁卬ginx+php+mysql+xdebug_第1张图片

brew help鍙互鐪嬪府鍔�

浜岋紝瀹夎nginx

brew install nginx

#閲嶆柊鍔犺浇閰嶇疆|閲嶅惎|鍋滄|閫�鍑� nginx
nginx -s reload|reopen|stop|quit
#娴嬭瘯閰嶇疆鏄惁鏈夎娉曢敊璇�
nginx -t

 鍙堟槸婕暱鐨勭瓑寰�

nginx -v 鏌ョ湅鐗堟湰

mac涓嬪畨瑁卬ginx+php+mysql+xdebug_第2张图片

鎵撳紑 nginx 鍚庯紝榛樿鐨勮闂鍙� 8080锛屽鏋滆鏀逛负甯哥敤鐨� 80 绔彛锛屽垯瑕佷慨鏀� "/usr/local/etc/nginx/nginx.conf" 涓嬬洃鍚�(listen)绔彛鍊笺��

榛樿鐨勬枃浠惰闂洰褰�(root)鏄� "/usr/local/Cellar/nginx/1.8.0/html"锛堣繖閲岀殑1..8.0鏄畨瑁呯殑nginx鐨勭増鏈紝鏂囦欢澶瑰悕浠ュ畨瑁呯殑nginx鐗堟湰涓哄噯锛夈��

鎶� nginx 璁剧疆涓哄紑鏈哄惎鍔ㄨ繍琛岋細

mkdir -p ~/Library/LaunchAgents

cp /usr/local/Cellar/nginx/1.8.0/homebrew.mxcl.nginx.plist ~/Library/LaunchAgents/

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

 

涓嶈繃璇曚簡涓�涓嬶紝涓嶆槸瓒呯骇鐢ㄦ埛鐧婚檰锛岃�屾槸鏅�氱敤鎴风櫥闄嗭紝骞朵笖鐩戝惉鐨勭鍙e湪1024浠ヤ笅鐨勶紙渚嬪鎶婇粯璁ょ殑8080绔彛鏀逛负浜�80绔彛锛夛紝nginx 寮�鏈烘槸鍚姩涓嶄簡銆傚洜姝わ紝瑕� nginx 寮�鏈哄惎鍔ㄧ殑璇濓紝闇�瑕佺粰浜堝畠绠$悊鍛樻潈闄愶細

sudo chown  root:wheel /usr/local/Cellar/nginx/1.8.0/bin/nginx

sudo chmod  u+s /usr/local/Cellar/nginx/1.8.0/bin/nginx

 

浜岋紝瀹夎mysql

brew install mysql 

瀹夎瀹屼箣鍚庣櫥闄嗭紝鎶ヤ簡涓敊锛孧ySQL server through socket '/tmp/mysql.sock

鍚姩涓�涓媘ysql锛屽湪璇曚竴涓�

mysql.server restart

濡傛灉瑙夊緱寰堥夯鐑︺�傜洿鎺ュ埌瀹樼綉涓嬩釜mac鐨刣mg鐗坢ysql鍚�

璁板緱鍗歌浇 brew remove mysql 锛�

涓嬭浇mysql瀹樼綉鐨刴ac dmg鐗堝畨瑁呭嵆鍙紝瀹夎瀹屼箣鍚庯紝鍦ㄥ亸濂借缃噷闈細鍑虹幇mysql鐨勫浘鏍囷紝鍜宩ava锛宖lash涓�鏍凤紝鎵撳紑鐪嬩笅锛屼笅闈㈢殑鍕鹃�夊紑鏈哄惎鍔�

mac涓嬪畨瑁卬ginx+php+mysql+xdebug_第3张图片 

cd ; nano .bash_profil
鎵撳紑缂栬緫杩欎釜鏂囦欢
export PATH="/usr/local/mysql/bin:$PATH"

control+x 鍚庡洖杞﹂��鍑�

source ~/.bash_profile

mysql鐧婚檰锛屽鏋滈亣鍒�
-bash: mysql: command not found

鍘熷洜:杩欐槸鐢变簬绯荤粺榛樿浼氭煡鎵�/usr/bin涓嬬殑鍛戒护锛屽鏋滆繖涓懡浠や笉鍦ㄨ繖涓洰褰曚笅锛屽綋鐒朵細鎵句笉鍒板懡浠わ紝鎴戜滑闇�瑕佸仛鐨勫氨鏄槧灏勪竴涓摼鎺ュ埌/usr/bin鐩綍涓嬶紝鐩稿綋浜庡缓绔嬩竴涓摼鎺ユ枃浠躲��
棣栧厛寰楃煡閬搈ysql鍛戒护鎴杕ysqladmin鍛戒护鐨勫畬鏁磋矾寰勶紝姣斿mysql鐨勮矾寰勬槸锛�/usr/local/mysql/bin/mysql锛屾垜浠垯鍙互杩欐牱鎵ц鍛戒护锛�

# ln -s /usr/local/mysql/bin/mysql /usr/bin

璁剧疆浣犵殑瀵嗙爜
/usr/local/mysql/bin/mysqladmin -u root password 'yourpasswordhere'

mysql -uroot -pyourpasswordhere

鐧婚檰鎴愬姛锛�

涓夈�佸畨瑁卲hp-fpm

Mac鏄瑁呬簡php锛屼笉杩囧緢澶氭墿灞曢兘娌″畨瑁咃紝鐩祴鏈�澶氬彧鑳藉湪缁堢閲屾墽琛屼笅php鎸囦护锛屾墍浠ユ垜閫夋嫨閲嶆柊瀹夎php銆傜敱浜� brew 榛樿鏄病鏈� php 瀹夎锛屾墍浠ヨ浣跨敤 “brew tap” 鏉ュ畨瑁� brew 鐨勭涓夋柟绋嬪簭鍖咃紝杩欓噷浣跨敤 josegonzalez 鐨刾hp瀹夎鍖咃紝鍏蜂綋鎿嶄綔濡備笅锛�

1
2
brew tap homebrew /dupes
brew tap josegonzalez /homebrew-php

鎵ц瀹屽悗锛屽氨鍙互鐢� brew 瀹夎php浜嗐�傝繖閲宲hp鏈夊嚑涓増鏈彲浠ュ畨瑁咃紝鍏蜂綋鍙互鎵ц "brew search php" 鏌ョ湅涓�涓嬫湁浠�涔坧hp鐗堟湰鍙互瀹夎锛屼竴鑸細鏈�“php52銆乸hp53銆乸hp54”鐗堟湰锛屾垜瀹夎鐨勬槸鏈�鏂扮殑php5.6鐗堟湰銆�(php7.0灏濊瘯澶氭缂栬瘧涓嶈繃鍘绘斁寮冧簡銆�)

鐢变簬PHP5.4浠ヤ笂鐗堟湰宸茬粡鍐呭祵浜� FPM锛孎astCGI Process Manager锛�锛屽湪瀹夎閫夐」閲屾爣鏄庡氨琛岋紝鏈汉 php 鐨勫畨瑁呴厤缃寚浠ゅ涓嬶細

brew install php56 --with-debug --with-homebrew-curl --with-imap --with-homebrew-libressl --with-homebrew-libxslt  --with-libmysql --without-apache --with-fpm

 瀹夎瀹屽悗浼氬嚭涓�娈垫彁绀虹殑銆�

The php.ini file can be found in:
    /usr/local/etc/php/5.6/php.ini

鉁┾湬鉁┾湬 Extensions 鉁┾湬鉁┾湬

If you are having issues with custom extension compiling, ensure that
you are using the brew version, by placing /usr/local/bin before /usr/sbin in your PATH:

      PATH="/usr/local/bin:$PATH"   //杩欎釜鏀惧湪鐜鍙橀噺鏂囦欢~/bash_profile鐨�/usr/sbin/鐨勫墠闈紝浼樺厛閫夋嫨brew鐨刾hp

PHP56 Extensions will always be compiled against this PHP. Please install them
using --without-homebrew-php to enable compiling against system PHP.

鉁┾湬鉁┾湬 PHP CLI 鉁┾湬鉁┾湬

If you wish to swap the PHP you use on the command line, you should add the following to ~/.bashrc,
~/.zshrc, ~/.profile or your shell's equivalent configuration file:

      export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH" //鍛戒护琛屾墽琛屽悗鎵嶈兘php -v鏌ョ湅鏈�鏂扮殑php瀹夎鐨勭増鏈�

鉁┾湬鉁┾湬 FPM 鉁┾湬鉁┾湬
To launch php
-fpm on startup: mkdir -p ~/Library/LaunchAgents //鍒涘缓鐩綍锛屾湁鍒欏拷鐣� cp /usr/local/opt/php56/homebrew.mxcl.php56.plist ~/Library/LaunchAgents/ //澶嶅埗鏂囦欢鍒扮郴缁熺洰褰� launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist //鎵ц鍚� 寮�鏈哄惎鍔╬hp-fpm The control script is located at /usr/local/opt/php56/sbin/php56-fpm OS X 10.8 and newer come with php-fpm pre-installed, to ensure you are using the brew version you need to make sure /usr/local/sbin is before /usr/sbin in your PATH: PATH="/usr/local/sbin:$PATH" //鏇存柊瀹夎锛屾湁鍒欏拷鐣ワ紝娌℃湁鍒欏姞鍒皛/.bash_profile You may also need to edit the plist to use the correct "UserName". Please note that the plist was called 'homebrew-php.josegonzalez.php56.plist' in old versions of this formula. To have launchd start josegonzalez/php/php56 at login: ln -sfv /usr/local/opt/php56/*.plist ~/Library/LaunchAgents //浣跨敤php Then to load josegonzalez/php/php56 now: launchctl load ~/Library/LaunchAgents/homebrew.mxcl.php56.plist //浣跨敤php ==> Summary 馃嵑 /usr/local/Cellar/php56/5.6.14: 309 files, 43M, built in 5.9 minutes

鏇村鐨勫畨瑁呴�夐」鍙互閫氳繃 "brew options php56" 鏌ョ湅銆傛寚浠ゆ墽琛屽畬鍚庯紝php 璺� php-fpm 灏卞畨瑁呭ソ浜嗐��

鐢变簬鏄噸瑁卲hp锛屼箣鍓嶇郴缁熼瑁呯殑php杩樻病鍗歌浇锛屽洜姝ゅ湪缁堢璋冪敤php鏃讹紝杩樻槸浠ヤ箣鍓嶇郴缁熺殑php鐗堟湰鍋氳В鏋愶紝鎵�浠ヨ繖閲岄渶瑕佷慨鏀筽ath锛屾寚瀹� php 鐨勮В鏋愯矾寰勩�傚湪~/.bash_profile锛堟病鏈夊垯鍒涘缓锛夋渶鍚庡姞鍏ヤ竴琛岋細

鍏跺疄鎻愮ず宸茬粡璇寸殑寰堟竻妤氫簡銆傛寜姝ラ鍘绘暡涓婇潰鏍囩孩鐨勫懡浠ゅ氨琛屼簡銆備笅闈㈡槸鎴戠殑鐜鍙橀噺鏂囦欢 ~/.bash_profile

1

export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH"

export PATH="/usr/local/sbin:$PATH"

export PATH="/usr/local/mysql/bin:$PATH"

娣诲姞涔嬪悗鍐嶆墽琛屼竴涓媠ource锛屼娇涔嬬敓鏁�
1
source ~/.bash_profile

銆�銆�銆�銆�銆�銆�souce 鏈夊彲鑳藉け璐ワ紝涓嶇敤绠″畠锛屽簲璇ユ槸鏈嶅姟娌¤捣鏉ャ��

OK锛宲hp-fpm瀹夎瀹屾垚銆�

mac涓嬪畨瑁卬ginx+php+mysql+xdebug_第4张图片

 

褰撶劧杩樻病瀹岋紝浣犻渶瑕佸憡璇塶ginx浣跨敤php-fpm缂栬瘧php鏂囦欢銆�

vi /usr/local/etc/nginx/nginx.conf 

 

 location ~ \.php$ {

            root           /usr/local/var/www;#鏀逛竴涓嬩綘鐨勭綉绔欐牴鐩綍

            fastcgi_pass   127.0.0.1:9000;

            fastcgi_index  index.php;

            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name; #杩欓噷/script鏀规垚$document_root

            include        fastcgi_params;

        }

========================================

閰嶇疆涓�涓猯ocalhost:8081鐨勯」鐩紝/User/XXX/www/test.com

涓嬮潰鏄竴涓畝鍗曠殑閰嶇疆

server {
        listen       8081;
        server_name  localhost
        root   /Users/lixianghui/www/test.com;
     index index.php index.html;
 
    location ~ \.php$ {
        root   /Users/lixianghui/www/test.com;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
 }

 

鍥涖�亁debug

brew install xdebug 鍚勭鎶ラ敊锛屾病鎵惧埌tap涔嬬被鐨勶紝缃戜笂鎵句簡寰堝鏂规锛屾病瑙e喅銆�

鎵�浠ユ墦绠楃洿鎺ョ紪璇憍debug濂戒簡銆�

鎵�浠ョ洿鎺ュ畼缃慼ttp://xdebug.org/download.php

閫夋嫨 source   files/xdebug-2.3.3.tgz 涓嬭浇涓嬫潵

涓㈠埌/User/XXX/www/xdebug-2.3.3.tgz

瑙e帇

tar -xzf  xdebug-2.3.3.tgz

cd xdebug-2.3.3

phpize

濡傛灉鎶ラ敊娌″畨瑁卆utoconf鐨勮瘽灏� 鎵ц  brew install autoconf 

./configure --enable-xdebug

make

娴嬭瘯涓�涓�

make test

mac涓嬪畨瑁卬ginx+php+mysql+xdebug_第5张图片

make install

mac涓嬪畨瑁卬ginx+php+mysql+xdebug_第6张图片 

php --ini   鎵惧埌php.ini鏂囦欢浣嶇疆

 php.ine鏈熬鍔犲叆

[xdebug]

;zend_extension="/usr/local/Cellar/php56/5.6.14/lib/php/extensions/debug-non-zts-20131226/xdebug.so"

zend_extension="xdebug.so"

xdebug.remote_enable=1

xdebug.remote_host=localhost

xdebug.remote_port=9000

xdebug.remote_autostart=1

mac涓嬪畨瑁卬ginx+php+mysql+xdebug_第7张图片

 

 

鍙傝�冿細http://blog.csdn.net/iamduoluo/article/details/38346291

http://coolestguidesontheplanet.com/get-apache-mysql-php-phpmyadmin-working-osx-10-10-yosemite/#mysql

http://www.it165.net/os/html/201401/7076.html

你可能感兴趣的:(mac涓嬪畨瑁卬ginx+php+mysql+xdebug)