<pre>
server {
listen 80;
server_name 你的域名;
root 網(wǎng)站的根目錄;
index index.php index.html index.htm;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$query_string;
}
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
</pre>
在這個 server
區(qū)塊里面,定義了一些基本的配置,比如監(jiān)聽的端口號,綁定的域名,網(wǎng)站的根目錄,默認打開的文件。
這里一共有兩個 location
區(qū)塊,第一個匹配默認的請求,第二個匹配對 PHP 的請求,有 PHP 請求,就把這些請求發(fā)送給 FastCGI 服務(PHP-FPM),地址是 127.0.0.1:9000
。