Under the Mac install PHP nginx mysql root Linux almost, we recommend that you use the Brew Management kit installation.
1, install homebrew
Http://brew.sh/index_zh-cn.html
The installation method will change, so install the official method above to load. Installing Homebrew-cask
- $ brew Tap Caskroom/cask
Homebrew-cask installs something, more.
2, change the source or add agent
Brew Management Toolkit, which is downloaded from GitHub by default, is often used by walls. and turtle speed.
View copy print?
- $ Brew Install Git
- $ cd/usr/local/homebrew
- $ git Remote Set-url origin https://git.coding.net/homebrew/homebrew.git
If you do not want to change the source, you can add agent, if your agent, not by the wall, and relatively fast
View copy print?
- Zhangyingdemacbook-pro:homebrew zhangying$ Cat ~/.CURLRC
- socks5="127.0.0.1:1080"
3, installing Nginx MySQL
- $ brew Install Nginx MySQL
4, install PHP
View copy print?
- Add an extension library
- $ brew Tap Homebrew/dupes
- $ brew Tap Homebrew/versions
- $ brew Tap homebrew/php
- $ Brew Search PHP //View available versions of PHP
- $ brew Install PHP54 //install required version
- The default is PHP, so the PHP environment to point to the new
- $ 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 //Update configuration
5, configuration file directory
- /usr/local/etc/nginx
- /usr/local/etc/php
- /usr/local/cellar/mysql/5.7.16
6, start-up, with Nginx as an example
View copy print?
- $ ln-s/usr/local/opt/nginx/*.plist ~/library/launchagents/
- $ launchctl Load ~/library/launchagents/homebrew.mxcl.nginx.plist //Load
- $ launchctl Unload ~/library/launchagents/homebrew.mxcl.nginx.plist //Cancel load
7,sudo No password
View copy print?
- $ sudo su
- # Visudo
- %admin all = Member of Nopasswd:all//admin Group, sudo does not enter password
8, if you do not want to self-start, you can use the startup script
View copy print?
- #!/bin/bash
- param= $
- Start ()
- {
- #启动nginx
- sudo nginx //nginx requires root user to start
- #启动mysql
- Mysql.server start
- #启动php-FPM
- fpms= ' ps aux | Grep-i "PHP-FPM" | grep-v grep | awk ' {print $} '
- 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 $} '
- 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 install PHP nginx mysql