mac 安裝 php nginx mysql

來源:互聯網
上載者:User

標籤:read   path   top   home   dmi   highlight   $path   bre   取消   

 

mac下面安裝php nginx mysql根linux下面差不多,建議大家使用brew管理工具包安裝。

 

1,安裝homebrew

http://brew.sh/index_zh-cn.html

安裝方法會改變的,所以安裝官方上面的方法來裝。安裝 homebrew-cask

  1. $ brew tap caskroom/cask  

homebrew-cask安裝的東西,更多。

2,換源或者加代理

brew管理工具包,預設是從github上面下載,github經常被牆。並且龜速。

查看複製列印?
  1. $ brew install git  
  2. $ cd /usr/local/Homebrew  
  3. $ git remote set-url origin https://git.coding.net/homebrew/homebrew.git  

如果不想換源話,可以加代理,前提是你的代理,不被牆,並且比較快

查看複製列印?
  1. zhangyingdeMacBook-Pro:Homebrew zhangying$ cat ~/.curlrc  
  2. socks5="127.0.0.1:1080"  

3,安裝nginx mysql

  1. $ brew install nginx mysql  

4,安裝php

查看複製列印?
  1. //添加擴充庫  
  2. $ brew tap homebrew/dupes  
  3. $ brew tap homebrew/versions  
  4. $ brew tap homebrew/php  
  5.   
  6. $ brew search php //查看php的可用版本  
  7. $ brew install php54 //安裝所需版本  
  8.   
  9. //預設是有php的,所以php的環境要指向新的  
  10. $ echo ‘export PATH="$(brew --prefix homebrew/php/php54)/bin:$PATH"‘ >> ~/.bash_profile  
  11. $ echo ‘export PATH="$(brew --prefix homebrew/php/php54)/sbin:$PATH"‘ >> ~/.bash_profile  
  12. $ echo ‘export PATH="/usr/local/bin:/usr/local/sbin:$PATH"‘ >> ~/.bash_profile  
  13. $ source ~/.bash_profile //更新配置  

5,設定檔目錄

  1. /usr/local/etc/nginx  
  2. /usr/local/etc/php  
  3. /usr/local/Cellar/mysql/5.7.16  

6,開機啟動,以nginx為例

查看複製列印?
  1. $ ln -s /usr/local/opt/nginx/*.plist ~/Library/LaunchAgents/  
  2. $ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist   //載入  
  3. $ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist     //取消載入  

7,sudo無密碼

查看複製列印?
  1. $ sudo su  
  2. # visudo  
  3. %admin   ALL = NOPASSWD:ALL  //admin組的成員,sudo不用輸入密碼了  

8,如果不想自啟動,可以用啟動指令碼

查看複製列印?
    1. #!/bin/bash  
    2.   
    3. param=$1  
    4.   
    5. start()  
    6. {  
    7.   
    8.  #啟動nginx  
    9.  sudo nginx    //nginx需要root使用者來啟動  
    10.  #啟動mysql  
    11.  mysql.server start  
    12.  #啟動php-fpm  
    13.  fpms=`ps aux | grep -i "php-fpm" | grep -v grep | awk ‘{print $2}‘`  
    14.  if [ ! -n "$fpms" ]; then  
    15.  php-fpm  
    16.  echo "PHP-FPM Start"  
    17.  else  
    18.  echo "PHP-FPM Already Start"  
    19.  fi  
    20. }  
    21.   
    22. stop()  
    23. {  
    24.   
    25.  #停止nginx  
    26.  sudo nginx -s stop  
    27.  #停止mysql  
    28.  mysql.server stop  
    29.  #停止php-fpm  
    30.  fpms=`ps aux | grep -i "php-fpm" | grep -v grep | awk ‘{print $2}‘`  
    31.  echo $fpms | xargs kill -9  
    32.   
    33.  for pid in $fpms; do  
    34.  if echo $pid | egrep -q ‘^[0-9]+$‘; then  
    35.  echo "PHP-FPM Pid $pid Kill"  
    36.  else  
    37.  echo "$pid IS Not A PHP-FPM Pid"  
    38.  fi  
    39.  done  
    40. }  
    41.   
    42. case $param in  
    43.  ‘start‘)  
    44.  start;;  
    45.  ‘stop‘)  
    46.  stop;;  
    47.  ‘restart‘)  
    48.  stop  
    49.  start;;  
    50.  *)  
    51.  echo "Usage: ./web.sh start|stop|restart";;  
    52. esac  

mac 安裝 php nginx mysql

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.