Operating system: CentOS6.5 nginx software version: nginx-1.6.0 PHP software version: php-5.3.28
Nginx is not supported by default PHP environment, we can use two methods to let Nginx support PHP environment
Method one: When compiling and installing PHP, add the PHP fpm module "--ENABLE-FPM" in the configuration to invoke the native PHP environment
1. Compiling and installing PHP
First install the required toolkit for PHP
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7B/69/wKiom1bNSvzBa9o6AAAd9nTP6Qc646.jpg "title=" Installation kit. jpg "alt=" wkiom1bnsvzba9o6aaad9ntp6qc646.jpg "/>
Then compile and install PHP, when configured with "--enable-fpm" This configuration item
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/7B/68/wKioL1bNTpCT97YRAABIAyNvNQ0430.jpg "title=" PHP installation. jpg "alt=" wkiol1bntpct97yraabiaynvnq0430.jpg "/>
Post-Installation adjustments
650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M02/7B/69/wKiom1bNUjiTn_7XAABKcBGbfGg803.jpg "title=" adjust. jpg "alt=" Wkiom1bnujitn_7xaabkcbgbfgg803.jpg "/>
2. Configure Nginx support PHP environment, start the PHP-FPM process.
First create a PHP-FPM program user PHP (name optional)
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7B/68/wKioL1bNVr_g5F96AABGeAfcVRg994.jpg "title=" Fpm.jpg "alt=" Wkiol1bnvr_g5f96aabgeafcvrg994.jpg "/>
Then modify the PHP-FPM configuration file to save the exit
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7B/68/wKioL1bNWe3weMUoAABasHSA5ek947.jpg "title=" FPM configuration. jpg "alt=" wkiol1bnwe3wemuoaabashsa5ek947.jpg "/>
Finally start the program
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7B/69/wKioL1bNWqCiQgm6AAA2hx7y7s4301.jpg "title=" Start Fpm.jpg "alt=" Wkiol1bnwqciqgm6aaa2hx7y7s4301.jpg "/>
3. Configure Nginx support PHP parsing, modify nginx configuration file, you need to add a location setting in the corresponding "server{}" configuration segment to specify what action to take when accessing the. PHP Web page. Restart Nginx Service after modification
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7B/69/wKioL1bNYu_yQ8tkAACf9br35Co933.jpg "title=" Nginx configuration. jpg "alt=" wkiol1bnyu_yq8tkaacf9br35co933.jpg "/>
4. Writing a PHP test page
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/7B/69/wKioL1bNX9eTJy4fAAAjjmLzcK0604.jpg "title=" PHP test page. jpg "alt=" wkiol1bnx9etjy4faaajjmlzck0604.jpg "/>
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7B/69/wKioL1bNY06QV84FAAAxrJk5qoM369.jpg "title=" PHP test page write. jpg "alt=" wkiol1bny06qv84faaaxrjk5qom369.jpg "/>
5. Browser access
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/7B/6B/wKiom1bNYz-RBX3DAABwcN5rpUA782.jpg "title=" authentication. jpg "alt=" Wkiom1bnyz-rbx3daabwcn5rpua782.jpg "/>
Method Two: Nginx reverse proxy, we can be the Nginx server's. PHP dynamic request forwarded to the lamp server to handle. So that Nginx is responsible for static pages and lamp responsible for dynamic page static separation effect
1. Directly set the Nginx configuration file, find the corresponding "server{}" configuration section, and then use the option "Proxy_pass" to specify the Apache server, let Apache to respond. PHP request. For example, the IP address of the Apache server is 192.168.100.2
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/7B/6B/wKiom1bNZn-hwk9_AABw5iswrNU839.jpg "title=" Reverse proxy. jpg "alt=" wkiom1bnzn-hwk9_aabw5iswrnu839.jpg "/>
Add the following to restart the Nginx service can be
Nginx supports PHP environment in two ways