Install PHP5-FPM, php5-cgi. and install other PHP components according to your needs
sudo apt-get install Nginx php5-fpm
sudo apt-get install PHP-APC php5-curl php5-gd php5-imagick php5-mysql php5-memcache php5-memcached php5- MCrypt
Configure Nginx
sudo vi/etc/nginx/sites-available/default
Code
server {
Listen 80; # # Listen for IPv4
Listen [::]: Default ipv6only = on; # # Listen for IPv6
server_name localhost;
root/var/www;
Index index.php index.html index.htm;
Expires 14d;
#access_log/var/log/nginx/localhost.access.log;
Location ~ \.php$ {
Fastcgi_pass 127.0. 0.1:9,000;
Fastcgi_index index.php;
Fastcgi_param application_env production;
Include fcgi.conf;
Expires off;
}
}
Modify Fastcgi.conf
Code
Fastcgi_param Gateway_interface cgi/1.1;
Fastcgi_param Server_software Nginx;
Fastcgi_param query_string $query _string;
Fastcgi_param Request_method $request _method;
Fastcgi_param Content_Type $content _type;
Fastcgi_param content_length $content _length;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Fastcgi_param script_name $fastcgi _script_name;
Fastcgi_param Request_uri $request _uri;
Fastcgi_param Document_uri $document _uri;
Fastcgi_param document_root $document _root;
Fastcgi_param server_protocol $server _protocol;
Fastcgi_param remote_addr $remote _addr;
Fastcgi_param Remote_port $remote _port;
Fastcgi_param server_addr $server _addr;
Fastcgi_param server_port $server _port;
Fastcgi_param server_name $server _name;
# PHP only, required if PHP is built with? enable-force-cgi-redirect
Fastcgi_param Redirect_status 200;
Modify nginx.conf when modifying the Web default directory in order to/var/www/, you can build a PHP test page in this directory
Access
Reference: http://shen2.cn/2010/08/nginx-php5-fpm/