mac 安裝php+nginx+php-fpm+mysql

一、下載編輯器http://www.iterm2.com/downloads.htmlphp

 
二、使用brew安裝軟件:brew又叫homebrew,是mac osx上的軟件包管理工具,能在mac中方便的安裝軟件或者卸載軟件,只須要一個命令,很是方便。
 
三、打開brew 的官方網站: http://brew.sh/
 
四、在linux命令行下輸入:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

安裝brew成功

五、安裝git

直接在命令行中輸入 brew install git

就能夠安裝成功,若是要卸載就直接輸入 brew uninstall git

六、更新brew:brew update

具體用到能夠直接查

七、安裝nginx:
brew search nginx
brew install nginx

執行:
cd /usr/local/etc/nginx/
mkdir conf.d
 
vim nginx.conf
粘貼此內容:
<!-- lang: shell -->
worker_processes 1;
 
error_log    /usr/local/var/log/nginx/error.log warn;
 
pid    /usr/local/var/run/nginx.pid;
 
events {
   worker_connections 256;
}
 
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   /usr/local/var/log/nginx/access.log main;
   port_in_redirect off;
   sendfile    on;
   keepalive_timeout 65;
 
   include /usr/local/etc/nginx/conf.d/*.conf;
}
 
vim default.conf
<!-- lang: shell -->
server {
   listen    8080;
   server_name localhost;
 
   root /Users/user_name/nginx_sites/; # 該項要修改成你準備存放相關網頁的路徑
 
   location / {
     index index.php;
     autoindex on;
  
 
   #proxy the php scripts to php-fpm
   location ~ \.php$ {
     include /usr/local/etc/nginx/fastcgi.conf;
     fastcgi_intercept_errors on;
     fastcgi_pass  127.0.0.1:9000;
  
 
}
 
 
以上就是nginx配置完成
 
安裝php
brew install php70 --with-imap --with-tidy --with-debug --with-mysql --with-fpm

安裝php-fpmhtml

mac osx 10.9 之後的系統都自帶了php、php-fpm,這樣就省去了安裝的麻煩
只須要執行: sudo cp /private/etc/php-fpm .conf.default /private/etc/php-fpm .conf
 
安裝mysql
 
brew install mysql
 
 
測試nginx服務
 
在以前的nginx配置文件default.conf中設置的root項對應的文件夾下建立測試文件index.php
 
<?php phpinfo();?>
 
啓動nginx服務
 sudo nginx
 
啓動php服務
sudo php-fpm
 
注意:
若是你以前在電腦上安裝了php5.5,你再安裝php7.0,當你在地址欄中輸入localhost:8080 看到的php版本是5.5而不是最新的7.0  看到的fpm版本也是5.5 
解決:
一、sudo cp /usr/local/Cellar/php70/7.0.15_8/sbin/php-fpm /usr/sbin/php-fpm
 
二、
vim ~./zshrc 修改此文件的最後一行,把
export PATH=$HOME/bin:/usr/local/sbin:/usr/local/bin:$PATH
 
三、從新啓動fpm :source .zshrc
 
四、看fpm的進程有哪些:ps aux|grep php-fpm
 
五、分別殺死這些進程:sudo kill 16591 16591 16589
 
 
四、最後看一下phpfpm的版本:/usr/local/sbin/php-fpm -v
 
 
意思就是先去sbin中去找php7文件,再去bin找,剛開始沒有🏠skin,都是從bin中,bin文件中都是php5.5,因此就用回php5.5fpm,
 
 
這樣就所有安裝成功了。
相關文章
相關標籤/搜索