標籤: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
- $ brew tap caskroom/cask
homebrew-cask安裝的東西,更多。
2,換源或者加代理
brew管理工具包,預設是從github上面下載,github經常被牆。並且龜速。
查看複製列印?
- $ brew install git
- $ cd /usr/local/Homebrew
- $ git remote set-url origin https://git.coding.net/homebrew/homebrew.git
如果不想換源話,可以加代理,前提是你的代理,不被牆,並且比較快
查看複製列印?
- zhangyingdeMacBook-Pro:Homebrew zhangying$ cat ~/.curlrc
- socks5="127.0.0.1:1080"
3,安裝nginx mysql
- $ brew install nginx mysql
4,安裝php
查看複製列印?
- //添加擴充庫
- $ brew tap homebrew/dupes
- $ brew tap homebrew/versions
- $ brew tap homebrew/php
-
- $ brew search php //查看php的可用版本
- $ brew install php54 //安裝所需版本
-
- //預設是有php的,所以php的環境要指向新的
- $ echo ‘export PATH="$(brew --prefix homebrew/php/php54)/bin:$PATH"‘ >> ~/.bash_profile
- $ echo ‘export PATH="$(brew --prefix homebrew/php/php54)/sbin:$PATH"‘ >> ~/.bash_profile
- $ echo ‘export PATH="/usr/local/bin:/usr/local/sbin:$PATH"‘ >> ~/.bash_profile
- $ source ~/.bash_profile //更新配置
5,設定檔目錄
- /usr/local/etc/nginx
- /usr/local/etc/php
- /usr/local/Cellar/mysql/5.7.16
6,開機啟動,以nginx為例
查看複製列印?
- $ ln -s /usr/local/opt/nginx/*.plist ~/Library/LaunchAgents/
- $ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist //載入
- $ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist //取消載入
7,sudo無密碼
查看複製列印?
- $ sudo su
- # visudo
- %admin ALL = NOPASSWD:ALL //admin組的成員,sudo不用輸入密碼了
8,如果不想自啟動,可以用啟動指令碼
查看複製列印?
- #!/bin/bash
-
- param=$1
-
- start()
- {
-
- #啟動nginx
- sudo nginx //nginx需要root使用者來啟動
- #啟動mysql
- mysql.server start
- #啟動php-fpm
- fpms=`ps aux | grep -i "php-fpm" | grep -v grep | awk ‘{print $2}‘`
- if [ ! -n "$fpms" ]; then
- php-fpm
- echo "PHP-FPM Start"
- else
- echo "PHP-FPM Already Start"
- fi
- }
-
- stop()
- {
-
- #停止nginx
- sudo nginx -s stop
- #停止mysql
- mysql.server stop
- #停止php-fpm
- fpms=`ps aux | grep -i "php-fpm" | grep -v grep | awk ‘{print $2}‘`
- echo $fpms | xargs kill -9
-
- for pid in $fpms; do
- if echo $pid | egrep -q ‘^[0-9]+$‘; then
- echo "PHP-FPM Pid $pid Kill"
- else
- echo "$pid IS Not A PHP-FPM Pid"
- fi
- done
- }
-
- case $param in
- ‘start‘)
- start;;
- ‘stop‘)
- stop;;
- ‘restart‘)
- stop
- start;;
- *)
- echo "Usage: ./web.sh start|stop|restart";;
- esac
mac 安裝 php nginx mysql