I am wondering if you can have more than one 'fastcgi_index' in nginx virtual config file... If you view my virtual.conf below you will see I put home.php next to 'index.php' My home.php is more or less my sites index.php. My site is running ok (if it was running better I wouldn't be looking to see if any tweaks can be made) with index.php as the 'fastcgi_index' but I am not even sure why index.php was used (other than it is most likely the default setting for 'fastcgi_index') since my site uses home.php rather than index.php. So my question is... will my site run better if I replace my current 'fastcgi_index' (index.php) to home.php. Or can I put both in 'fastcgi_index' as noted below?

location ~ \.php$ {
    root           /home/xx/usr/share/nginx/html;
    fastcgi_index  index.php **home.php;**
    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    include        fastcgi_params;
    include        fastcgi.conf;

No, fastcgi_index can only take a single filename. This is because nginx doesn't search for the specified filename, it simply appends the string which you provide to the URL if it ends with a slash and hands it off to the FastCGI service. FastCGI paths don't have to exist as files on the filesystem, and so nginx cannot verify their existence.

| improve this answer | |
  • thanks, so do you recommend I use index.php or home.php? – Andrew Jun 25 '12 at 23:26
  • @Andrew index.php is more common, but it doesn't really matter. If you already use home.php then just go with that. – mgorven Jun 25 '12 at 23:28
  • 1
    It doesn't actually matter which one you use. Because of the location match, the url is already guaranteed to end with ".php" so fastcgi_index won't ever come into play. – kolbyjack Jun 26 '12 at 0:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.