Reference documents:
Http://dhq.me/mac-apt-get-homebrew
http://www.xiaoche.me/blog/2012/02/01/homebrew-install/
http://dhq.me/mac-install-nginx-mysql-php-fpm
Http://www.cnblogs.com/zhongyuan/p/3313106.html
1. Installing homebrew
" $ (curl-fssl https://raw.github.com/Homebrew/homebrew/go/install) "
2. Installing Nginx
Install NIGNX with brew one click:
Install Nginx
This installs the Nginx, you can use the following command to operate Nginx:
#打开 Nginx sudo nginx# Reload config | restart | stop | -S reload|reopen|stop| -T
After you open Nginx, the default access port 8080, if you want to change to a common 80 port, you want to modify the "/usr/local/etc/nginx/nginx.conf" listening (listen) port value.
The default file access directory (root) is "/usr/local/cellar/nginx/1.2.6/html" (Here the 1.2.6 is the installed Nginx version, the folder name is based on the installed Nginx version).
3. Installing PHP-FPM
Mac is pre-loaded with PHP, but many extensions are not installed, visual only in the terminal to execute the next PHP instructions, so I choose to reinstall PHP. Since brew does not have a PHP installation by default, use "Brew tap" to install Brew's third-party packages, which use Josegonzalez's PHP installation package, as follows:
Brew tap homebrew/dupesbrew tap Josegonzalez/homebrew-php
Once you're done, you can install PHP with brew. Here are several versions of PHP can be installed, specifically, you can perform "Brew search PHP" to see what PHP version can be installed. Here I choose php5.5, and install PHP-FPM and so on, are optional, such as conflict can also choose not to install--without Some options, commands are as follows:
Install php55--with-imap--with-tidy--with-debug--with-pgsql--with-mysql--with-fpm
More installation options can be viewed through the brew options php54. After the instructions are executed, PHP and PHP-FPM are installed.
Because it is a reload of PHP, before the system pre-installed PHP has not been uninstalled, so when the terminal calls PHP, or in the previous version of the PHP system to parse, so here need to modify path, specify the parsing path of PHP. What I chose here is to modify the system-level path sequence. Open the/etc/path and use Vim to modify it: Put/usr/local/sbin in front of the/usr/sbin (in English for the installation of the PHP-FPM command line prompt).
1 Make inch your PATH: 4 5 Path="/usr/local/sbin: $PATH"69"UserName ".
The following is the order of the changes.
1 cat /etc/paths2 /usr/local/sbin3 /usr/local/bin4 / usr/bin5 /bin6 /usr/sbin7 /sbin
You can choose to start the boot php-fpm:
1To launch php-fpm on startup:2 3* If This is your firstInstall:4 5 mkdir-P ~/library/launchagents6 7 CP/usr/local/cellar/php55/5.5. -/homebrew.mxcl.php55.plist ~/library/launchagents/8 9Launchctl Load-W~/library/launchagents/homebrew.mxcl.php55.plistTen One A -*If This is a upgrade and you already has the homebrew.mxcl.php55.plist loaded: - theLaunchctl Unload-W~/library/launchagents/homebrew.mxcl.php55.plist - - CP/usr/local/cellar/php55/5.5. -/homebrew.mxcl.php55.plist ~/library/launchagents/ - +Launchctl Load-W~/library/launchagents/homebrew.mxcl.php55.plist
At this point, the PHP-FPM installation is complete.
Do you want to start php-fpm? Direct:
1 php-fpm
Error (usually fail to open error_log, etc.), this is because the built-in PHP-FPM is opened, and there are two ways to open it:
The first type: Open with Superuser, should be in the system level and other path sequence
1 sudo -s #开启root
2 PHP-FPM
Second: Open directly at the location of the script (/usr/local/cellar/php55/5.5.20/sbin/):
1 The control script is located at/usr/local/cellar/php55/5.5. /SBIN/PHP55-FPM
cd/usr/local/cellar/php55/5.5. /sbinphp55-fpm
4. Configure Nginx PHP-FPM
Open the default annotated PHP location settings, modify the following (specific configuration parameters, such as the path, here to my local installation as the subject, note the revision of your corresponding version number, here is 1.6.2):
1 Location ~ \.php$ {2 fastcgi_intercept_errors on; 3 Fastcgi_pass 127.0. 0.1:9000; 4 fastcgi_index index.php; 5 Fastcgi_param script_filename /usr/local/cellar/nginx/1.6. 2/html$fastcgi_script_name; 6 Include /usr/local/etc/nginx/fastcgi_params; 7 }
5. Testing
Write a test.php under Nginx's default publishing root '/usr/local/cellar/nginx/1.6.2/html ' and then enter url:localhost:8080/test.php in the browser, The information page that appears in PHP explains the successful configuration!
1 # test.php 2 <? PHP 3 Phpinfo (); 4 ?>
macos10.9 Configuration nginx,php-fpm