To run your drupal site on nginx, the lightweight web server, you will need a custom conf file to make nginx working with php. If you want to enable drupal's clean url function ( maybe you should because a clean url is both more user-friendly and Search Engine friendly ), you will need a additional nginx rewrite rule. I have managed to get drupal 6 working on nginx, and here is what in my nginx configuration file:
server {
listen 80;
server_name www.o-learn.com ; # your domain name
client_max_body_size 50M;
root /wwwroot/www.o-learn.com; # your drupal site files
charset utf8;
source_charset utf8;
access_log /logs/www.o-learn.com.access.log main; # log file path
# All dynamic requests will go here
location / {
root /wwwroot/www.o-learn.com; # your drupal site files
index index.php;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
break;
}
}
error_page 404 /index.php;
# serve static files directly
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico)$ {
access_log off;
expires 30d;
}
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000; #your spawn_fcgi socket
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /wwwroot/www.o-learn.com$fastcgi_script_name;
# your drupal site file path
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_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 GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
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;
}
}
I hope it can help you. If you meet any problem, you can leave a comment, and I will try what I can to help.
Post new comment