Zend Framework on nginx

前端 未结 8 1261
小蘑菇
小蘑菇 2021-01-30 09:51

The Zend Framework based site I have been working on is now being migrated to its production server. This server turns out to be nginx (surprise!). Naturally the site does not w

相关标签:
8条回答
  • 2021-01-30 10:22

    Actually i run a nginx with a drupal site that work like zend framework: one index.php as bootstrap

    this is the rule (not tested on zend framework, just on drupal, but should be similar)

    location / {
                if (!-e $request_filename) {
                        rewrite  ^/(.*)$  /index.php?q=$1  last;
                        break;
            }
        }
    
    error_page  404              /index.php;
    
    0 讨论(0)
  • 2021-01-30 10:32

    I know it's a pretty old thread but it might help some people anyway.

    Basically it redirects any 404 error to index.php, but if the file exists (type file) it will set the right root.

    I did it from the top of my head. It might not be working right away, and you have to put the right path and fastcgi config. I also put everything back to index.php as it should work like that with Zend_Framework

    error_page  404 = /index.php;
    
    location / {
        if (-f $request_filename) {
            root   /var/www;
        }
    }
    
    location ~ \.php$ {
            fastcgi_pass   unix:/tmp/php.sock;
            fastcgi_index  index.php;
    
            fastcgi_param  SCRIPT_FILENAME     /var/www/index.php;
            include /etc/nginx/fastcgi_params;
    }
    
    0 讨论(0)
提交回复
热议问题