1. update
1 | sudo apt-get update |
2. nginx
1 | sudo apt-get install nginx |
3. php
1 | sudo apt-get install php5-fpm |
php5-mysql
when mysql needphp5-mcrypt
when phpMyAdmin need
4. Nginx
Static type file no log, one day expired
1
2
3
4location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
access_log off;
expires 1d;
}The data type root directory could request
1
2
3
4
5
6location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
#try_files $uri $uri/ =404;
index index.html index.htm index.php default.html default.htm default.php;
}Php type files’ deal process config
1
2
3
4
5
6
7
8
9
10
11
12location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
If php no this config, script may not work.
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
5. Restart & Test
1 | sudo /etc/init.d/nginx restart |
try request this script in browser<?php phpinfo(); ?>