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


1、下載編輯器http://www.iterm2.com/downloads.html

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

安裝brew成功

5、安裝git

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

就可以安裝成功,如果要卸載就直接輸入 brew uninstall git

6、更新brew:brew update

具體用到可以直接查

7、安裝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-fpm

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 
解決:
1、sudo cp /usr/local/Cellar/php70/7.0.15_8/sbin/php-fpm /usr/sbin/php-fpm
 
2、
vim ~./zshrc 修改此文件的最后一行,把
export PATH=$HOME/bin:/usr/local/sbin:/usr/local/bin:$PATH
 
3、重新啟動fpm :source .zshrc
 
4、看fpm的進程有哪些:ps aux|grep php-fpm
 
5、分別殺死這些進程:sudo kill 16591 16591 16589
 
 
4、最后看一下phpfpm的版本:/usr/local/sbin/php-fpm -v
 
 
意思就是先去sbin中去找php7文件,再去bin找,剛開始沒有🏠skin,都是從bin中,bin文件中都是php5.5,所以就用回php5.5fpm,
 
 
這樣就全部安裝成功了。
 
 
 




 
 
 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM