I.. installation Nginx Please refer to:? http://qingwei201314.iteye.com/blog/1729174
Get and unzip the PHP source code:
Tar zxf php-x.x.x
Configure and build PHP. In this step you can customize PHP with a number of options, such as enabling certain extensions. Run the./configure--help command to get a complete list of available options. In this example, we only have a simple configuration that includes PHP-FPM and MySQL support.
Cd.. /php-x.x.x./configure--enable-fpm--with-mysqlmakesudo make install
Create the configuration file and copy it to the correct location.
CP php.ini-development/usr/local/php/php.inicp/usr/local/etc/ PHP-FPM.CONF.DEFAULT/USR/LOCAL/ETC/PHP-FPM.CONFCP sapi/fpm/php-fpm/usr/local/bin
You need to be reminded that if the file does not exist, it prevents Nginx from sending the request to the back-end PHP-FPM module. To avoid attacks that are injected by malicious scripts.
php.ini the configuration items in the file? cgi.fix_pathinfo? 0 ?.
open php.ini:
vim/usr/local/php/php.ini
navigate to " cgi.fix_pathinfo= ? and modify it to resemble the following:
cgi.fix_pathinfo=0
before starting the service, you need to modify the php-fpm.conf configuration file to make sure the PHP-FPM module uses Www-data The user and the Www-data user group are running.
vim/usr/local/etc/php-fpm.conf
find the following and modify:
then start PHP-FPM service:
Pre class= "Brush:php;toolbar:false" >/usr/local/bin/php-fpm
This document does not cover further configuration of PHP-FPM, and if you need more information, please consult the relevant documentation.
configure Nginx to support PHP applications:
vim/usr/local/nginx/conf/nginx.conf
Modify the default location block, Enable it to support. php Files:
location/{root HTML; Index index.php index.html index.htm;}
next configuration to ensure that requests for. php files will be routed to the backend PHP-FPM module, uncomment the default PHP configuration block, and modify to the following:
location ~* \.php$ {fastcgi_index index.php; Fastcgi_pass 127.0.0.1:9000; Include Fastcgi_params; Fastcgi_param script_filename $document _root$fastcgi_script_name; Fastcgi_param script_name $fastcgi _script_name;}
restart Nginx.
- If you use thinkphp, configure PathInfo:
- Modify part of the 6th step as follows:
Location ~ \.php { fastcgi_pass 127.0.0.1:9000; Fastcgi_index index.php; Set $path _info ""; Set $real _script_name $fastcgi _script_name; if ($fastcgi _script_name ~ "^ (. +?\.php) (/.+) $") { set $real _script_name $; Set $path _info; } Fastcgi_param script_filename $document _root$real_script_name; Fastcgi_param script_name $real _script_name; Fastcgi_param path_info $path _info; Include fastcgi_params; }