文章目录

OS: OS X El Capitan Version 10.11.4

  1. Install Homebrew

    1
    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

  2. Install PHP 5.6

    1
    2
    3
    brew install --without-apache --with-fpm --with-mysql php56
    # if an error occured as: No available formula for php56, execute the following command at first.
    brew tap homebrew/homebrew-php

    The configuration file of PHP is located at /usr/local/etc/php/5.6/php.ini. The configuration file of PHP-FPM is located at /usr/local/etc/php/5.6/php-fpm.conf. To install PHP extensions, type brew install php56-memcached for example. It will be put under directory /usr/local/etc/php/5.6/conf.d after installation.

  3. Update $PATH env variable in your ~/.bashrc or ~/.zshrc

    1
    export PATH="/usr/local/sbin:/usr/local/bin:$PATH"

  4. Start PHP-FPM

    1
    2
    ln -sfv /usr/local/opt/php56/homebrew.mxcl.php56.plist ~/Library/LaunchAgents
    launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist

  5. Add a script to restart fpm Create a new file named /usr/local/etc/php/fpm-restart

    1
    2
    3
    chmod ug+x /usr/local/etc/php/fpm-restart
    cd /usr/local/sbin/
    ln -s /usr/local/etc/php/fpm-restart

  6. Install Nginx

    1
    brew install nginx

    The configuration file of Nginx is located at /usr/local/etc/nginx/nginx.conf. To reload Nginx configuration, try nginx -s reload The default server root located as: /usr/local/opt/nginx/html

文章目录