Zend Framework on nginx

前端 未结 8 1267
小蘑菇
小蘑菇 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:20

    I don't know of any automatic/systematic way to convert the htaccess-file, you'll probably have to do it manually. The Nginx wiki is the best resource for nginx documentation.

    Edit: I'm running Zend Framework on Nginx myself now and the config looks like this:

    server {
      listen 80;
      server_name servername.com;
    
      root /var/www/zendapp/public;
    
      location / {
        index index.php;
      }
    
      # Deny access to sensitive files.
      location ~ (\.inc\.php|\.tpl|\.sql|\.tpl\.php|\.db)$ {
        deny all;
      }
      location ~ \.htaccess {
        deny all;
      }
    
      # Rewrite rule adapted from zendapp/public/.htaccess
      if (!-e $request_filename) {
        rewrite ^.*$ /index.php last;
      }
    
      # PHP scripts will be forwarded to fastcgi processess.
      # Remember that the `fastcgi_pass` directive must specify the same
      # port on which `spawn-fcgi` runs.
      location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
    
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
      }
    
      location = /50x.html {
          root   /var/www/default;
      }
    }
    

    As you can see, the rewrite rule itself is very simple.

提交回复
热议问题