常用位置:
nginx:
- 安装位置:
/usr/local/Cellar/nginx
- log:
/usr/local/var/log/nginx/error.log
- 配置位置:
/usr/local/etc/nginx
- document root:
/var/www
- 安装位置:
php
- 安装位置:
/usr/local/Cellar/php56/5.6.8/
- 配置位置:
/usr/local/etc/php/5.6/php.ini
- 安装位置:
mysql
- 查看server信息:
mysqld --help --verbose
- 安装位置:
/usr/local/Cellar/mysql
- 查看server信息:
安装
引用一篇非常详细的博客:Install Nginx, PHP-FPM, MySQL and phpMyAdmin on OS X Mavericks or Yosemite
Xcode
1 | xcode-select --install |
Homebrew
1 | ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" |
Check for any conflicts or problems (If you have confilcts, sort them out before you continue with this guide):
1 | brew doctor |
Update and upgrade its formulas in case you already had Homebrew installed before:
1 | brew update && brew upgrade |
PHP-FPM
1 | brew tap homebrew/dupes |
Now install it with the following arguments:
1 | brew install --without-apache --with-fpm --with-mysql php56 |
Setup PHP CLI binary
If you want to use the PHP command line binary, you need to update the $PATH environment variable of your shell profile:
1 | # If you use Bash |
Setup auto start
Create a folder for our LaunchAgents and symlink the start/stop service:
1 | mkdir -p ~/Library/LaunchAgents |
And start PHP-FPM:
1 | launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist |
Make sure PHP-FPM is listening on port 9000:
1 | lsof -Pni4 | grep LISTEN | grep php |
The output should look something like this:
1 | php-fpm 69659 frdmn 6u IPv4 0x8d8ebe505a1ae01 0t0 TCP 127.0.0.1:9000 (LISTEN) |
MySQL
Next step is to install MySQL:
1 | brew install mysql |
Setup auto start
1 | ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents |
And start the database server:
1 | launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist |
1 | mysql_secure_installation |
Test connection
1 | mysql -uroot -p |
phpMyAdmin
Install autoconf, which is needed for the installation of phpMyAdmin:
1 | brew install autoconf |
Set $PHP_AUTOCONF:
1 | # If you use Bash |
Let’s start with the installation of phpMyAdmin:
1 | brew install phpmyadmin |
Nginx
Install the default Nginx with:
1 | brew install nginx |
Setup auto start
Since we want to use port 80 have to start the Nginx process as root:
1 | sudo cp -v /usr/local/opt/nginx/*.plist /Library/LaunchDaemons/ |
Test web server
Start Nginx for the first with:
1 | sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist |
Stop Nginx again:
1 | sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.nginx.plist |
Make alias:
1 | alias nginx.start='sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist' |