nginx配置drupal的一个例子

server {
listen 80;
server_name example.com;

root /usr/share/nginx/html;
index index.php index.html index.htm;

location / {
# This is cool because no php is touched for static content
try_files $uri @rewrite;
}

location @rewrite {
# You have 2 options here
# For D7 and above:
# Clean URLs are handled in drupal_environment_initialize().
rewrite ^ /index.php;
# For Drupal 6 and bwlow:
# Some modules enforce no slash (/) at the end of the URL
# Else this rewrite block wouldn’t be needed (GlobalRedirect)
#rewrite ^/(.*)$ /index.php?q=$1;
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/tmp/php-fpm.sock;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
include fastcgi_params;
}

location ~ ^/sites/.*/files/styles/ {
try_files $uri @rewrite;
}

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *