server {
listen 80;
server_name www.aldjflas.cn;
access_log /home/logs/bbs/access.log combined buffer=32k;
error_log /home/logs/bbs/error.log warn;
location / {
index index.html index.htm index.php;
root /data/www/wwwroot/bbs;
}
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|thumb) {
root /data/www/wwwroot/bbs;
access_log off;
expires 10d;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/dev/shm/php-fcgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www/wwwroot/bbs$fastcgi_script_name;
}
}
listen 80;
server_name www.aldjflas.cn;
access_log /home/logs/bbs/access.log combined buffer=32k;
error_log /home/logs/bbs/error.log warn;
location / {
index index.html index.htm index.php;
root /data/www/wwwroot/bbs;
}
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|thumb) {
root /data/www/wwwroot/bbs;
access_log off;
expires 10d;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/dev/shm/php-fcgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www/wwwroot/bbs$fastcgi_script_name;
}
}
0
本帖最后由 andy 于 2009-11-5 11:02 编辑
有时虚拟主机的配置文件不以这样的方式配置
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/dev/shm/php-fcgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www/wwwroot/bbs$fastcgi_script_name;
}
而是包含一个文件
server
{
listen 80;
server_name www.test.com;
index index.html index.htm index.php;
root /data/server;
access_log "/home/logs/access.log" combined_realip;
location ~ .*\.php?$
{
include enable_php5.conf;
}
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html)$
{
access_log off;
expires 30d;
}
}
其中enable_php5.conf 文件内容如下:
fastcgi_pass unix:/tmp/php-fcgi.sock;
fastcgi_index index.php;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
#new ac upload
#fastcgi_pass_request_body off;
#client_body_in_file_only clean;
#fastcgi_param REQUEST_BODY_FILE $request_body_file;
#
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 was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
fastcgi_connect_timeout 300;
因为在 enable_php5.conf 中有很多配置参数,写到配置文件中不仅繁琐,而且容易出错,这样的形式方便配置多个虚拟主机。
有时虚拟主机的配置文件不以这样的方式配置
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/dev/shm/php-fcgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www/wwwroot/bbs$fastcgi_script_name;
}
而是包含一个文件
server
{
listen 80;
server_name www.test.com;
index index.html index.htm index.php;
root /data/server;
access_log "/home/logs/access.log" combined_realip;
location ~ .*\.php?$
{
include enable_php5.conf;
}
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html)$
{
access_log off;
expires 30d;
}
}
其中enable_php5.conf 文件内容如下:
fastcgi_pass unix:/tmp/php-fcgi.sock;
fastcgi_index index.php;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
#new ac upload
#fastcgi_pass_request_body off;
#client_body_in_file_only clean;
#fastcgi_param REQUEST_BODY_FILE $request_body_file;
#
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 was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
fastcgi_connect_timeout 300;
因为在 enable_php5.conf 中有很多配置参数,写到配置文件中不仅繁琐,而且容易出错,这样的形式方便配置多个虚拟主机。
编辑回复